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
|
2024-02-08 20:43:14 +01:00
|
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
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-11-08 19:08:34 +01:00
|
|
|
uses: bitwarden/gh-actions/release-version-check@main
|
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
|
2024-02-08 20:43:14 +01:00
|
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
2022-03-03 20:00:41 +01:00
|
|
|
|
|
|
|
########## ACR ##########
|
2023-02-15 16:32:00 +01:00
|
|
|
- name: Login to Azure - PROD Subscription
|
2024-02-08 20:38:19 +01:00
|
|
|
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
|
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
|
|
|
|
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
|
|
|
|
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' }}
|
2024-02-08 20:38:19 +01:00
|
|
|
uses: chrnorm/deployment-action@55729fcebec3d284f60f5bcabbd8376437d696b1 # v2.0.7
|
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
|
2024-03-01 17:47:58 +01:00
|
|
|
environment: 'Web Vault - US Production Cloud'
|
2022-07-25 23:20:17 +02:00
|
|
|
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-11-08 19:08:34 +01:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@main
|
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-11-08 19:08:34 +01:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@main
|
2022-07-01 17:44:20 +02:00
|
|
|
with:
|
|
|
|
workflow: build-web.yml
|
|
|
|
path: apps/web/artifacts
|
|
|
|
workflow_conclusion: success
|
2023-12-12 20:57:50 +01:00
|
|
|
branch: main
|
2022-07-01 17:44:20 +02:00
|
|
|
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' }}
|
2024-02-08 20:38:19 +01:00
|
|
|
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.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() }}
|
2024-03-06 19:49:15 +01:00
|
|
|
uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3
|
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() }}
|
2024-03-06 19:49:15 +01:00
|
|
|
uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3
|
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 }}
|