name: Release run-name: Release ${{ inputs.release_type }} on: workflow_dispatch: inputs: release_type: description: "Release Options" required: true default: "Initial Release" type: choice options: - Initial Release - Redeploy - Dry Run env: _AZ_REGISTRY: "bitwardenprod.azurecr.io" permissions: contents: read jobs: setup: name: Setup runs-on: ubuntu-22.04 outputs: release_version: ${{ steps.version.outputs.version }} branch-name: ${{ steps.branch.outputs.branch-name }} last_release_tag: ${{ steps.get_release_info.outputs.last_release_tag }} steps: - name: Branch check if: ${{ 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: Check out repo uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: fetch-depth: 0 persist-credentials: false - name: Check release version id: version uses: bitwarden/gh-actions/release-version-check@main with: release-type: ${{ inputs.release_type }} project-type: dotnet file: Directory.Build.props - name: Get branch name id: branch run: | BRANCH_NAME=$(basename "${GITHUB_REF}") echo "branch-name=$BRANCH_NAME" >> "$GITHUB_OUTPUT" - name: Get version info from run logs and set release tag name id: get_release_info run: | last_release_tag=$(git tag -l --sort=-authordate | head -n 1) echo "🔖 Last release tag: $last_release_tag" echo "last_release_tag=$last_release_tag" >> "$GITHUB_OUTPUT" release: name: Create GitHub release runs-on: ubuntu-22.04 needs: setup permissions: contents: write steps: - name: Download latest release Docker stubs if: ${{ inputs.release_type != 'Dry Run' }} uses: bitwarden/gh-actions/download-artifacts@main with: workflow: build.yml workflow_conclusion: success branch: ${{ needs.setup.outputs.branch-name }} artifacts: "docker-stub-US.zip, docker-stub-EU.zip, swagger.json" - name: Dry Run - Download latest release Docker stubs if: ${{ inputs.release_type == 'Dry Run' }} uses: bitwarden/gh-actions/download-artifacts@main with: workflow: build.yml workflow_conclusion: success branch: main artifacts: "docker-stub-US.zip, docker-stub-EU.zip, swagger.json" - name: Create release if: ${{ inputs.release_type != 'Dry Run' }} uses: ncipollo/release-action@b7eabc95ff50cbeeedec83973935c8f306dfcd0b # v1.20.0 env: RELEASE_VERSION: ${{ needs.setup.outputs.release_version }} LAST_RELEASE_TAG: ${{ needs.setup.outputs.last_release_tag }} with: artifacts: "docker-stub-US.zip, docker-stub-EU.zip, swagger.json" commit: ${{ github.sha }} tag: "v${{ env.RELEASE_VERSION }}" name: "Version ${{ env.RELEASE_VERSION }}" body: "" token: ${{ secrets.GITHUB_TOKEN }} generateReleaseNotes: true generateReleaseNotesPreviousTag: ${{ env.LAST_RELEASE_TAG }} draft: true