2021-09-02 22:05:17 +02:00
|
|
|
---
|
2022-06-03 16:35:46 +02:00
|
|
|
name: Release Web
|
2021-06-02 17:28:56 +02:00
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
2021-12-20 18:15:43 +01:00
|
|
|
inputs:
|
|
|
|
release_type:
|
|
|
|
description: 'Release Options'
|
|
|
|
required: true
|
|
|
|
default: 'Initial Release'
|
|
|
|
type: choice
|
|
|
|
options:
|
|
|
|
- Initial Release
|
|
|
|
- Redeploy
|
2022-02-25 15:07:54 +01:00
|
|
|
- Dry Run
|
2021-06-02 17:28:56 +02:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
setup:
|
2021-09-02 22:05:17 +02:00
|
|
|
name: Setup
|
2021-09-21 18:37:17 +02:00
|
|
|
runs-on: ubuntu-20.04
|
2021-06-02 17:28:56 +02:00
|
|
|
outputs:
|
2022-06-01 03:08:32 +02:00
|
|
|
release_version: ${{ steps.version.outputs.version }}
|
2022-06-03 16:35:46 +02:00
|
|
|
tag_version: ${{ steps.version.outputs.tag }}
|
2021-06-02 17:28:56 +02:00
|
|
|
steps:
|
2022-06-30 19:26:35 +02:00
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
|
|
|
|
|
2021-06-02 17:28:56 +02:00
|
|
|
- name: Branch check
|
2022-02-25 15:07:54 +01:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
2021-06-02 17:28:56 +02:00
|
|
|
run: |
|
2022-07-26 22:43:29 +02:00
|
|
|
if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ $GITHUB_REF != "refs/heads/hotfix-rc" ]]; then
|
2021-06-02 17:28:56 +02:00
|
|
|
echo "==================================="
|
2022-07-26 22:43:29 +02:00
|
|
|
echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches"
|
2021-06-02 17:28:56 +02:00
|
|
|
echo "==================================="
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-09-21 18:37:17 +02:00
|
|
|
- name: Check Release Version
|
|
|
|
id: version
|
2022-06-03 16:35:46 +02:00
|
|
|
uses: bitwarden/gh-actions/release-version-check@8f055ef543c7433c967a1b9b04a0f230923233bb
|
2022-06-01 01:11:26 +02:00
|
|
|
with:
|
|
|
|
release-type: ${{ github.event.inputs.release_type }}
|
|
|
|
project-type: ts
|
2022-06-03 16:35:46 +02:00
|
|
|
file: apps/web/package.json
|
|
|
|
monorepo: true
|
|
|
|
monorepo-project: web
|
2021-09-21 18:37:17 +02:00
|
|
|
|
2022-03-03 20:00:41 +01:00
|
|
|
|
2021-09-21 18:37:17 +02:00
|
|
|
self-host:
|
2021-10-21 19:31:41 +02:00
|
|
|
name: Release self-host docker
|
2021-09-21 18:37:17 +02:00
|
|
|
runs-on: ubuntu-20.04
|
2021-06-02 18:28:51 +02:00
|
|
|
needs: setup
|
|
|
|
env:
|
2022-06-22 14:32:45 +02:00
|
|
|
_BRANCH_NAME: ${{ github.ref_name }}
|
2021-09-02 22:05:17 +02:00
|
|
|
_RELEASE_VERSION: ${{ needs.setup.outputs.release_version }}
|
2022-02-25 15:07:54 +01:00
|
|
|
_RELEASE_OPTION: ${{ github.event.inputs.release_type }}
|
2021-06-02 17:28:56 +02:00
|
|
|
steps:
|
|
|
|
- name: Print environment
|
|
|
|
run: |
|
|
|
|
whoami
|
|
|
|
docker --version
|
|
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
|
|
echo "GitHub event: $GITHUB_EVENT"
|
2022-02-25 15:07:54 +01:00
|
|
|
echo "Github Release Option: $_RELEASE_OPTION"
|
2021-06-02 17:28:56 +02:00
|
|
|
|
2022-03-03 20:00:41 +01:00
|
|
|
- name: Checkout repo
|
2022-06-03 16:35:46 +02:00
|
|
|
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
|
2022-03-03 20:00:41 +01:00
|
|
|
|
|
|
|
########## DockerHub ##########
|
2021-09-21 18:37:17 +02:00
|
|
|
- name: Setup DCT
|
|
|
|
id: setup-dct
|
|
|
|
uses: bitwarden/gh-actions/setup-docker-trust@a8c384a05a974c05c48374c818b004be221d43ff
|
2021-06-02 17:28:56 +02:00
|
|
|
with:
|
2021-09-21 18:37:17 +02:00
|
|
|
azure-creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
|
|
|
|
azure-keyvault-name: "bitwarden-prod-kv"
|
2021-06-02 17:28:56 +02:00
|
|
|
|
2021-12-16 17:46:26 +01:00
|
|
|
- name: Pull latest selfhost image
|
2022-02-25 15:07:54 +01:00
|
|
|
run: |
|
|
|
|
if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then
|
|
|
|
docker pull bitwarden/web:latest
|
|
|
|
else
|
|
|
|
docker pull bitwarden/web:$_BRANCH_NAME
|
|
|
|
fi
|
2021-06-02 17:28:56 +02:00
|
|
|
|
2022-06-03 16:35:46 +02:00
|
|
|
- name: Docker Tag version and latest image
|
2021-06-02 17:28:56 +02:00
|
|
|
run: |
|
2022-06-22 14:32:45 +02:00
|
|
|
if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then
|
|
|
|
docker tag bitwarden/web:latest bitwarden/web:$_RELEASE_VERSION
|
|
|
|
else
|
|
|
|
docker tag bitwarden/web:$_BRANCH_NAME bitwarden/web:$_RELEASE_VERSION
|
|
|
|
fi
|
2021-06-02 17:28:56 +02:00
|
|
|
|
2022-06-03 16:35:46 +02:00
|
|
|
- name: Docker Push version and latest image
|
2022-02-25 15:07:54 +01:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
2021-06-02 17:28:56 +02:00
|
|
|
env:
|
2021-09-21 18:37:17 +02:00
|
|
|
DOCKER_CONTENT_TRUST: 1
|
|
|
|
DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.setup-dct.outputs.dct-delegate-repo-passphrase }}
|
2021-12-16 17:46:26 +01:00
|
|
|
run: |
|
|
|
|
docker push bitwarden/web:$_RELEASE_VERSION
|
2021-06-02 17:28:56 +02:00
|
|
|
|
2022-03-03 20:00:41 +01:00
|
|
|
- name: Log out of Docker and disable Docker Notary
|
|
|
|
run: |
|
|
|
|
docker logout
|
|
|
|
echo "DOCKER_CONTENT_TRUST=0" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
########## ACR ##########
|
|
|
|
- name: Login to Azure - QA Subscription
|
2022-06-03 16:35:46 +02:00
|
|
|
uses: Azure/login@ec3c14589bd3e9312b3cc8c41e6860e258df9010 # v1.1
|
2022-03-03 20:00:41 +01:00
|
|
|
with:
|
|
|
|
creds: ${{ secrets.AZURE_QA_KV_CREDENTIALS }}
|
|
|
|
|
|
|
|
- name: Login to Azure ACR
|
|
|
|
run: az acr login -n bitwardenqa
|
|
|
|
|
|
|
|
- name: Tag version and latest
|
|
|
|
env:
|
|
|
|
REGISTRY: bitwardenqa.azurecr.io
|
|
|
|
run: |
|
2022-06-22 14:32:45 +02:00
|
|
|
if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then
|
|
|
|
docker tag bitwarden/web:latest $REGISTRY/web:$_RELEASE_VERSION
|
|
|
|
|
|
|
|
docker tag bitwarden/web:latest $REGISTRY/web-sh:$_RELEASE_VERSION
|
|
|
|
else
|
|
|
|
docker tag bitwarden/web:$_BRANCH_NAME $REGISTRY/web:$_RELEASE_VERSION
|
2022-03-30 23:21:00 +02:00
|
|
|
|
2022-06-22 14:32:45 +02:00
|
|
|
docker tag bitwarden/web:$_BRANCH_NAME $REGISTRY/web-sh:$_RELEASE_VERSION
|
|
|
|
fi
|
2022-03-03 20:00:41 +01:00
|
|
|
|
|
|
|
- name: Push version and latest image
|
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
|
|
|
env:
|
|
|
|
REGISTRY: bitwardenqa.azurecr.io
|
|
|
|
run: |
|
|
|
|
docker push $REGISTRY/web:$_RELEASE_VERSION
|
|
|
|
|
2022-03-30 23:21:00 +02:00
|
|
|
docker push $REGISTRY/web-sh:$_RELEASE_VERSION
|
|
|
|
|
2021-09-21 18:37:17 +02:00
|
|
|
- name: Log out of Docker
|
|
|
|
run: docker logout
|
2021-06-02 17:28:56 +02:00
|
|
|
|
2022-03-03 20:00:41 +01:00
|
|
|
|
2022-05-03 18:21:27 +02:00
|
|
|
cfpages-deploy:
|
|
|
|
name: Deploy Web Vault to CloudFlare Pages branch
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
needs:
|
|
|
|
- setup
|
|
|
|
- self-host
|
|
|
|
env:
|
|
|
|
_RELEASE_VERSION: ${{ needs.setup.outputs.release_version }}
|
|
|
|
_TAG_VERSION: ${{ needs.setup.outputs.tag_version }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout Repo
|
2022-06-03 16:35:46 +02:00
|
|
|
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
|
2022-05-03 18:21:27 +02:00
|
|
|
|
|
|
|
- name: Download latest cloud asset
|
2022-07-19 21:01:14 +02:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
2022-05-03 18:21:27 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@c1fa8e09871a860862d6bbe36184b06d2c7e35a8
|
|
|
|
with:
|
2022-06-03 16:35:46 +02:00
|
|
|
workflow: build-web.yml
|
|
|
|
path: apps/web
|
2022-05-03 18:21:27 +02:00
|
|
|
workflow_conclusion: success
|
2022-06-22 14:32:45 +02:00
|
|
|
branch: ${{ github.ref_name }}
|
2022-05-03 18:21:27 +02:00
|
|
|
artifacts: web-*-cloud-COMMERCIAL.zip
|
|
|
|
|
2022-07-19 21:01:14 +02:00
|
|
|
- name: Download latest cloud asset
|
|
|
|
if: ${{ github.event.inputs.release_type == 'Dry Run' }}
|
|
|
|
uses: bitwarden/gh-actions/download-artifacts@c1fa8e09871a860862d6bbe36184b06d2c7e35a8
|
|
|
|
with:
|
|
|
|
workflow: build-web.yml
|
|
|
|
path: apps/web
|
|
|
|
workflow_conclusion: success
|
|
|
|
branch: master
|
|
|
|
artifacts: web-*-cloud-COMMERCIAL.zip
|
|
|
|
|
2022-05-03 18:21:27 +02:00
|
|
|
# This should result in a build directory in the current working directory
|
|
|
|
- name: Unzip build asset
|
2022-06-03 16:35:46 +02:00
|
|
|
working-directory: apps/web
|
2022-05-03 18:21:27 +02:00
|
|
|
run: unzip web-*-cloud-COMMERCIAL.zip
|
|
|
|
|
|
|
|
- name: Checkout Repo
|
2022-06-03 16:35:46 +02:00
|
|
|
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
|
2022-05-03 18:21:27 +02:00
|
|
|
with:
|
2022-06-20 21:16:51 +02:00
|
|
|
ref: cf-pages
|
2022-05-03 18:21:27 +02:00
|
|
|
path: deployment
|
|
|
|
|
|
|
|
- name: Setup git config
|
|
|
|
run: |
|
|
|
|
git config --global user.name = "GitHub Action Bot"
|
|
|
|
git config --global user.email = "<>"
|
|
|
|
git config --global url."https://github.com/".insteadOf ssh://git@github.com/
|
|
|
|
git config --global url."https://".insteadOf ssh://
|
|
|
|
|
|
|
|
- name: Deploy CloudFlare Pages
|
|
|
|
run: |
|
|
|
|
rm -rf ./*
|
2022-06-22 14:32:45 +02:00
|
|
|
cp -R ../apps/web/build/* .
|
2022-05-03 18:21:27 +02:00
|
|
|
working-directory: deployment
|
|
|
|
|
|
|
|
- name: Create cf-pages-deploy branch
|
|
|
|
run: |
|
|
|
|
git switch -c cf-pages-deploy-$_TAG_VERSION
|
|
|
|
git add .
|
|
|
|
git commit -m "Staging deploy ${{ needs.setup.outputs.release_version }}"
|
2022-07-19 21:01:14 +02:00
|
|
|
|
|
|
|
if [[ "${{ github.event.inputs.release_type }}" != "Dry Run" ]]; then
|
|
|
|
git push -u origin cf-pages-deploy-$_TAG_VERSION
|
|
|
|
fi
|
2022-06-03 16:35:46 +02:00
|
|
|
working-directory: deployment
|
2022-05-03 18:21:27 +02:00
|
|
|
|
|
|
|
- name: Create CloudFlare Pages Deploy PR
|
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
|
|
|
env:
|
|
|
|
PR_BRANCH: cf-pages-deploy-${{ env._TAG_VERSION }}
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
run: |
|
|
|
|
gh pr create --title "Deploy $_RELEASE_VERSION to CloudFlare Pages" \
|
|
|
|
--body "Deploying $_RELEASE_VERSION" \
|
2022-06-20 21:16:51 +02:00
|
|
|
--base cf-pages \
|
2022-05-03 18:21:27 +02:00
|
|
|
--head "$PR_BRANCH"
|
|
|
|
|
|
|
|
|
2021-09-21 18:37:17 +02:00
|
|
|
release:
|
|
|
|
name: Create GitHub Release
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
needs:
|
|
|
|
- setup
|
|
|
|
- self-host
|
2022-05-03 18:21:27 +02:00
|
|
|
- cfpages-deploy
|
2021-09-21 18:37:17 +02:00
|
|
|
steps:
|
2022-07-25 23:20:17 +02:00
|
|
|
- name: Create GitHub deployment
|
|
|
|
uses: chrnorm/deployment-action@1b599fe41a0ef1f95191e7f2eec4743f2d7dfc48
|
|
|
|
id: deployment
|
|
|
|
with:
|
|
|
|
token: '${{ secrets.GITHUB_TOKEN }}'
|
|
|
|
environment-url: http://vault.bitwarden.com
|
|
|
|
environment: 'Web Vault - Production'
|
|
|
|
description: 'Deployment ${{ needs.setup.outputs.release_version }} from branch ${{ github.ref_name }}'
|
|
|
|
task: release
|
|
|
|
|
|
|
|
- name: Update deployment status to In Progress
|
|
|
|
uses: chrnorm/deployment-status@07b3930847f65e71c9c6802ff5a402f6dfb46b86
|
|
|
|
with:
|
|
|
|
token: '${{ secrets.GITHUB_TOKEN }}'
|
|
|
|
environment-url: http://vault.bitwarden.com
|
|
|
|
state: 'in_progress'
|
|
|
|
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
|
|
|
|
|
2021-10-08 18:54:42 +02:00
|
|
|
- name: Download latest build artifacts
|
2022-07-01 17:44:20 +02:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
2022-06-03 16:35:46 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@c1fa8e09871a860862d6bbe36184b06d2c7e35a8
|
2021-09-21 18:37:17 +02:00
|
|
|
with:
|
2022-06-03 16:35:46 +02:00
|
|
|
workflow: build-web.yml
|
|
|
|
path: apps/web/artifacts
|
2021-09-21 18:37:17 +02:00
|
|
|
workflow_conclusion: success
|
2022-06-22 14:32:45 +02:00
|
|
|
branch: ${{ github.ref_name }}
|
2021-10-08 18:54:42 +02:00
|
|
|
artifacts: "web-*-selfhosted-COMMERCIAL.zip,
|
2021-12-17 15:57:11 +01:00
|
|
|
web-*-selfhosted-open-source.zip"
|
2021-10-08 18:54:42 +02:00
|
|
|
|
2022-07-01 17:44:20 +02:00
|
|
|
- name: Download latest build artifacts
|
|
|
|
if: ${{ github.event.inputs.release_type == 'Dry Run' }}
|
|
|
|
uses: bitwarden/gh-actions/download-artifacts@c1fa8e09871a860862d6bbe36184b06d2c7e35a8
|
|
|
|
with:
|
|
|
|
workflow: build-web.yml
|
|
|
|
path: apps/web/artifacts
|
|
|
|
workflow_conclusion: success
|
|
|
|
branch: master
|
|
|
|
artifacts: "web-*-selfhosted-COMMERCIAL.zip,
|
|
|
|
web-*-selfhosted-open-source.zip"
|
|
|
|
|
2021-10-08 18:54:42 +02:00
|
|
|
- name: Rename assets
|
2022-06-03 16:35:46 +02:00
|
|
|
working-directory: apps/web/artifacts
|
2021-10-08 18:54:42 +02:00
|
|
|
run: |
|
|
|
|
mv web-*-selfhosted-COMMERCIAL.zip web-${{ needs.setup.outputs.release_version }}-selfhosted-COMMERCIAL.zip
|
|
|
|
mv web-*-selfhosted-open-source.zip web-${{ needs.setup.outputs.release_version }}-selfhosted-open-source.zip
|
2021-06-02 17:28:56 +02:00
|
|
|
|
2021-09-21 18:37:17 +02:00
|
|
|
- name: Create release
|
2022-02-25 15:07:54 +01:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
2022-06-03 16:35:46 +02:00
|
|
|
uses: ncipollo/release-action@58ae73b360456532aafd58ee170c045abbeaee37 # v1.10.0
|
2021-09-21 18:37:17 +02:00
|
|
|
with:
|
2022-06-03 16:35:46 +02:00
|
|
|
name: "Version v${{ needs.setup.outputs.release_version }}"
|
2021-09-21 18:37:17 +02:00
|
|
|
commit: ${{ github.sha }}
|
2022-06-27 20:44:50 +02:00
|
|
|
tag: web-v${{ needs.setup.outputs.tag_version }}
|
2021-09-21 18:37:17 +02:00
|
|
|
body: "<insert release notes here>"
|
2022-06-03 16:35:46 +02:00
|
|
|
artifacts: "apps/web/artifacts/web-${{ needs.setup.outputs.release_version }}-selfhosted-COMMERCIAL.zip,
|
|
|
|
apps/web/artifacts/web-${{ needs.setup.outputs.release_version }}-selfhosted-open-source.zip"
|
2021-09-21 18:37:17 +02:00
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
2021-10-27 22:08:37 +02:00
|
|
|
draft: true
|
2022-07-25 23:20:17 +02:00
|
|
|
|
|
|
|
- name: Update deployment status to Success
|
|
|
|
if: success()
|
|
|
|
uses: chrnorm/deployment-status@07b3930847f65e71c9c6802ff5a402f6dfb46b86
|
|
|
|
with:
|
|
|
|
token: '${{ secrets.GITHUB_TOKEN }}'
|
|
|
|
environment-url: http://vault.bitwarden.com
|
|
|
|
state: 'success'
|
|
|
|
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
|
|
|
|
|
|
|
|
- name: Update deployment status to Failure
|
|
|
|
if: failure()
|
|
|
|
uses: chrnorm/deployment-status@07b3930847f65e71c9c6802ff5a402f6dfb46b86
|
|
|
|
with:
|
|
|
|
token: '${{ secrets.GITHUB_TOKEN }}'
|
|
|
|
environment-url: http://vault.bitwarden.com
|
|
|
|
state: 'failure'
|
|
|
|
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
|