|
| 1 | +name: 'New Release' |
| 2 | +run-name: 'Release ${{ inputs.version_number }} (skip tests: ${{ inputs.skip_tests }}, use existing tag: ${{ inputs.use_existing_tag}})' |
| 3 | + |
| 4 | +# Used for creating a new release. This workflow will run qa acceptance tests, create a new tag, and generate the release with GoReleaser. |
| 5 | +on: |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + version_number: |
| 9 | + description: 'Version number (e.g., v1.0.0, v1.0.0-pre, v1.0.0-pre1)' |
| 10 | + required: true |
| 11 | + skip_tests: |
| 12 | + description: 'Set value to `true` to skip tests, default is `false`' |
| 13 | + default: 'false' |
| 14 | + use_existing_tag: |
| 15 | + description: 'Set value to `true` to use an existing tag for the release process, default is `false`' |
| 16 | + default: 'false' |
| 17 | + |
| 18 | +jobs: |
| 19 | + create-tag: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + if: >- |
| 22 | + !cancelled() |
| 23 | + && inputs.use_existing_tag == 'false' |
| 24 | + steps: |
| 25 | + - name: Validation of version format |
| 26 | + run: | |
| 27 | + echo "${{ inputs.version_number }}" | grep -P '^v\d+\.\d+\.\d+(-pre[A-Za-z0-9-]*)?$' |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 |
| 30 | + - name: Get the latest commit SHA |
| 31 | + id: get-sha |
| 32 | + run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" |
| 33 | + - name: Create release tag |
| 34 | + uses: rickstaa/action-create-tag@a1c7777fcb2fee4f19b0f283ba888afa11678b72 |
| 35 | + with: |
| 36 | + tag: ${{ inputs.version_number }} |
| 37 | + commit_sha: ${{ steps.get-sha.outputs.sha }} |
| 38 | + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} |
| 39 | + gpg_passphrase: ${{ secrets.PASSPHRASE }} |
| 40 | + - name: Create Issue |
| 41 | + if: ${{ failure() }} |
| 42 | + uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd |
| 43 | + env: |
| 44 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + with: |
| 46 | + labels: failed-release |
| 47 | + title: "Releasing openapicli v${{ inputs.version_number }} failed at the tag creation step :scream_cat:" |
| 48 | + body: See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 49 | + |
| 50 | + run-tests: |
| 51 | + needs: [ create-tag ] |
| 52 | + if: >- |
| 53 | + !cancelled() |
| 54 | + && !contains(needs.*.result, 'failure') |
| 55 | + && inputs.skip_tests == 'false' |
| 56 | + secrets: inherit |
| 57 | + uses: ./.github/workflows/code-health-tools.yml |
| 58 | + |
| 59 | + release: |
| 60 | + runs-on: ubuntu-latest |
| 61 | + needs: [ run-tests ] |
| 62 | + # Release is skipped if there are failures in previous steps |
| 63 | + if: >- |
| 64 | + !cancelled() |
| 65 | + && !contains(needs.*.result, 'failure') |
| 66 | + steps: |
| 67 | + - name: Checkout |
| 68 | + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 |
| 69 | + with: |
| 70 | + ref: ${{ inputs.version_number }} |
| 71 | + - name: Set up Go |
| 72 | + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 |
| 73 | + with: |
| 74 | + go-version-file: 'tools/cli/go.mod' |
| 75 | + - name: Run GoReleaser |
| 76 | + uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 |
| 77 | + with: |
| 78 | + version: latest |
| 79 | + workdir: tools/cli |
| 80 | + args: release --rm-dist |
| 81 | + env: |
| 82 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + - name: Create Issue |
| 84 | + if: ${{ failure() }} |
| 85 | + uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd |
| 86 | + env: |
| 87 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 88 | + with: |
| 89 | + labels: failed-release |
| 90 | + title: "Releasing openapicli v${{ inputs.version_number }} failed at the goreleaser step :scream_cat:" |
| 91 | + body: See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |
0 commit comments