2021-09-02 22:03:28 +02:00
|
|
|
---
|
2021-05-04 22:41:49 +02:00
|
|
|
name: Release
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
2021-12-20 21:19:18 +01:00
|
|
|
inputs:
|
|
|
|
release_type:
|
|
|
|
description: 'Release Options'
|
|
|
|
required: true
|
|
|
|
default: 'Initial Release'
|
|
|
|
type: choice
|
|
|
|
options:
|
|
|
|
- Initial Release
|
|
|
|
- Redeploy
|
2021-10-20 00:13:42 +02:00
|
|
|
|
2021-05-04 22:41:49 +02:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
setup:
|
2021-05-27 16:32:36 +02:00
|
|
|
name: Setup
|
2021-09-25 00:04:14 +02:00
|
|
|
runs-on: ubuntu-20.04
|
2021-05-04 22:41:49 +02:00
|
|
|
outputs:
|
2021-09-25 00:04:14 +02:00
|
|
|
release_version: ${{ steps.version.outputs.package }}
|
2021-11-08 19:39:32 +01:00
|
|
|
branch-name: ${{ steps.branch.outputs.branch-name }}
|
2021-05-04 22:41:49 +02:00
|
|
|
steps:
|
2021-10-22 17:41:38 +02:00
|
|
|
- name: Branch check
|
|
|
|
run: |
|
2022-02-09 17:17:17 +01:00
|
|
|
if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then
|
2021-10-22 17:41:38 +02:00
|
|
|
echo "==================================="
|
2022-02-09 17:17:17 +01:00
|
|
|
echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches"
|
2021-10-22 17:41:38 +02:00
|
|
|
echo "==================================="
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-05-04 22:41:49 +02:00
|
|
|
- name: Checkout repo
|
2021-05-17 21:15:01 +02:00
|
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
2021-05-04 22:41:49 +02:00
|
|
|
|
2021-09-25 00:04:14 +02:00
|
|
|
- name: Check Release Version
|
|
|
|
id: version
|
2021-05-04 22:41:49 +02:00
|
|
|
run: |
|
2021-09-25 00:04:14 +02:00
|
|
|
version=$( grep -o "<Version>.*</Version>" Directory.Build.props | grep -o "[0-9]*\.[0-9]*\.[0-9]*")
|
|
|
|
previous_release_tag_version=$(
|
|
|
|
curl -sL https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq -r ".tag_name"
|
|
|
|
)
|
2021-05-04 22:41:49 +02:00
|
|
|
|
2021-12-20 21:19:18 +01:00
|
|
|
if [ "v$version" == "$previous_release_tag_version" ] && \
|
|
|
|
[ "${{ github.event.inputs.release_type }}" == "Initial Release" ]; then
|
2021-09-25 00:04:14 +02:00
|
|
|
echo "[!] Already released v$version. Please bump version to continue"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-05-04 22:41:49 +02:00
|
|
|
|
2021-09-25 00:04:14 +02:00
|
|
|
echo "::set-output name=package::$version"
|
2021-05-04 22:41:49 +02:00
|
|
|
|
2021-11-08 19:39:32 +01:00
|
|
|
- name: Get branch name
|
|
|
|
id: branch
|
|
|
|
run: |
|
|
|
|
BRANCH_NAME=$(basename ${{ github.ref }})
|
|
|
|
echo "::set-output name=branch-name::$BRANCH_NAME"
|
|
|
|
|
2021-09-25 00:04:14 +02:00
|
|
|
|
|
|
|
deploy:
|
|
|
|
name: Deploy
|
|
|
|
runs-on: ubuntu-20.04
|
2021-09-02 22:03:28 +02:00
|
|
|
needs:
|
2021-06-01 22:16:06 +02:00
|
|
|
- setup
|
2021-09-25 00:04:14 +02:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- name: Api
|
|
|
|
- name: Admin
|
|
|
|
- name: Billing
|
|
|
|
- name: Events
|
|
|
|
- name: Sso
|
|
|
|
- name: Identity
|
2021-05-27 16:32:36 +02:00
|
|
|
steps:
|
2021-09-25 00:04:14 +02:00
|
|
|
- name: Setup
|
|
|
|
id: setup
|
2021-05-04 22:41:49 +02:00
|
|
|
run: |
|
2021-09-25 00:04:14 +02:00
|
|
|
NAME_LOWER=$(echo "${{ matrix.name }}" | awk '{print tolower($0)}')
|
|
|
|
echo "Matrix name: ${{ matrix.name }}"
|
|
|
|
echo "NAME_LOWER: $NAME_LOWER"
|
|
|
|
echo "::set-output name=name_lower::$NAME_LOWER"
|
2021-05-04 22:41:49 +02:00
|
|
|
|
2021-10-22 17:41:38 +02:00
|
|
|
- name: Download latest Release ${{ matrix.name }} asset
|
2021-09-25 00:04:14 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@23433be15ed6fd046ce12b6889c5184a8d9c8783
|
2021-05-04 22:41:49 +02:00
|
|
|
with:
|
2021-09-25 00:04:14 +02:00
|
|
|
workflow: build.yml
|
|
|
|
workflow_conclusion: success
|
2021-11-08 19:39:32 +01:00
|
|
|
branch: ${{ needs.setup.outputs.branch-name }}
|
2021-09-28 00:30:20 +02:00
|
|
|
artifacts: ${{ matrix.name }}.zip
|
2021-05-04 22:41:49 +02:00
|
|
|
|
2021-09-25 00:04:14 +02:00
|
|
|
- name: Login to Azure
|
|
|
|
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
|
|
|
|
with:
|
|
|
|
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
|
2021-05-04 22:41:49 +02:00
|
|
|
|
2021-09-25 00:04:14 +02:00
|
|
|
- name: Retrieve secrets
|
|
|
|
id: retrieve-secrets
|
2021-05-04 22:41:49 +02:00
|
|
|
env:
|
2021-09-25 00:04:14 +02:00
|
|
|
VAULT_NAME: "bitwarden-prod-kv"
|
|
|
|
run: |
|
|
|
|
webapp_name=$(
|
|
|
|
az keyvault secret show --vault-name $VAULT_NAME \
|
|
|
|
--name appservices-${{ steps.setup.outputs.name_lower }}-webapp-name \
|
|
|
|
--query value --output tsv
|
|
|
|
)
|
2021-10-27 17:45:33 +02:00
|
|
|
publish_profile=$(
|
|
|
|
az keyvault secret show --vault-name $VAULT_NAME \
|
|
|
|
--name appservices-${{ steps.setup.outputs.name_lower }}-webapp-publish-profile \
|
|
|
|
--query value --output tsv
|
|
|
|
)
|
2021-09-25 00:04:14 +02:00
|
|
|
echo "::add-mask::$webapp_name"
|
|
|
|
echo "::set-output name=webapp-name::$webapp_name"
|
2021-10-27 17:45:33 +02:00
|
|
|
echo "::add-mask::$publish_profile"
|
|
|
|
echo "::set-output name=publish-profile::$publish_profile"
|
2021-05-04 22:41:49 +02:00
|
|
|
|
2021-09-25 00:04:14 +02:00
|
|
|
- name: Deploy App
|
|
|
|
uses: azure/webapps-deploy@798e43877120eda6a2a690a4f212c545e586ae31
|
2021-05-04 22:41:49 +02:00
|
|
|
with:
|
2021-09-25 00:04:14 +02:00
|
|
|
app-name: ${{ steps.retrieve-secrets.outputs.webapp-name }}
|
2021-10-27 17:45:33 +02:00
|
|
|
publish-profile: ${{ steps.retrieve-secrets.outputs.publish-profile }}
|
2021-09-25 00:04:14 +02:00
|
|
|
package: ./${{ matrix.name }}.zip
|
2021-10-27 04:18:54 +02:00
|
|
|
slot-name: "staging"
|
2021-05-04 22:41:49 +02:00
|
|
|
|
2021-09-25 00:04:14 +02:00
|
|
|
|
2021-10-22 17:41:38 +02:00
|
|
|
release-docker:
|
|
|
|
name: Build Docker images
|
|
|
|
runs-on: ubuntu-20.04
|
2021-11-15 19:23:51 +01:00
|
|
|
needs:
|
|
|
|
- setup
|
2021-10-22 17:41:38 +02:00
|
|
|
env:
|
|
|
|
_RELEASE_VERSION: ${{ needs.setup.outputs.release_version }}
|
2021-11-08 19:39:32 +01:00
|
|
|
_BRANCH_NAME: ${{ needs.setup.outputs.branch-name }}
|
2021-10-22 17:41:38 +02:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- service_name: Admin
|
|
|
|
- service_name: Api
|
|
|
|
- service_name: Attachments
|
|
|
|
- service_name: Events
|
|
|
|
- service_name: Icons
|
|
|
|
- service_name: Identity
|
|
|
|
- service_name: K8S-Proxy
|
|
|
|
- service_name: MsSql
|
|
|
|
- service_name: Nginx
|
|
|
|
- service_name: Notifications
|
|
|
|
- service_name: Server
|
|
|
|
- service_name: Setup
|
|
|
|
- service_name: Sso
|
|
|
|
steps:
|
|
|
|
- name: Print environment
|
|
|
|
run: |
|
|
|
|
whoami
|
|
|
|
docker --version
|
|
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
|
|
echo "GitHub event: $GITHUB_EVENT"
|
|
|
|
|
|
|
|
- name: Setup DCT
|
|
|
|
id: setup-dct
|
|
|
|
uses: bitwarden/gh-actions/setup-docker-trust@a8c384a05a974c05c48374c818b004be221d43ff
|
|
|
|
with:
|
|
|
|
azure-creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
|
|
|
|
azure-keyvault-name: "bitwarden-prod-kv"
|
|
|
|
|
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
|
|
|
|
|
|
|
- name: Setup service name
|
|
|
|
id: setup
|
|
|
|
run: |
|
|
|
|
SERVICE_NAME=$(echo "${{ matrix.service_name }}" | awk '{print tolower($0)}')
|
|
|
|
echo "Matrix name: ${{ matrix.service_name }}"
|
|
|
|
echo "SERVICE_NAME: $SERVICE_NAME"
|
|
|
|
echo "::set-output name=service_name::$SERVICE_NAME"
|
|
|
|
|
2021-11-08 19:39:32 +01:00
|
|
|
- name: Pull latest selfhost image
|
|
|
|
env:
|
|
|
|
SERVICE_NAME: ${{ steps.setup.outputs.service_name }}
|
|
|
|
run: docker pull bitwarden/$SERVICE_NAME:$_BRANCH_NAME
|
2021-10-22 17:41:38 +02:00
|
|
|
|
2021-11-08 19:39:32 +01:00
|
|
|
- name: Tag version and latest
|
|
|
|
env:
|
|
|
|
SERVICE_NAME: ${{ steps.setup.outputs.service_name }}
|
2021-10-22 17:41:38 +02:00
|
|
|
run: |
|
2021-11-08 19:39:32 +01:00
|
|
|
docker tag bitwarden/$SERVICE_NAME:$_BRANCH_NAME bitwarden/$SERVICE_NAME:$_RELEASE_VERSION
|
|
|
|
docker tag bitwarden/$SERVICE_NAME:$_BRANCH_NAME bitwarden/$SERVICE_NAME:latest
|
2021-10-22 17:41:38 +02:00
|
|
|
|
|
|
|
- name: List Docker images
|
|
|
|
run: docker images
|
|
|
|
|
2021-11-08 19:39:32 +01:00
|
|
|
- name: Push version and latest image
|
2021-10-22 17:41:38 +02:00
|
|
|
env:
|
|
|
|
DOCKER_CONTENT_TRUST: 1
|
|
|
|
DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.setup-dct.outputs.dct-delegate-repo-passphrase }}
|
2021-11-08 19:39:32 +01:00
|
|
|
SERVICE_NAME: ${{ steps.setup.outputs.service_name }}
|
|
|
|
run: |
|
|
|
|
docker push bitwarden/$SERVICE_NAME:$_RELEASE_VERSION
|
|
|
|
docker push bitwarden/$SERVICE_NAME:latest
|
2021-10-22 17:41:38 +02:00
|
|
|
|
|
|
|
- name: Log out of Docker
|
|
|
|
run: docker logout
|
|
|
|
|
|
|
|
|
2021-09-25 00:04:14 +02:00
|
|
|
release:
|
|
|
|
name: Create GitHub Release
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
needs:
|
|
|
|
- setup
|
|
|
|
- deploy
|
|
|
|
steps:
|
2021-10-22 17:41:38 +02:00
|
|
|
- name: Download latest Release docker-stub
|
2021-09-25 00:04:14 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@23433be15ed6fd046ce12b6889c5184a8d9c8783
|
|
|
|
with:
|
|
|
|
workflow: build.yml
|
|
|
|
workflow_conclusion: success
|
2021-11-08 19:39:32 +01:00
|
|
|
branch: ${{ needs.setup.outputs.branch-name }}
|
2021-09-25 00:04:14 +02:00
|
|
|
artifacts: "docker-stub.zip,
|
|
|
|
swagger.json"
|
|
|
|
|
|
|
|
- name: Create release
|
|
|
|
uses: ncipollo/release-action@95215a3cb6e6a1908b3c44e00b4fdb15548b1e09
|
|
|
|
with:
|
|
|
|
artifacts: 'docker-stub.zip,
|
|
|
|
swagger.json'
|
|
|
|
commit: ${{ github.sha }}
|
2021-09-28 00:30:20 +02:00
|
|
|
tag: "v${{ needs.setup.outputs.release_version }}"
|
2021-09-25 00:04:14 +02:00
|
|
|
name: "Version ${{ needs.setup.outputs.release_version }}"
|
|
|
|
body: "<insert release notes here>"
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
draft: true
|