mirror of
https://github.com/bitwarden/browser
synced 2024-12-24 00:54:30 +01:00
7b21e380cb
* adding new build artifacts * fixing some version issues * fixing syntax error * fixing asset names * updating the release workflow to release the new build assets
406 lines
11 KiB
YAML
406 lines
11 KiB
YAML
---
|
|
name: Build
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
custom_tag_extension:
|
|
description: "Custom image tag extension"
|
|
required: false
|
|
push:
|
|
branches-ignore:
|
|
- 'l10n_master'
|
|
- 'gh-pages'
|
|
|
|
jobs:
|
|
cloc:
|
|
name: CLOC
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
|
|
|
- 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:
|
|
name: Setup
|
|
runs-on: ubuntu-20.04
|
|
outputs:
|
|
version: ${{ steps.version.outputs.value }}
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
|
|
|
- name: Get GitHub sha as version
|
|
id: version
|
|
run: |
|
|
echo "::set-output name=value::${GITHUB_SHA:0:7}"
|
|
|
|
|
|
build-oss-selfhost:
|
|
name: Build OSS zip
|
|
runs-on: ubuntu-20.04
|
|
needs: setup
|
|
env:
|
|
_VERSION: ${{ needs.setup.outputs.version }}
|
|
steps:
|
|
- name: Set up Node
|
|
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
|
|
with:
|
|
node-version: '14'
|
|
|
|
- name: Update NPM
|
|
run: |
|
|
npm install -g npm@7
|
|
|
|
- name: Cache npm
|
|
id: npm-cache
|
|
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
|
|
with:
|
|
path: '~/.npm'
|
|
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
- name: Print environment
|
|
run: |
|
|
whoami
|
|
node --version
|
|
npm --version
|
|
gulp --version
|
|
docker --version
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
echo "GitHub event: $GITHUB_EVENT"
|
|
|
|
- name: Checkout repo
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build OSS selfhost
|
|
run: |
|
|
npm run dist:oss:selfhost
|
|
zip -r web-$_VERSION-selfhosted-open-source.zip build
|
|
|
|
- name: Upload build artifact
|
|
uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700 # v2.2.3
|
|
with:
|
|
name: web-${{ env._VERSION }}-selfhosted-open-source.zip
|
|
path: ./web-${{ env._VERSION }}-selfhosted-open-source.zip
|
|
if-no-files-found: error
|
|
|
|
|
|
build-cloud:
|
|
name: Build Cloud zip
|
|
runs-on: ubuntu-20.04
|
|
needs: setup
|
|
env:
|
|
_VERSION: ${{ needs.setup.outputs.version }}
|
|
steps:
|
|
- name: Set up Node
|
|
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
|
|
with:
|
|
node-version: '14'
|
|
|
|
- name: Update NPM
|
|
run: |
|
|
npm install -g npm@7
|
|
|
|
- name: Cache npm
|
|
id: npm-cache
|
|
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
|
|
with:
|
|
path: '~/.npm'
|
|
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
- name: Print environment
|
|
run: |
|
|
whoami
|
|
node --version
|
|
npm --version
|
|
gulp --version
|
|
docker --version
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
echo "GitHub event: $GITHUB_EVENT"
|
|
|
|
- name: Checkout repo
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build Cloud
|
|
run: |
|
|
npm run dist:bit:cloud
|
|
zip -r web-$_VERSION-cloud-COMMERCIAL.zip build
|
|
|
|
- name: Upload build artifact
|
|
uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700 # v2.2.3
|
|
with:
|
|
name: web-${{ env._VERSION }}-cloud-COMMERCIAL.zip
|
|
path: ./web-${{ env._VERSION }}-cloud-COMMERCIAL.zip
|
|
if-no-files-found: error
|
|
|
|
|
|
build-commercial-selfhost:
|
|
name: Build SelfHost Docker image
|
|
runs-on: ubuntu-20.04
|
|
needs: setup
|
|
env:
|
|
_VERSION: ${{ needs.setup.outputs.version }}
|
|
steps:
|
|
- name: Set up Node
|
|
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
|
|
with:
|
|
node-version: '14'
|
|
|
|
- name: Update NPM
|
|
run: |
|
|
npm install -g npm@7
|
|
|
|
- name: Cache npm
|
|
id: npm-cache
|
|
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
|
|
with:
|
|
path: '~/.npm'
|
|
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
- name: Print environment
|
|
run: |
|
|
whoami
|
|
node --version
|
|
npm --version
|
|
gulp --version
|
|
docker --version
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
echo "GitHub event: $GITHUB_EVENT"
|
|
|
|
- name: Setup DCT
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
|
id: setup-dct
|
|
uses: bitwarden/gh-actions/setup-docker-trust@a8c384a05a974c05c48374c818b004be221d43ff
|
|
with:
|
|
azure-creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
|
|
azure-keyvault-name: "bitwarden-prod-kv"
|
|
|
|
- name: Checkout repo
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
|
|
|
- name: Restore
|
|
run: dotnet tool restore
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build
|
|
run: |
|
|
echo -e "# Building Web\n"
|
|
echo "Building app"
|
|
echo "npm version $(npm --version)"
|
|
|
|
npm run dist:bit:selfhost
|
|
zip -r web-$_VERSION-selfhosted-COMMERCIAL.zip build
|
|
|
|
- name: Upload build artifact
|
|
uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700 # v2.2.3
|
|
with:
|
|
name: web-${{ env._VERSION }}-selfhosted-COMMERCIAL.zip
|
|
path: ./web-${{ env._VERSION }}-selfhosted-COMMERCIAL.zip
|
|
if-no-files-found: error
|
|
|
|
- name: Build Docker image
|
|
run: |
|
|
echo -e "\nBuilding Docker image"
|
|
docker --version
|
|
docker build -t bitwarden/web .
|
|
|
|
- name: Tag rc branch
|
|
if: github.ref == 'refs/heads/rc'
|
|
run: docker tag bitwarden/web bitwarden/web:rc
|
|
|
|
- name: Tag dev
|
|
if: github.ref == 'refs/heads/master'
|
|
run: docker tag bitwarden/web bitwarden/web:dev
|
|
|
|
- name: List Docker images
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
|
run: docker images
|
|
|
|
- name: Push rc images
|
|
if: github.ref == 'refs/heads/rc'
|
|
run: docker push bitwarden/web:rc
|
|
env:
|
|
DOCKER_CONTENT_TRUST: 1
|
|
DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.setup-dct.outputs.dct-delegate-repo-passphrase }}
|
|
|
|
- name: Push dev images
|
|
if: github.ref == 'refs/heads/master'
|
|
run: docker push bitwarden/web:dev
|
|
env:
|
|
DOCKER_CONTENT_TRUST: 1
|
|
DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.setup-dct.outputs.dct-delegate-repo-passphrase }}
|
|
|
|
- name: Log out of Docker
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
|
run: docker logout
|
|
|
|
|
|
build-qa:
|
|
name: Build Docker images for QA environment
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- name: Set up Node
|
|
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
|
|
with:
|
|
node-version: '14'
|
|
|
|
- name: Update NPM
|
|
run: |
|
|
npm install -g npm@7
|
|
|
|
- name: Cache npm
|
|
id: npm-cache
|
|
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
|
|
with:
|
|
path: '~/.npm'
|
|
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
- name: Print environment
|
|
run: |
|
|
whoami
|
|
node --version
|
|
npm --version
|
|
gulp --version
|
|
docker --version
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
echo "GitHub event: $GITHUB_EVENT"
|
|
|
|
- name: Login to Azure
|
|
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
|
|
with:
|
|
creds: ${{ secrets.AZURE_QA_KV_CREDENTIALS }}
|
|
|
|
- name: Log into container registry
|
|
run: az acr login -n bitwardenqa
|
|
|
|
- name: Checkout repo
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
|
|
|
- name: Restore
|
|
run: dotnet tool restore
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build
|
|
run: |
|
|
echo -e "# Building Web\n"
|
|
echo "Building app"
|
|
echo "npm version $(npm --version)"
|
|
VERSION=$( jq -r ".version" package.json)
|
|
jq --arg version "$VERSION - ${GITHUB_SHA:0:7}" '.version = $version' package.json > package.json.tmp
|
|
mv package.json.tmp package.json
|
|
|
|
npm run build:bit:qa
|
|
|
|
echo "{\"commit_hash\": \"$GITHUB_SHA\", \"ref\": \"$GITHUB_REF\"}" | jq . > build/info.json
|
|
|
|
echo -e "\nBuilding Docker image"
|
|
docker --version
|
|
docker build -t bitwardenqa.azurecr.io/web .
|
|
|
|
- name: Get image tag
|
|
id: image-tag
|
|
run: |
|
|
IMAGE_TAG=$(echo "$GITHUB_REF" | awk '{split($0, a, "/"); print a[3];}')
|
|
TAG_EXTENSION=${{ github.event.inputs.custom_tag_extension }}
|
|
|
|
if [[ $TAG_EXTENSION ]]; then
|
|
IMAGE_TAG=$IMAGE_TAG-$TAG_EXTENSION
|
|
fi
|
|
echo "::set-output name=value::$IMAGE_TAG"
|
|
|
|
- name: Tag image
|
|
env:
|
|
IMAGE_TAG: ${{ steps.image-tag.outputs.value }}
|
|
run: docker tag bitwardenqa.azurecr.io/web "bitwardenqa.azurecr.io/web:$IMAGE_TAG"
|
|
|
|
- name: Tag dev
|
|
if: github.ref == 'refs/heads/master'
|
|
run: docker tag bitwardenqa.azurecr.io/web bitwardenqa.azurecr.io/web:dev
|
|
|
|
- name: List Docker images
|
|
run: docker images
|
|
|
|
- name: Push image
|
|
env:
|
|
IMAGE_TAG: ${{ steps.image-tag.outputs.value }}
|
|
run: docker push "bitwardenqa.azurecr.io/web:$IMAGE_TAG"
|
|
|
|
- name: Push dev images
|
|
if: github.ref == 'refs/heads/master'
|
|
run: docker push bitwardenqa.azurecr.io/web:dev
|
|
|
|
- name: Log out of Docker
|
|
run: docker logout
|
|
|
|
|
|
windows:
|
|
name: Test code on Windows
|
|
runs-on: windows-2019
|
|
steps:
|
|
- name: Set up NuGet
|
|
uses: nuget/setup-nuget@04b0c2b8d1b97922f67eca497d7cf0bf17b8ffe1
|
|
with:
|
|
nuget-version: 'latest'
|
|
|
|
- name: Set up MSBuild
|
|
uses: microsoft/setup-msbuild@c26a08ba26249b81327e26f6ef381897b6a8754d
|
|
|
|
- name: Cache npm
|
|
id: npm-cache
|
|
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
|
|
with:
|
|
path: '~/.npm'
|
|
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
- name: Set up Node
|
|
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
|
|
with:
|
|
node-version: '14'
|
|
|
|
- name: Update NPM
|
|
run: |
|
|
npm install -g npm@7
|
|
|
|
- name: Print environment
|
|
run: |
|
|
nuget help | grep Version
|
|
msbuild -version
|
|
dotnet --info
|
|
node --version
|
|
npm --version
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
echo "GitHub event: $GITHUB_EVENT"
|
|
env:
|
|
GITHUB_REF: ${{ github.ref }}
|
|
GITHUB_EVENT: ${{ github.event_name }}
|
|
|
|
- name: Checkout repo
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: NPM install
|
|
run: npm ci
|
|
|
|
- name: NPM build
|
|
run: npm run build:bit:cloud
|