2021-09-02 22:03:28 +02:00
|
|
|
---
|
2021-05-04 22:41:49 +02:00
|
|
|
name: Release
|
2022-11-08 21:26:47 +01:00
|
|
|
run-name: Release ${{ inputs.release_type }}
|
2021-05-04 22:41:49 +02:00
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
2021-12-20 21:19:18 +01:00
|
|
|
inputs:
|
|
|
|
release_type:
|
2022-11-18 20:39:01 +01:00
|
|
|
description: "Release Options"
|
2021-12-20 21:19:18 +01:00
|
|
|
required: true
|
2022-11-18 20:39:01 +01:00
|
|
|
default: "Initial Release"
|
2021-12-20 21:19:18 +01:00
|
|
|
type: choice
|
|
|
|
options:
|
|
|
|
- Initial Release
|
|
|
|
- Redeploy
|
2022-02-24 14:55:43 +01:00
|
|
|
- Dry Run
|
2021-10-20 00:13:42 +02:00
|
|
|
|
2023-08-14 16:56:54 +02:00
|
|
|
env:
|
2024-01-23 19:24:52 +01:00
|
|
|
_AZ_REGISTRY: "bitwardenprod.azurecr.io"
|
2023-08-14 16:56:54 +02:00
|
|
|
|
2021-05-04 22:41:49 +02:00
|
|
|
jobs:
|
|
|
|
setup:
|
2021-05-27 16:32:36 +02:00
|
|
|
name: Setup
|
2022-11-18 20:39:01 +01:00
|
|
|
runs-on: ubuntu-22.04
|
2021-05-04 22:41:49 +02:00
|
|
|
outputs:
|
2022-06-01 03:08:56 +02:00
|
|
|
release_version: ${{ steps.version.outputs.version }}
|
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
|
2024-07-09 15:24:25 +02:00
|
|
|
if: ${{ inputs.release_type != 'Dry Run' }}
|
2021-10-22 17:41:38 +02:00
|
|
|
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
|
|
|
|
|
2024-01-23 19:24:52 +01:00
|
|
|
- name: Check out repo
|
2024-07-10 21:47:20 +02:00
|
|
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
2021-05-04 22:41:49 +02:00
|
|
|
|
2024-01-23 19:24:52 +01:00
|
|
|
- name: Check release version
|
2021-09-25 00:04:14 +02:00
|
|
|
id: version
|
2023-11-08 19:08:15 +01:00
|
|
|
uses: bitwarden/gh-actions/release-version-check@main
|
2022-06-01 01:11:21 +02:00
|
|
|
with:
|
2024-07-09 15:24:25 +02:00
|
|
|
release-type: ${{ inputs.release_type }}
|
2022-06-28 22:54:49 +02:00
|
|
|
project-type: dotnet
|
2022-06-01 01:11:21 +02:00
|
|
|
file: Directory.Build.props
|
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 }})
|
2022-12-05 17:12:42 +01:00
|
|
|
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
|
2021-11-08 19:39:32 +01:00
|
|
|
|
2021-10-22 17:41:38 +02:00
|
|
|
release-docker:
|
|
|
|
name: Build Docker images
|
2022-11-18 20:39:01 +01:00
|
|
|
runs-on: ubuntu-22.04
|
2023-08-14 16:56:54 +02: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:
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Admin
|
|
|
|
- project_name: Api
|
|
|
|
- project_name: Attachments
|
2023-08-14 16:56:54 +02:00
|
|
|
- project_name: Billing
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Events
|
|
|
|
- project_name: EventsProcessor
|
|
|
|
- project_name: Icons
|
|
|
|
- project_name: Identity
|
|
|
|
- project_name: MsSql
|
2023-08-14 16:56:54 +02:00
|
|
|
- project_name: MsSqlMigratorUtility
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Nginx
|
|
|
|
- project_name: Notifications
|
2023-08-14 16:56:54 +02:00
|
|
|
- project_name: Scim
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Server
|
|
|
|
- project_name: Setup
|
|
|
|
- project_name: Sso
|
2021-10-22 17:41:38 +02:00
|
|
|
steps:
|
|
|
|
- name: Print environment
|
2022-02-24 14:55:43 +01:00
|
|
|
env:
|
2024-07-09 15:24:25 +02:00
|
|
|
RELEASE_OPTION: ${{ inputs.release_type }}
|
2021-10-22 17:41:38 +02:00
|
|
|
run: |
|
|
|
|
whoami
|
|
|
|
docker --version
|
|
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
|
|
echo "GitHub event: $GITHUB_EVENT"
|
2022-02-24 14:55:43 +01:00
|
|
|
echo "Github Release Option: $RELEASE_OPTION"
|
2021-10-22 17:41:38 +02:00
|
|
|
|
2024-01-23 19:24:52 +01:00
|
|
|
- name: Check out repo
|
2024-07-10 21:47:20 +02:00
|
|
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
2021-10-22 17:41:38 +02:00
|
|
|
|
2024-01-23 19:24:52 +01:00
|
|
|
- name: Set up project name
|
2021-10-22 17:41:38 +02:00
|
|
|
id: setup
|
|
|
|
run: |
|
2022-11-18 20:39:01 +01:00
|
|
|
PROJECT_NAME=$(echo "${{ matrix.project_name }}" | awk '{print tolower($0)}')
|
|
|
|
echo "Matrix name: ${{ matrix.project_name }}"
|
|
|
|
echo "PROJECT_NAME: $PROJECT_NAME"
|
2022-12-05 17:12:42 +01:00
|
|
|
echo "project_name=$PROJECT_NAME" >> $GITHUB_OUTPUT
|
2021-10-22 17:41:38 +02:00
|
|
|
|
2022-08-25 10:02:24 +02:00
|
|
|
########## ACR PROD ##########
|
2024-01-23 19:24:52 +01:00
|
|
|
- name: Log in to Azure - production subscription
|
2024-07-10 21:47:20 +02:00
|
|
|
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
|
2022-08-25 10:02:24 +02:00
|
|
|
with:
|
|
|
|
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
|
|
|
|
|
2024-01-23 19:24:52 +01:00
|
|
|
- name: Log in to Azure ACR
|
2023-08-14 16:56:54 +02:00
|
|
|
run: az acr login -n $_AZ_REGISTRY --only-show-errors
|
2022-08-25 10:02:24 +02:00
|
|
|
|
2023-05-01 21:56:04 +02:00
|
|
|
- name: Pull latest project image
|
|
|
|
env:
|
|
|
|
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
|
|
|
|
run: |
|
2024-07-09 15:24:25 +02:00
|
|
|
if [[ "${{ inputs.release_type }}" == "Dry Run" ]]; then
|
2023-08-14 16:56:54 +02:00
|
|
|
docker pull $_AZ_REGISTRY/$PROJECT_NAME:latest
|
2023-05-01 21:56:04 +02:00
|
|
|
else
|
2023-08-14 16:56:54 +02:00
|
|
|
docker pull $_AZ_REGISTRY/$PROJECT_NAME:$_BRANCH_NAME
|
2023-05-01 21:56:04 +02:00
|
|
|
fi
|
|
|
|
|
2022-08-25 10:02:24 +02:00
|
|
|
- name: Tag version and latest
|
|
|
|
env:
|
2022-11-18 20:39:01 +01:00
|
|
|
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
|
2022-08-25 10:02:24 +02:00
|
|
|
run: |
|
2024-07-09 15:24:25 +02:00
|
|
|
if [[ "${{ inputs.release_type }}" == "Dry Run" ]]; then
|
2023-08-14 16:56:54 +02:00
|
|
|
docker tag $_AZ_REGISTRY/$PROJECT_NAME:latest $_AZ_REGISTRY/$PROJECT_NAME:dryrun
|
2022-08-25 10:02:24 +02:00
|
|
|
else
|
2023-08-14 16:56:54 +02:00
|
|
|
docker tag $_AZ_REGISTRY/$PROJECT_NAME:$_BRANCH_NAME $_AZ_REGISTRY/$PROJECT_NAME:$_RELEASE_VERSION
|
|
|
|
docker tag $_AZ_REGISTRY/$PROJECT_NAME:$_BRANCH_NAME $_AZ_REGISTRY/$PROJECT_NAME:latest
|
2022-08-25 10:02:24 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Push version and latest image
|
|
|
|
env:
|
2022-11-18 20:39:01 +01:00
|
|
|
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
|
|
|
|
run: |
|
2024-07-09 15:24:25 +02:00
|
|
|
if [[ "${{ inputs.release_type }}" == "Dry Run" ]]; then
|
2023-08-14 16:56:54 +02:00
|
|
|
docker push $_AZ_REGISTRY/$PROJECT_NAME:dryrun
|
|
|
|
else
|
|
|
|
docker push $_AZ_REGISTRY/$PROJECT_NAME:$_RELEASE_VERSION
|
|
|
|
docker push $_AZ_REGISTRY/$PROJECT_NAME:latest
|
|
|
|
fi
|
2022-08-25 10:02:24 +02:00
|
|
|
|
|
|
|
- name: Log out of Docker
|
|
|
|
run: docker logout
|
|
|
|
|
2021-09-25 00:04:14 +02:00
|
|
|
release:
|
2024-01-23 19:24:52 +01:00
|
|
|
name: Create GitHub release
|
2022-11-18 20:39:01 +01:00
|
|
|
runs-on: ubuntu-22.04
|
2021-09-25 00:04:14 +02:00
|
|
|
needs:
|
|
|
|
- setup
|
|
|
|
- deploy
|
|
|
|
steps:
|
2024-01-23 19:24:52 +01:00
|
|
|
- name: Download latest release Docker stubs
|
2024-07-09 15:24:25 +02:00
|
|
|
if: ${{ inputs.release_type != 'Dry Run' }}
|
2023-11-08 19:08:15 +01:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@main
|
2021-09-25 00:04:14 +02:00
|
|
|
with:
|
|
|
|
workflow: build.yml
|
|
|
|
workflow_conclusion: success
|
2021-11-08 19:39:32 +01:00
|
|
|
branch: ${{ needs.setup.outputs.branch-name }}
|
2023-07-31 19:14:33 +02:00
|
|
|
artifacts: "docker-stub-US.zip,
|
|
|
|
docker-stub-US-sha256.txt,
|
|
|
|
docker-stub-EU.zip,
|
|
|
|
docker-stub-EU-sha256.txt,
|
2022-11-18 20:39:01 +01:00
|
|
|
swagger.json"
|
2022-07-20 18:47:19 +02:00
|
|
|
|
2024-01-23 19:24:52 +01:00
|
|
|
- name: Dry Run - Download latest release Docker stubs
|
2024-07-09 15:24:25 +02:00
|
|
|
if: ${{ inputs.release_type == 'Dry Run' }}
|
2023-11-08 19:08:15 +01:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@main
|
2022-07-19 21:00:57 +02:00
|
|
|
with:
|
|
|
|
workflow: build.yml
|
|
|
|
workflow_conclusion: success
|
2023-12-12 21:08:12 +01:00
|
|
|
branch: main
|
2023-07-31 19:14:33 +02:00
|
|
|
artifacts: "docker-stub-US.zip,
|
|
|
|
docker-stub-US-sha256.txt,
|
|
|
|
docker-stub-EU.zip,
|
|
|
|
docker-stub-EU-sha256.txt,
|
2022-11-18 20:39:01 +01:00
|
|
|
swagger.json"
|
2021-09-25 00:04:14 +02:00
|
|
|
|
|
|
|
- name: Create release
|
2024-07-09 15:24:25 +02:00
|
|
|
if: ${{ inputs.release_type != 'Dry Run' }}
|
2024-07-10 21:47:20 +02:00
|
|
|
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
|
2021-09-25 00:04:14 +02:00
|
|
|
with:
|
2023-07-31 19:14:33 +02:00
|
|
|
artifacts: "docker-stub-US.zip,
|
|
|
|
docker-stub-US-sha256.txt,
|
|
|
|
docker-stub-EU.zip,
|
|
|
|
docker-stub-EU-sha256.txt,
|
2022-11-18 20:39:01 +01:00
|
|
|
swagger.json"
|
2021-09-25 00:04:14 +02:00
|
|
|
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
|