1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-06 09:20:43 +01:00

Merge pull request #1595 from joseph-flinn/master

Adding build/release workflows
This commit is contained in:
Joseph Flinn 2021-03-04 11:38:22 -08:00 committed by GitHub
commit 34e7970363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 268 additions and 0 deletions

102
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,102 @@
name: Build
on:
push:
branches-ignore:
- 'l10n_master'
workflow_dispatch:
inputs:
jobs:
cloc:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Set up cloc
run: |
sudo apt update
sudo apt -y install cloc
- name: Print lines of code
run: cloc --include-lang TypeScript,JavaScript,HTML,Sass,CSS --vcs git
setup:
runs-on: ubuntu-latest
outputs:
repo_url: ${{ steps.gen_vars.outputs.repo_url }}
adj_build_number: ${{ steps.gen_vars.outputs.adj_build_number }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Get Package Version
id: gen_vars
run: |
repo_url=https://github.com/$GITHUB_REPOSITORY.git
adj_build_num=${GITHUB_SHA:0:7}
echo "::set-output name=repo_url::$repo_url"
echo "::set-output name=adj_build_number::$adj_build_num"
browser:
runs-on: windows-latest
needs: setup
env:
REPO_URL: ${{ needs.setup.outputs.repo_url }}
BUILD_NUMBER: ${{ needs.setup.outputs.adj_build_number }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: '10.x'
- name: Print environment
run: |
node --version
npm --version
- name: npm setup & test
run: |
npm install
npm run dist
npm run test
- name: gulp
run: gulp ci
- name: Upload opera artifact
uses: actions/upload-artifact@v2
with:
name: dist-opera-${{ env.BUILD_NUMBER }}.zip
path: dist/dist-opera-${{ env.BUILD_NUMBER }}.zip
- name: Upload chrome artifact
uses: actions/upload-artifact@v2
with:
name: dist-chrome-${{ env.BUILD_NUMBER }}.zip
path: dist/dist-chrome-${{ env.BUILD_NUMBER }}.zip
- name: Upload firefox artifact
uses: actions/upload-artifact@v2
with:
name: dist-firefox-${{ env.BUILD_NUMBER }}.zip
path: dist/dist-firefox-${{ env.BUILD_NUMBER }}.zip
- name: Upload edge artifact
uses: actions/upload-artifact@v2
with:
name: dist-edge-${{ env.BUILD_NUMBER }}.zip
path: dist/dist-edge-${{ env.BUILD_NUMBER }}.zip
- name: Upload coverage artifact
uses: actions/upload-artifact@v2
with:
name: coverage-${{ env.BUILD_NUMBER }}.zip
path: coverage/coverage-${{ env.BUILD_NUMBER }}.zip

166
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,166 @@
name: Release
on:
workflow_dispatch:
inputs:
release_tag_name_input:
description: "Release Tag Name <X.X.X>"
required: true
jobs:
setup:
runs-on: ubuntu-latest
outputs:
tag_version: ${{ steps.create_tags.outputs.tag_version }}
release_upload_url: ${{ steps.create_release.outputs.upload_url }}
repo_url: ${{ steps.gen_vars.outputs.repo_url }}
adj_build_number: ${{ steps.gen_vars.outputs.adj_build_number }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Get Package Version
id: gen_vars
shell: pwsh
run: |
$repo_url = "https://github.com/${env:GITHUB_REPOSITORY}.git"
$build_num = [int]$env:GITHUB_RUN_NUMBER
$adj_build_num = $build_num + 3000
echo "::set-output name=repo_url::$repo_url"
echo "::set-output name=adj_build_number::$adj_build_num"
- name: Create Release Vars
id: create_tags
run: |
case "${RELEASE_TAG_NAME_INPUT:0:1}" in
v)
echo "RELEASE_NAME=${RELEASE_TAG_NAME_INPUT:1}" >> $GITHUB_ENV
echo "RELEASE_TAG_NAME=$RELEASE_TAG_NAME_INPUT" >> $GITHUB_ENV
echo "::set-output name=tag_version::$RELEASE_TAG_NAME_INPUT"
;;
[0-9])
echo "RELEASE_NAME=$RELEASE_TAG_NAME_INPUT" >> $GITHUB_ENV
echo "RELEASE_TAG_NAME=v$RELEASE_TAG_NAME_INPUT" >> $GITHUB_ENV
echo "::set-output name=tag_version::v$RELEASE_TAG_NAME_INPUT"
;;
*)
exit 1
;;
esac
env:
RELEASE_TAG_NAME_INPUT: ${{ github.event.inputs.release_tag_name_input }}
- name: Create Draft Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_TAG_NAME }}
release_name: ${{ env.RELEASE_NAME }}
draft: true
prerelease: false
browser:
runs-on: windows-latest
needs: setup
env:
REPO_URL: ${{ needs.setup.outputs.repo_url }}
BUILD_NUMBER: ${{ needs.setup.outputs.adj_build_number }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: '10.x'
- name: Print environment
run: |
node --version
npm --version
- name: npm setup & test
run: |
npm install
npm run dist
npm run test
- name: gulp
run: gulp ci
- name: Build sources for reviewers
shell: cmd
run: |
mkdir dist\Source
call git clone --branch=%GITHUB_REF% %REPO_URL% dist\Source
cd dist\Source
call git checkout %GITHUB_SHA%
call git submodule update --init --recursive
cd ../
del /S/Q "Source\.git\objects\pack\*"
call 7z a browser-source-%BUILD_NUMBER%.zip "Source\*"
- name: Upload opera release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.setup.outputs.release_upload_url }}
asset_name: dist-opera-${{ env.BUILD_NUMBER }}.zip
asset_path: dist/dist-opera-${{ env.BUILD_NUMBER }}.zip
asset_content_type: application
- name: upload chrome release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.setup.outputs.release_upload_url }}
asset_name: dist-chrome-${{ env.BUILD_NUMBER }}.zip
asset_path: dist/dist-chrome-${{ env.BUILD_NUMBER }}.zip
asset_content_type: application/zip
- name: upload firefox release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.setup.outputs.release_upload_url }}
asset_name: dist-firefox-${{ env.BUILD_NUMBER }}.zip
asset_path: dist/dist-firefox-${{ env.BUILD_NUMBER }}.zip
asset_content_type: application/zip
- name: upload edge release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.setup.outputs.release_upload_url }}
asset_name: dist-edge-${{ env.BUILD_NUMBER }}.zip
asset_path: dist/dist-edge-${{ env.BUILD_NUMBER }}.zip
asset_content_type: application/zip
- name: upload browser source zip release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.setup.outputs.release_upload_url }}
asset_name: browser-source-${{ env.BUILD_NUMBER }}.zip
asset_path: dist/browser-source-${{ env.BUILD_NUMBER }}.zip
asset_content_type: application/zip
- name: upload coverage release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.setup.outputs.release_upload_url }}
asset_name: coverage-${{ env.BUILD_NUMBER }}.zip
asset_path: coverage/coverage-${{ env.BUILD_NUMBER }}.zip
asset_content_type: application/zip