You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
176 lines
5.8 KiB
176 lines
5.8 KiB
--- |
|
name: Release |
|
|
|
on: |
|
workflow_dispatch: |
|
inputs: |
|
release_type: |
|
description: 'Release Options' |
|
required: true |
|
default: 'Initial Release' |
|
type: choice |
|
options: |
|
- Initial Release |
|
- Redeploy |
|
- Dry Run |
|
|
|
jobs: |
|
setup: |
|
name: Setup |
|
runs-on: ubuntu-20.04 |
|
outputs: |
|
release_version: ${{ steps.version.outputs.version }} |
|
branch-name: ${{ steps.branch.outputs.branch-name }} |
|
steps: |
|
- name: Branch check |
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }} |
|
run: | |
|
if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then |
|
echo "===================================" |
|
echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches" |
|
echo "===================================" |
|
exit 1 |
|
fi |
|
- name: Checkout repo |
|
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 |
|
|
|
- name: Check Release Version |
|
id: version |
|
uses: bitwarden/gh-actions/release-version-check@8f055ef543c7433c967a1b9b04a0f230923233bb |
|
with: |
|
release-type: ${{ github.event.inputs.release_type }} |
|
project-type: dotnet |
|
file: src/KeyConnector/KeyConnector.csproj |
|
|
|
- name: Get branch name |
|
id: branch |
|
run: | |
|
BRANCH_NAME=$(basename ${{ github.ref }}) |
|
echo "::set-output name=branch-name::$BRANCH_NAME" |
|
|
|
release-docker: |
|
name: Build Docker images |
|
runs-on: ubuntu-20.04 |
|
needs: setup |
|
env: |
|
_SERVICE_NAME: key-connector |
|
_RELEASE_VERSION: ${{ needs.setup.outputs.release_version }} |
|
_BRANCH_NAME: ${{ needs.setup.outputs.branch-name }} |
|
_RELEASE_OPTION: ${{ github.event.inputs.release_type }} |
|
steps: |
|
- name: Print environment |
|
run: | |
|
whoami |
|
docker --version |
|
echo "GitHub ref: $GITHUB_REF" |
|
echo "GitHub event: $GITHUB_EVENT" |
|
echo "Github Release Option: $_RELEASE_OPTION" |
|
|
|
- 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@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 |
|
|
|
- name: Pull latest selfhost image |
|
run: | |
|
if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then |
|
docker pull bitwarden/$_SERVICE_NAME:latest |
|
else |
|
docker pull bitwarden/$_SERVICE_NAME:$_BRANCH_NAME |
|
fi |
|
|
|
- name: Tag version and latest |
|
run: | |
|
if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then |
|
docker tag bitwarden/$_SERVICE_NAME:latest bitwarden/$_SERVICE_NAME:dryrun |
|
else |
|
docker tag bitwarden/$_SERVICE_NAME:$_BRANCH_NAME bitwarden/$_SERVICE_NAME:$_RELEASE_VERSION |
|
docker tag bitwarden/$_SERVICE_NAME:$_BRANCH_NAME bitwarden/$_SERVICE_NAME:latest |
|
fi |
|
|
|
- name: List Docker images |
|
run: docker images |
|
|
|
- name: Push version and latest image |
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }} |
|
# env: |
|
# DOCKER_CONTENT_TRUST: 1 |
|
# DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.setup-dct.outputs.dct-delegate-repo-passphrase }} |
|
run: | |
|
docker push bitwarden/$_SERVICE_NAME:$_RELEASE_VERSION |
|
docker push bitwarden/$_SERVICE_NAME:latest |
|
|
|
- name: Log out of Docker |
|
run: docker logout |
|
|
|
|
|
release-github: |
|
name: Create GitHub Release |
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }} |
|
runs-on: ubuntu-20.04 |
|
needs: setup |
|
steps: |
|
- name: Create release |
|
uses: ncipollo/release-action@40bb172bd05f266cf9ba4ff965cb61e9ee5f6d01 # v1.9.0 |
|
with: |
|
commit: ${{ github.sha }} |
|
tag: "v${{ needs.setup.outputs.release_version }}" |
|
name: "Version ${{ needs.setup.outputs.release_version }}" |
|
body: "<insert release notes here>" |
|
token: ${{ secrets.GITHUB_TOKEN }} |
|
draft: true |
|
|
|
|
|
check-failures: |
|
name: Check for failures |
|
if: always() |
|
runs-on: ubuntu-20.04 |
|
needs: |
|
- release-docker |
|
- release-github |
|
- setup |
|
steps: |
|
- name: Check if any job failed |
|
if: | |
|
github.ref == 'refs/heads/master' |
|
|| github.ref == 'refs/heads/rc' |
|
|| github.ref == 'refs/heads/hotfix' |
|
env: |
|
RELEASE_DOCKER_STATUS: ${{ needs.release-docker.result }} |
|
RELEASE_GITHUB_STATUS: ${{ needs.release-github.result }} |
|
SETUP_STATUS: ${{ needs.setup.result }} |
|
run: | |
|
if [ "$RELEASE_DOCKER_STATUS" = "failure" ]; then |
|
exit 1 |
|
elif [ "$RELEASE_GITHUB_STATUS" = "failure" ]; then |
|
exit 1 |
|
elif [ "$SETUP_STATUS" = "failure" ]; then |
|
exit 1 |
|
fi |
|
|
|
- name: Login to Azure - Prod Subscription |
|
uses: Azure/login@1f63701bf3e6892515f1b7ce2d2bf1708b46beaf |
|
if: failure() |
|
with: |
|
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }} |
|
|
|
- name: Retrieve secrets |
|
id: retrieve-secrets |
|
uses: Azure/get-keyvault-secrets@64af23c7cf243996cd6ec3b15a6957947935c54b # v1 |
|
if: failure() |
|
with: |
|
keyvault: "bitwarden-prod-kv" |
|
secrets: "devops-alerts-slack-webhook-url" |
|
|
|
- name: Notify Slack on failure |
|
uses: act10ns/slack@da3191ebe2e67f49b46880b4633f5591a96d1d33 # v1.5.1 |
|
if: failure() |
|
env: |
|
SLACK_WEBHOOK_URL: ${{ steps.retrieve-secrets.outputs.devops-alerts-slack-webhook-url }} |
|
with: |
|
status: ${{ job.status }}
|
|
|