2021-09-02 22:05:17 +02:00
|
|
|
---
|
2021-06-02 17:28:56 +02:00
|
|
|
name: Release
|
|
|
|
|
|
|
|
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:
|
2021-09-24 18:28:37 +02:00
|
|
|
release_version: ${{ steps.version.outputs.package }}
|
|
|
|
tag_version: ${{ steps.version.outputs.tag }}
|
2022-02-02 16:30:19 +01:00
|
|
|
branch_name: ${{ steps.branch.outputs.branch_name }}
|
2021-06-02 17:28:56 +02:00
|
|
|
steps:
|
|
|
|
- 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-03-09 21:46:20 +01:00
|
|
|
if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then
|
2021-06-02 17:28:56 +02:00
|
|
|
echo "==================================="
|
2022-03-09 21:46:20 +01:00
|
|
|
echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches"
|
2021-06-02 17:28:56 +02:00
|
|
|
echo "==================================="
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Checkout repo
|
2022-02-25 15:07:54 +01:00
|
|
|
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # 2.4.0
|
2021-06-02 17:28:56 +02:00
|
|
|
|
2021-09-21 18:37:17 +02:00
|
|
|
- name: Check Release Version
|
|
|
|
id: version
|
2021-06-02 17:28:56 +02:00
|
|
|
run: |
|
2021-09-21 18:37:17 +02:00
|
|
|
version=$( jq -r ".version" package.json)
|
|
|
|
previous_release_tag_version=$(
|
|
|
|
curl -sL https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq -r ".tag_name"
|
|
|
|
)
|
2021-06-02 17:28:56 +02:00
|
|
|
|
2021-12-20 18:15:43 +01:00
|
|
|
if [ "v$version" == "$previous_release_tag_version" ] && \
|
|
|
|
[ "${{ github.event.inputs.release_type }}" == "Initial Release" ]; then
|
2021-09-21 18:37:17 +02:00
|
|
|
echo "[!] Already released v$version. Please bump version to continue"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "::set-output name=package::$version"
|
|
|
|
echo "::set-output name=tag::v$version"
|
|
|
|
|
2021-11-08 15:48:53 +01:00
|
|
|
- name: Get branch name
|
|
|
|
id: branch
|
|
|
|
run: |
|
|
|
|
BRANCH_NAME=$(basename ${{ github.ref }})
|
2022-02-02 16:30:19 +01:00
|
|
|
echo "::set-output name=branch_name::$BRANCH_NAME"
|
2021-11-08 15:48:53 +01: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-02-02 16:30:19 +01:00
|
|
|
_BRANCH_NAME: ${{ needs.setup.outputs.branch_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
|
|
|
|
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
|
|
|
|
|
|
|
|
########## 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
|
|
|
|
2021-12-16 17:46:26 +01:00
|
|
|
- name: Tag version and latest
|
2021-06-02 17:28:56 +02:00
|
|
|
run: |
|
2022-02-25 15:07:54 +01:00
|
|
|
if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then
|
|
|
|
docker tag bitwarden/web:latest bitwarden/web:dryrun
|
|
|
|
else
|
|
|
|
docker tag bitwarden/web:$_BRANCH_NAME bitwarden/web:$_RELEASE_VERSION
|
|
|
|
docker tag bitwarden/web:$_BRANCH_NAME bitwarden/web:latest
|
|
|
|
fi
|
2021-06-02 17:28:56 +02:00
|
|
|
|
2021-12-16 17:46:26 +01:00
|
|
|
- name: 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
|
|
|
|
docker push bitwarden/web:latest
|
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
|
|
|
|
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
|
|
|
|
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: |
|
|
|
|
if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then
|
|
|
|
docker tag bitwarden/web:latest $REGISTRY/web:dryrun
|
|
|
|
else
|
|
|
|
docker tag bitwarden/web:$_BRANCH_NAME $REGISTRY/web:$_RELEASE_VERSION
|
|
|
|
docker tag bitwarden/web:$_BRANCH_NAME $REGISTRY/web:latest
|
2022-03-30 23:21:00 +02:00
|
|
|
|
|
|
|
docker tag bitwarden/web:$_BRANCH_NAME $REGISTRY/web-sh:$_RELEASE_VERSION
|
|
|
|
docker tag bitwarden/web:$_BRANCH_NAME $REGISTRY/web-sh:latest
|
2022-03-03 20:00:41 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
- 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
|
|
|
|
docker push $REGISTRY/web:latest
|
|
|
|
|
2022-03-30 23:21:00 +02:00
|
|
|
docker push $REGISTRY/web-sh:$_RELEASE_VERSION
|
|
|
|
docker push $REGISTRY/web-sh:latest
|
|
|
|
|
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
|
|
|
|
2021-09-21 18:37:17 +02:00
|
|
|
ghpages-deploy:
|
2022-05-03 18:21:27 +02:00
|
|
|
name: Deploy Web Vault to GitHub Pages
|
2021-09-21 18:37:17 +02:00
|
|
|
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-02-25 15:07:54 +01:00
|
|
|
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0
|
2021-09-21 18:37:17 +02:00
|
|
|
with:
|
|
|
|
ref: gh-pages
|
|
|
|
|
2022-05-03 18:21:27 +02:00
|
|
|
- name: Create gh-pages-deploy branch
|
2021-06-02 17:28:56 +02:00
|
|
|
run: |
|
2022-05-03 18:21:27 +02:00
|
|
|
git switch -c gh-pages-deploy-$_TAG_VERSION
|
|
|
|
git push -u origin gh-pages-deploy-$_TAG_VERSION
|
2021-10-27 22:08:37 +02:00
|
|
|
|
|
|
|
- name: Checkout Repo
|
2022-02-25 15:07:54 +01:00
|
|
|
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0
|
2021-06-02 17:28:56 +02:00
|
|
|
|
2021-09-21 18:37:17 +02:00
|
|
|
- name: Setup git config
|
|
|
|
run: |
|
|
|
|
git config user.name = "GitHub Action Bot"
|
|
|
|
git config user.email = "<>"
|
|
|
|
git config --global url."https://github.com/".insteadOf ssh://git@github.com/
|
|
|
|
git config --global url."https://".insteadOf ssh://
|
2021-06-02 17:28:56 +02:00
|
|
|
|
2021-10-08 18:54:42 +02:00
|
|
|
- name: Download latest cloud asset
|
2022-04-15 01:05:20 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@c1fa8e09871a860862d6bbe36184b06d2c7e35a8
|
2021-09-21 18:37:17 +02:00
|
|
|
with:
|
|
|
|
workflow: build.yml
|
|
|
|
workflow_conclusion: success
|
2022-02-02 16:30:19 +01:00
|
|
|
branch: ${{ needs.setup.outputs.branch_name }}
|
2021-10-08 18:54:42 +02:00
|
|
|
artifacts: web-*-cloud-COMMERCIAL.zip
|
2021-06-02 17:28:56 +02:00
|
|
|
|
2021-09-21 18:37:17 +02:00
|
|
|
# This should result in a build directory in the current working directory
|
|
|
|
- name: Unzip build asset
|
2021-10-08 18:54:42 +02:00
|
|
|
run: unzip web-*-cloud-COMMERCIAL.zip
|
2021-06-02 17:28:56 +02:00
|
|
|
|
2021-09-21 18:37:17 +02:00
|
|
|
- name: Deploy GitHub Pages
|
2022-02-25 15:07:54 +01:00
|
|
|
uses: crazy-max/ghaction-github-pages@a117e4aa1fb4854d021546d2abdfac95be568a3a # v2.6.0
|
2021-09-02 22:05:17 +02:00
|
|
|
env:
|
2021-09-21 18:37:17 +02:00
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
2022-05-03 18:21:27 +02:00
|
|
|
target_branch: gh-pages-deploy-${{ needs.setup.outputs.tag_version }}
|
2021-09-21 18:37:17 +02:00
|
|
|
build_dir: build
|
|
|
|
keep_history: true
|
|
|
|
commit_message: "Staging deploy ${{ needs.setup.outputs.release_version }}"
|
2022-02-25 15:07:54 +01:00
|
|
|
dry_run: ${{ github.event.inputs.release_type == 'Dry Run' }}
|
2021-06-02 17:28:56 +02:00
|
|
|
|
2022-05-03 18:21:27 +02:00
|
|
|
- name: Create GitHub Pages Deploy PR
|
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:
|
2022-05-03 18:21:27 +02:00
|
|
|
PR_BRANCH: gh-pages-deploy-${{ env._TAG_VERSION }}
|
2021-09-21 18:37:17 +02:00
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
run: |
|
2022-05-03 18:21:27 +02:00
|
|
|
gh pr create --title "Deploy $_RELEASE_VERSION to GitHub Pages" \
|
2021-09-21 18:37:17 +02:00
|
|
|
--body "Deploying $_RELEASE_VERSION" \
|
|
|
|
--base gh-pages \
|
|
|
|
--head "$PR_BRANCH"
|
|
|
|
|
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
|
|
|
|
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0
|
|
|
|
|
|
|
|
- name: Download latest cloud asset
|
|
|
|
uses: bitwarden/gh-actions/download-artifacts@c1fa8e09871a860862d6bbe36184b06d2c7e35a8
|
|
|
|
with:
|
|
|
|
workflow: build.yml
|
|
|
|
workflow_conclusion: success
|
|
|
|
branch: ${{ needs.setup.outputs.branch_name }}
|
|
|
|
artifacts: web-*-cloud-COMMERCIAL.zip
|
|
|
|
|
|
|
|
# This should result in a build directory in the current working directory
|
|
|
|
- name: Unzip build asset
|
|
|
|
run: unzip web-*-cloud-COMMERCIAL.zip
|
|
|
|
|
|
|
|
- name: Checkout Repo
|
|
|
|
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0
|
|
|
|
with:
|
|
|
|
ref: deploy
|
|
|
|
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 ./*
|
|
|
|
cp -R ../build/* .
|
|
|
|
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 }}"
|
|
|
|
git push -u origin cf-pages-deploy-$_TAG_VERSION
|
|
|
|
working-directory: deployment
|
|
|
|
|
|
|
|
- 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" \
|
|
|
|
--base deploy \
|
|
|
|
--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
|
|
|
|
- ghpages-deploy
|
2022-05-03 18:21:27 +02:00
|
|
|
- cfpages-deploy
|
2021-09-21 18:37:17 +02:00
|
|
|
steps:
|
2021-10-08 18:54:42 +02:00
|
|
|
- name: Download latest build artifacts
|
|
|
|
uses: bitwarden/gh-actions/download-artifacts@23433be15ed6fd046ce12b6889c5184a8d9c8783
|
2021-09-21 18:37:17 +02:00
|
|
|
with:
|
|
|
|
workflow: build.yml
|
|
|
|
workflow_conclusion: success
|
2022-02-02 16:30:19 +01:00
|
|
|
branch: ${{ needs.setup.outputs.branch_name }}
|
2021-10-08 18:54:42 +02:00
|
|
|
artifacts: "web-*-selfhosted-COMMERCIAL.zip,
|
|
|
|
web-*-selfhosted-open-source.zip"
|
|
|
|
|
|
|
|
- name: Rename assets
|
|
|
|
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' }}
|
|
|
|
uses: ncipollo/release-action@40bb172bd05f266cf9ba4ff965cb61e9ee5f6d01
|
2021-09-21 18:37:17 +02:00
|
|
|
with:
|
2021-10-08 18:54:42 +02:00
|
|
|
name: "Version ${{ needs.setup.outputs.release_version }}"
|
2021-09-21 18:37:17 +02:00
|
|
|
commit: ${{ github.sha }}
|
2021-09-24 18:28:37 +02:00
|
|
|
tag: "${{ needs.setup.outputs.tag_version }}"
|
2021-09-21 18:37:17 +02:00
|
|
|
body: "<insert release notes here>"
|
2021-10-08 18:54:42 +02:00
|
|
|
artifacts: "web-${{ needs.setup.outputs.release_version }}-selfhosted-COMMERCIAL.zip,
|
|
|
|
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-02-25 15:07:54 +01:00
|
|
|
|
2022-03-03 20:00:41 +01:00
|
|
|
|
2022-02-25 15:07:54 +01:00
|
|
|
dry-run:
|
|
|
|
name: Dry Run Cleanup
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
if: ${{ github.event.inputs.release_type == 'Dry Run' }}
|
|
|
|
env:
|
|
|
|
_TAG_VERSION: ${{ needs.setup.outputs.tag_version }}
|
|
|
|
needs:
|
|
|
|
- setup
|
|
|
|
- release
|
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # 2.4.0
|
|
|
|
|
2022-05-03 18:21:27 +02:00
|
|
|
- name: Remove gh-pages-deploy branch
|
|
|
|
run: git push origin --delete gh-pages-deploy-$_TAG_VERSION
|
|
|
|
|
|
|
|
- name: Remove cf-pages-deploy branch
|
|
|
|
run: git push origin --delete cf-pages-deploy-$_TAG_VERSION
|