2020-12-21 18:46:36 +01:00
|
|
|
name: build
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches-ignore:
|
|
|
|
- 'l10n_master'
|
|
|
|
- 'gh-pages'
|
|
|
|
release:
|
|
|
|
types:
|
|
|
|
- published
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
ubuntu:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Set up Node
|
|
|
|
uses: actions/setup-node@v1
|
|
|
|
with:
|
2021-05-14 20:08:03 +02:00
|
|
|
node-version: '14.x'
|
2020-12-21 18:46:36 +01:00
|
|
|
|
|
|
|
- name: Print environment
|
|
|
|
run: |
|
|
|
|
whoami
|
|
|
|
node --version
|
|
|
|
npm --version
|
|
|
|
gulp --version
|
|
|
|
docker --version
|
|
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
|
|
echo "GitHub event: $GITHUB_EVENT"
|
|
|
|
env:
|
|
|
|
GITHUB_REF: ${{ github.ref }}
|
|
|
|
GITHUB_EVENT: ${{ github.event_name }}
|
|
|
|
|
2021-05-11 21:02:31 +02:00
|
|
|
- name: Login to Azure
|
|
|
|
if: github.ref == 'refs/heads/master' || github.event_name == 'release' || github.ref == 'refs/heads/rc'
|
|
|
|
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
|
|
|
|
with:
|
|
|
|
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
|
|
|
|
|
|
|
|
- name: Retrieve secrets
|
|
|
|
if: github.ref == 'refs/heads/master' || github.event_name == 'release' || github.ref == 'refs/heads/rc'
|
|
|
|
id: retrieve-secrets
|
|
|
|
uses: Azure/get-keyvault-secrets@80ccd3fafe5662407cc2e55f202ee34bfff8c403
|
|
|
|
with:
|
|
|
|
keyvault: "bitwarden-prod-kv"
|
|
|
|
secrets: "docker-password,
|
|
|
|
docker-username,
|
|
|
|
dct-delegate-2-repo-passphrase,
|
|
|
|
dct-delegate-2-key"
|
|
|
|
|
2020-12-21 18:46:36 +01:00
|
|
|
- name: Log into docker
|
2021-03-04 22:28:32 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || github.event_name == 'release' || github.ref == 'refs/heads/rc'
|
2021-05-11 21:02:31 +02:00
|
|
|
run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
2020-12-21 18:46:36 +01:00
|
|
|
env:
|
2021-05-11 21:02:31 +02:00
|
|
|
DOCKER_USERNAME: ${{ steps.retrieve-secrets.outputs.docker-username }}
|
|
|
|
DOCKER_PASSWORD: ${{ steps.retrieve-secrets.outputs.docker-password }}
|
2020-12-21 18:46:36 +01:00
|
|
|
|
|
|
|
- name: Setup Docker Trust
|
2021-03-04 22:28:32 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || github.event_name == 'release' || github.ref == 'refs/heads/rc'
|
2020-12-21 18:46:36 +01:00
|
|
|
run: |
|
|
|
|
mkdir -p ~/.docker/trust/private
|
|
|
|
|
2021-05-11 21:02:31 +02:00
|
|
|
echo "$DCT_DELEGATE_KEY" > ~/.docker/trust/private/$DCT_DELEGATION_KEY_ID.key
|
2020-12-21 18:46:36 +01:00
|
|
|
env:
|
2021-05-11 21:02:31 +02:00
|
|
|
DCT_DELEGATION_KEY_ID: "c9bde8ec820701516491e5e03d3a6354e7bd66d05fa3df2b0062f68b116dc59c"
|
|
|
|
DCT_DELEGATE_KEY: ${{ steps.retrieve-secrets.outputs.dct-delegate-2-key }}
|
2020-12-21 18:46:36 +01:00
|
|
|
|
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Restore
|
|
|
|
run: dotnet tool restore
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
run: |
|
2021-04-20 22:27:09 +02:00
|
|
|
echo -e "# Building Web\n"
|
|
|
|
echo "Building app"
|
|
|
|
echo "npm version $(npm --version)"
|
|
|
|
npm install
|
|
|
|
npm run dist:selfhost
|
|
|
|
|
|
|
|
echo -e "\nBuilding docker image"
|
|
|
|
docker --version
|
|
|
|
docker build -t bitwarden/web .
|
2020-12-21 18:46:36 +01:00
|
|
|
|
2021-03-04 19:07:59 +01:00
|
|
|
- name: Tag rc branch
|
|
|
|
if: github.ref == 'refs/heads/rc'
|
2021-04-20 22:27:09 +02:00
|
|
|
run: docker tag bitwarden/web bitwarden/web:rc
|
2021-03-04 19:07:59 +01:00
|
|
|
|
2020-12-21 18:46:36 +01:00
|
|
|
- name: Tag dev
|
|
|
|
if: github.ref == 'refs/heads/master' || github.event_name == 'release'
|
2021-04-20 22:27:09 +02:00
|
|
|
run: docker tag bitwarden/web bitwarden/web:dev
|
2020-12-21 18:46:36 +01:00
|
|
|
|
|
|
|
- name: Tag beta
|
|
|
|
if: github.event_name == 'release'
|
2021-04-20 22:27:09 +02:00
|
|
|
run: docker tag bitwarden/web bitwarden/web:beta
|
2020-12-21 18:46:36 +01:00
|
|
|
|
|
|
|
- name: Tag version
|
|
|
|
if: github.event_name == 'release'
|
2021-05-12 23:24:18 +02:00
|
|
|
run: docker tag bitwarden/web bitwarden/web:$($env:RELEASE_TAG_NAME.trimStart('v'))
|
2020-12-21 18:46:36 +01:00
|
|
|
shell: pwsh
|
|
|
|
env:
|
|
|
|
RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
|
|
|
|
|
|
|
|
- name: List docker images
|
2021-03-04 22:28:32 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || github.event_name == 'release' || github.ref == 'refs/heads/rc'
|
2020-12-21 18:46:36 +01:00
|
|
|
run: docker images
|
|
|
|
|
2021-03-04 19:07:59 +01:00
|
|
|
- name: Push rc images
|
|
|
|
if: github.ref == 'refs/heads/rc'
|
2021-04-20 22:27:09 +02:00
|
|
|
run: docker push bitwarden/web:rc
|
2021-03-04 19:07:59 +01:00
|
|
|
env:
|
|
|
|
DOCKER_CONTENT_TRUST: 1
|
2021-05-11 21:46:14 +02:00
|
|
|
DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.retrieve-secrets.outputs.dct-delegate-2-repo-passphrase }}
|
2021-03-04 19:07:59 +01:00
|
|
|
|
2020-12-21 18:46:36 +01:00
|
|
|
- name: Push dev images
|
|
|
|
if: github.ref == 'refs/heads/master' || github.event_name == 'release'
|
2021-04-20 22:27:09 +02:00
|
|
|
run: docker push bitwarden/web:dev
|
2020-12-21 18:46:36 +01:00
|
|
|
env:
|
|
|
|
DOCKER_CONTENT_TRUST: 1
|
2021-05-11 21:46:14 +02:00
|
|
|
DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.retrieve-secrets.outputs.dct-delegate-2-repo-passphrase }}
|
2020-12-21 18:46:36 +01:00
|
|
|
|
|
|
|
- name: Push beta images
|
|
|
|
if: github.event_name == 'release'
|
2021-04-20 22:27:09 +02:00
|
|
|
run: docker push bitwarden/web:beta
|
2020-12-21 18:46:36 +01:00
|
|
|
env:
|
|
|
|
DOCKER_CONTENT_TRUST: 1
|
2021-05-11 21:46:14 +02:00
|
|
|
DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.retrieve-secrets.outputs.dct-delegate-2-repo-passphrase }}
|
2020-12-21 18:46:36 +01:00
|
|
|
|
|
|
|
- name: Push latest images
|
|
|
|
if: github.event_name == 'release'
|
2021-04-20 22:27:09 +02:00
|
|
|
run: docker push bitwarden/web:latest
|
2020-12-21 18:46:36 +01:00
|
|
|
env:
|
|
|
|
DOCKER_CONTENT_TRUST: 1
|
2021-05-11 21:46:14 +02:00
|
|
|
DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.retrieve-secrets.outputs.dct-delegate-2-repo-passphrase }}
|
2020-12-21 18:46:36 +01:00
|
|
|
|
|
|
|
- name: Push version images
|
|
|
|
if: github.event_name == 'release'
|
2021-04-20 22:27:09 +02:00
|
|
|
run: docker push bitwarden/web:$($env:RELEASE_TAG_NAME.trimStart('v'))
|
2020-12-21 18:46:36 +01:00
|
|
|
shell: pwsh
|
|
|
|
env:
|
|
|
|
RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
|
|
|
|
DOCKER_CONTENT_TRUST: 1
|
2021-05-11 21:46:14 +02:00
|
|
|
DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.retrieve-secrets.outputs.dct-delegate-2-repo-passphrase }}
|
2020-12-21 18:46:36 +01:00
|
|
|
|
|
|
|
- name: Log out of docker
|
2021-03-04 22:28:32 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || github.event_name == 'release' || github.ref == 'refs/heads/rc'
|
2020-12-21 18:46:36 +01:00
|
|
|
run: docker logout
|
|
|
|
|
|
|
|
windows:
|
|
|
|
runs-on: windows-latest
|
|
|
|
steps:
|
|
|
|
- name: Set up NuGet
|
|
|
|
uses: nuget/setup-nuget@v1
|
|
|
|
with:
|
|
|
|
nuget-version: 'latest'
|
|
|
|
|
|
|
|
- name: Set up MSBuild
|
|
|
|
uses: microsoft/setup-msbuild@v1
|
|
|
|
|
|
|
|
- name: Set up Node
|
|
|
|
uses: actions/setup-node@v1
|
|
|
|
with:
|
2021-05-14 20:08:03 +02:00
|
|
|
node-version: '14.x'
|
2020-12-21 18:46:36 +01:00
|
|
|
|
|
|
|
- name: Print environment
|
|
|
|
run: |
|
|
|
|
nuget help
|
|
|
|
msbuild -version
|
|
|
|
dotnet --info
|
|
|
|
node --version
|
|
|
|
npm --version
|
|
|
|
Write-Output "GitHub ref: $env:GITHUB_REF"
|
|
|
|
Write-Output "GitHub event: $env:GITHUB_EVENT"
|
|
|
|
shell: pwsh
|
|
|
|
env:
|
|
|
|
GITHUB_REF: ${{ github.ref }}
|
|
|
|
GITHUB_EVENT: ${{ github.event_name }}
|
|
|
|
|
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: npm install
|
|
|
|
run: npm install
|
|
|
|
|
|
|
|
- name: npm build
|
|
|
|
run: npm run build:prod
|
|
|
|
|