2021-09-02 22:05:17 +02:00
|
|
|
---
|
2022-06-03 16:35:46 +02:00
|
|
|
name: Release Web
|
2022-11-08 16:02:51 +01:00
|
|
|
run-name: Release Web ${{ inputs.release_type }}
|
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
|
|
|
|
2023-08-16 17:41:02 +02:00
|
|
|
env:
|
|
|
|
_AZ_REGISTRY: bitwardenprod.azurecr.io
|
|
|
|
|
2021-06-02 17:28:56 +02:00
|
|
|
jobs:
|
|
|
|
setup:
|
2021-09-02 22:05:17 +02:00
|
|
|
name: Setup
|
2023-08-16 06:37:41 +02:00
|
|
|
runs-on: ubuntu-22.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
|
2023-06-29 16:46:56 +02:00
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2022-06-30 19:26:35 +02:00
|
|
|
|
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-11-16 16:48:49 +01:00
|
|
|
if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc-web" ]]; then
|
2021-06-02 17:28:56 +02:00
|
|
|
echo "==================================="
|
2022-08-16 17:55:57 +02:00
|
|
|
echo "[!] Can only release from the 'rc' or 'hotfix-rc-web' 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
|
2023-08-25 22:27:30 +02:00
|
|
|
uses: bitwarden/gh-actions/release-version-check@67ab95d7a466bcefdedf3f93cbc10bcff436edfe
|
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
|
|
|
|
|
|
|
self-host:
|
2021-10-21 19:31:41 +02:00
|
|
|
name: Release self-host docker
|
2023-08-16 06:37:41 +02:00
|
|
|
runs-on: ubuntu-22.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
|
2023-06-29 16:46:56 +02:00
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2022-03-03 20:00:41 +01:00
|
|
|
|
|
|
|
########## ACR ##########
|
2023-02-15 16:32:00 +01:00
|
|
|
- name: Login to Azure - PROD Subscription
|
2023-05-09 18:38:11 +02:00
|
|
|
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
|
2022-03-03 20:00:41 +01:00
|
|
|
with:
|
2023-02-14 20:39:17 +01:00
|
|
|
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
|
2022-03-03 20:00:41 +01:00
|
|
|
|
|
|
|
- name: Login to Azure ACR
|
2023-02-14 20:39:17 +01:00
|
|
|
run: az acr login -n bitwardenprod
|
2022-03-03 20:00:41 +01:00
|
|
|
|
2023-08-16 17:41:02 +02:00
|
|
|
- name: Pull branch image
|
2022-03-03 20:00:41 +01:00
|
|
|
run: |
|
2022-06-22 14:32:45 +02:00
|
|
|
if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then
|
2023-08-16 17:41:02 +02:00
|
|
|
docker pull $_AZ_REGISTRY/web:latest
|
2022-06-22 14:32:45 +02:00
|
|
|
else
|
2023-08-16 17:41:02 +02:00
|
|
|
docker pull $_AZ_REGISTRY/web:$_BRANCH_NAME
|
|
|
|
fi
|
2022-03-30 23:21:00 +02:00
|
|
|
|
2023-08-16 17:41:02 +02:00
|
|
|
- name: Tag version
|
|
|
|
run: |
|
|
|
|
if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then
|
|
|
|
docker tag $_AZ_REGISTRY/web:latest $_AZ_REGISTRY/web:dryrun
|
|
|
|
docker tag $_AZ_REGISTRY/web:latest $_AZ_REGISTRY/web-sh:dryrun
|
|
|
|
else
|
|
|
|
docker tag $_AZ_REGISTRY/web:$_BRANCH_NAME $_AZ_REGISTRY/web:$_RELEASE_VERSION
|
|
|
|
docker tag $_AZ_REGISTRY/web:$_BRANCH_NAME $_AZ_REGISTRY/web-sh:$_RELEASE_VERSION
|
|
|
|
docker tag $_AZ_REGISTRY/web:$_BRANCH_NAME $_AZ_REGISTRY/web:latest
|
|
|
|
docker tag $_AZ_REGISTRY/web:$_BRANCH_NAME $_AZ_REGISTRY/web-sh:latest
|
2022-06-22 14:32:45 +02:00
|
|
|
fi
|
2022-03-03 20:00:41 +01:00
|
|
|
|
2022-09-08 17:11:47 +02:00
|
|
|
- name: Push version
|
2022-03-03 20:00:41 +01:00
|
|
|
run: |
|
2023-08-16 17:41:02 +02:00
|
|
|
if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then
|
|
|
|
docker push $_AZ_REGISTRY/web:dryrun
|
|
|
|
docker push $_AZ_REGISTRY/web-sh:dryrun
|
|
|
|
else
|
|
|
|
docker push $_AZ_REGISTRY/web:$_RELEASE_VERSION
|
|
|
|
docker push $_AZ_REGISTRY/web-sh:$_RELEASE_VERSION
|
|
|
|
docker push $_AZ_REGISTRY/web:latest
|
|
|
|
docker push $_AZ_REGISTRY/web-sh:latest
|
|
|
|
fi
|
2022-03-30 23:21:00 +02:00
|
|
|
|
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
|
|
|
|
2023-05-08 17:20:44 +02:00
|
|
|
ghpages-deploy:
|
2023-08-16 06:37:41 +02:00
|
|
|
name: Create Deploy PR for GitHub Pages
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
needs: setup
|
2022-05-03 18:21:27 +02:00
|
|
|
env:
|
|
|
|
_RELEASE_VERSION: ${{ needs.setup.outputs.release_version }}
|
2023-05-08 17:20:44 +02:00
|
|
|
_TAG_VERSION: ${{ needs.setup.outputs.tag_version }}
|
|
|
|
_BRANCH: "v${{ needs.setup.outputs.release_version }}-deploy"
|
2022-05-03 18:21:27 +02:00
|
|
|
steps:
|
2023-05-08 17:20:44 +02:00
|
|
|
- name: Login to Azure - CI Subscription
|
2023-05-09 18:38:11 +02:00
|
|
|
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
|
2023-05-08 17:20:44 +02:00
|
|
|
with:
|
|
|
|
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
|
|
|
|
|
|
|
|
- name: Retrieve bot secrets
|
|
|
|
id: retrieve-bot-secrets
|
2023-08-25 22:27:30 +02:00
|
|
|
uses: bitwarden/gh-actions/get-keyvault-secrets@67ab95d7a466bcefdedf3f93cbc10bcff436edfe
|
2023-05-08 17:20:44 +02:00
|
|
|
with:
|
|
|
|
keyvault: bitwarden-ci
|
|
|
|
secrets: "github-pat-bitwarden-devops-bot-repo-scope"
|
|
|
|
|
|
|
|
- name: Checkout GH pages repo
|
2023-06-29 16:46:56 +02:00
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2023-05-08 17:20:44 +02:00
|
|
|
with:
|
|
|
|
repository: bitwarden/web-vault-pages
|
|
|
|
path: ghpages-deployment
|
|
|
|
token: ${{ steps.retrieve-bot-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }}
|
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' }}
|
2023-08-25 22:27:30 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@67ab95d7a466bcefdedf3f93cbc10bcff436edfe
|
2022-05-03 18:21:27 +02:00
|
|
|
with:
|
2022-06-03 16:35:46 +02:00
|
|
|
workflow: build-web.yml
|
2023-05-08 17:20:44 +02:00
|
|
|
path: assets
|
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-11-14 15:35:42 +01:00
|
|
|
- name: Dry Run - Download latest cloud asset
|
2022-07-19 21:01:14 +02:00
|
|
|
if: ${{ github.event.inputs.release_type == 'Dry Run' }}
|
2023-08-25 22:27:30 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@67ab95d7a466bcefdedf3f93cbc10bcff436edfe
|
2022-07-19 21:01:14 +02:00
|
|
|
with:
|
|
|
|
workflow: build-web.yml
|
2023-05-08 17:20:44 +02:00
|
|
|
path: assets
|
2022-07-19 21:01:14 +02:00
|
|
|
workflow_conclusion: success
|
|
|
|
branch: master
|
|
|
|
artifacts: web-*-cloud-COMMERCIAL.zip
|
|
|
|
|
2022-10-12 02:57:34 +02:00
|
|
|
- name: Unzip build asset
|
2023-05-08 17:20:44 +02:00
|
|
|
working-directory: assets
|
2022-10-12 02:57:34 +02:00
|
|
|
run: unzip web-*-cloud-COMMERCIAL.zip
|
2023-08-16 17:41:02 +02:00
|
|
|
|
2023-05-08 17:20:44 +02:00
|
|
|
- name: Create new branch
|
2022-05-03 18:21:27 +02:00
|
|
|
run: |
|
2023-05-08 17:20:44 +02:00
|
|
|
cd ${{ github.workspace }}/ghpages-deployment
|
|
|
|
git config user.name = "GitHub Action Bot"
|
|
|
|
git config user.email = "<>"
|
2022-05-03 18:21:27 +02:00
|
|
|
git config --global url."https://github.com/".insteadOf ssh://git@github.com/
|
|
|
|
git config --global url."https://".insteadOf ssh://
|
2023-05-08 17:20:44 +02:00
|
|
|
git checkout -b ${_BRANCH}
|
2023-08-16 17:41:02 +02:00
|
|
|
|
2023-05-08 17:20:44 +02:00
|
|
|
- name: Copy build files
|
2022-05-03 18:21:27 +02:00
|
|
|
run: |
|
2023-05-08 17:20:44 +02:00
|
|
|
rm -rf ${{ github.workspace }}/ghpages-deployment/*
|
|
|
|
cp -Rf ${{ github.workspace }}/assets/build/* ghpages-deployment/
|
2023-08-16 17:41:02 +02:00
|
|
|
|
2023-05-08 17:20:44 +02:00
|
|
|
- name: Commit and push changes
|
|
|
|
working-directory: ghpages-deployment
|
2022-05-03 18:21:27 +02:00
|
|
|
run: |
|
|
|
|
git add .
|
2023-05-08 17:20:44 +02:00
|
|
|
git commit -m "Deploy Web v${_RELEASE_VERSION} to GitHub Pages"
|
|
|
|
git push --set-upstream origin ${_BRANCH} --force
|
2022-05-03 18:21:27 +02:00
|
|
|
|
2023-05-08 17:20:44 +02:00
|
|
|
- name: Create GitHub Pages Deploy PR
|
|
|
|
working-directory: ghpages-deployment
|
2022-05-03 18:21:27 +02:00
|
|
|
env:
|
2023-05-08 17:20:44 +02:00
|
|
|
GITHUB_TOKEN: ${{ steps.retrieve-bot-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }}
|
2022-05-03 18:21:27 +02:00
|
|
|
run: |
|
2023-05-08 17:20:44 +02:00
|
|
|
if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then
|
|
|
|
gh pr create --title "Deploy v${_RELEASE_VERSION} to GitHub Pages" \
|
|
|
|
--draft \
|
|
|
|
--body "Deploying v${_RELEASE_VERSION}" \
|
|
|
|
--base master \
|
|
|
|
--head "${_BRANCH}"
|
|
|
|
else
|
|
|
|
gh pr create --title "Deploy v${_RELEASE_VERSION} to GitHub Pages" \
|
|
|
|
--body "Deploying v${_RELEASE_VERSION}" \
|
|
|
|
--base master \
|
|
|
|
--head "${_BRANCH}"
|
|
|
|
fi
|
2022-05-03 18:21:27 +02:00
|
|
|
|
2021-09-21 18:37:17 +02:00
|
|
|
release:
|
|
|
|
name: Create GitHub Release
|
2023-08-16 06:37:41 +02:00
|
|
|
runs-on: ubuntu-22.04
|
2021-09-21 18:37:17 +02:00
|
|
|
needs:
|
|
|
|
- setup
|
|
|
|
- self-host
|
2023-05-08 17:20:44 +02:00
|
|
|
- ghpages-deploy
|
2021-09-21 18:37:17 +02:00
|
|
|
steps:
|
2022-07-25 23:20:17 +02:00
|
|
|
- name: Create GitHub deployment
|
2022-11-14 19:43:28 +01:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
2023-05-05 22:17:19 +02:00
|
|
|
uses: chrnorm/deployment-action@d42cde7132fcec920de534fffc3be83794335c00 # v2.0.5
|
2022-07-25 23:20:17 +02:00
|
|
|
id: deployment
|
|
|
|
with:
|
|
|
|
token: '${{ secrets.GITHUB_TOKEN }}'
|
2022-08-08 19:21:49 +02:00
|
|
|
initial-status: 'in_progress'
|
2022-07-25 23:20:17 +02:00
|
|
|
environment-url: http://vault.bitwarden.com
|
|
|
|
environment: 'Web Vault - Production'
|
|
|
|
description: 'Deployment ${{ needs.setup.outputs.release_version }} from branch ${{ github.ref_name }}'
|
|
|
|
task: release
|
|
|
|
|
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' }}
|
2023-08-25 22:27:30 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@67ab95d7a466bcefdedf3f93cbc10bcff436edfe
|
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,
|
|
|
|
web-*-selfhosted-open-source.zip"
|
|
|
|
|
2022-11-14 15:35:42 +01:00
|
|
|
- name: Dry Run - Download latest build artifacts
|
2022-07-01 17:44:20 +02:00
|
|
|
if: ${{ github.event.inputs.release_type == 'Dry Run' }}
|
2023-08-25 22:27:30 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@67ab95d7a466bcefdedf3f93cbc10bcff436edfe
|
2022-07-01 17:44:20 +02:00
|
|
|
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' }}
|
2023-05-05 22:17:19 +02:00
|
|
|
uses: ncipollo/release-action@a2e71bdd4e7dab70ca26a852f29600c98b33153e # v1.12.0
|
2021-09-21 18:37:17 +02:00
|
|
|
with:
|
2022-08-03 00:01:30 +02:00
|
|
|
name: "Web v${{ needs.setup.outputs.release_version }}"
|
2021-09-21 18:37:17 +02:00
|
|
|
commit: ${{ github.sha }}
|
2022-08-03 00:01:30 +02:00
|
|
|
tag: web-v${{ needs.setup.outputs.release_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
|
2022-11-14 19:43:28 +01:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' && success() }}
|
2023-05-09 11:44:05 +02:00
|
|
|
uses: chrnorm/deployment-status@2afb7d27101260f4a764219439564d954d10b5b0 # v2.0.1
|
2022-07-25 23:20:17 +02:00
|
|
|
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
|
2022-11-14 19:43:28 +01:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' && failure() }}
|
2023-05-09 11:44:05 +02:00
|
|
|
uses: chrnorm/deployment-status@2afb7d27101260f4a764219439564d954d10b5b0 # v2.0.1
|
2022-07-25 23:20:17 +02:00
|
|
|
with:
|
|
|
|
token: '${{ secrets.GITHUB_TOKEN }}'
|
|
|
|
environment-url: http://vault.bitwarden.com
|
|
|
|
state: 'failure'
|
|
|
|
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
|