|
1 | 1 | name: 'Gitflow: Auto prepare release' |
2 | 2 | on: |
3 | | - workflow_dispatch: |
4 | | - inputs: |
5 | | - version: |
6 | | - description: Version to release (or "auto") |
7 | | - required: false |
8 | | - force: |
9 | | - description: Force a release even when there are release-blockers |
10 | | - required: false |
11 | | - merge_target: |
12 | | - description: Target branch to merge into |
13 | | - required: false |
| 3 | + pull_request: |
| 4 | + types: |
| 5 | + - closed |
| 6 | + branches: |
| 7 | + - master |
| 8 | + |
14 | 9 | permissions: |
15 | 10 | contents: write |
16 | 11 | pull-requests: write |
17 | 12 |
|
| 13 | +# This workflow triggers a release when merging a branch with the pattern `prepare-release/VERSION` into master. |
18 | 14 | jobs: |
19 | 15 | release: |
20 | | - runs-on: ubuntu-latest |
21 | | - name: Release a new version |
| 16 | + runs-on: ubuntu-24.04 |
| 17 | + name: 'Prepare a new version' |
22 | 18 | steps: |
23 | | - - name: Get auth token |
24 | | - id: token |
25 | | - uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v2 |
26 | | - with: |
27 | | - app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }} |
28 | | - private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }} |
29 | | - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v2 |
30 | | - with: |
31 | | - token: ${{ steps.token.outputs.token }} |
32 | | - fetch-depth: 0 |
33 | | - - name: Prepare release |
34 | | - uses: getsentry/craft@39ee616a6a58dc64797feecb145d66770492b66c # v2 |
35 | | - env: |
36 | | - GITHUB_TOKEN: ${{ steps.token.outputs.token }} |
37 | | - with: |
38 | | - version: ${{ inputs.version }} |
39 | | - force: ${{ inputs.force }} |
40 | | - merge_target: ${{ inputs.merge_target }} |
41 | | - craft_config_from_merge_target: 'true' |
| 19 | + - name: Get auth token |
| 20 | + id: token |
| 21 | + uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1 |
| 22 | + with: |
| 23 | + app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }} |
| 24 | + private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }} |
| 25 | + |
| 26 | + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 27 | + with: |
| 28 | + token: ${{ steps.token.outputs.token }} |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + # https://github.com/actions-ecosystem/action-regex-match |
| 32 | + - uses: actions-ecosystem/action-regex-match@v2 |
| 33 | + id: version-regex |
| 34 | + with: |
| 35 | + # Parse version from head branch |
| 36 | + text: ${{ github.head_ref }} |
| 37 | + # match: prepare-release/xx.xx.xx |
| 38 | + regex: '^prepare-release\/(\d+\.\d+\.\d+)(?:-(alpha|beta|rc)\.\d+)?$' |
| 39 | + |
| 40 | + - name: Extract version |
| 41 | + id: get_version |
| 42 | + run: | |
| 43 | + version=${{ steps.version-regex.outputs.match }} |
| 44 | + version=${version/'prepare-release/'/''} |
| 45 | + echo "version=$version" >> $GITHUB_OUTPUT |
| 46 | +
|
| 47 | + - name: Set up Node |
| 48 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 49 | + with: |
| 50 | + node-version-file: 'package.json' |
| 51 | + |
| 52 | + - name: Prepare release |
| 53 | + uses: getsentry/craft@39ee616a6a58dc64797feecb145d66770492b66c # v2 |
| 54 | + if: >- |
| 55 | + github.event.pull_request.merged == true && |
| 56 | + steps.version-regex.outputs.match != '' && |
| 57 | + steps.get_version.outputs.version != '' |
| 58 | + env: |
| 59 | + GITHUB_TOKEN: ${{ steps.token.outputs.token }} |
| 60 | + with: |
| 61 | + version: ${{ steps.get_version.outputs.version }} |
| 62 | + force: false |
| 63 | + merge_target: master |
| 64 | + craft_config_from_merge_target: 'true' |
0 commit comments