|
| 1 | +name: release |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + tags: |
| 7 | + - "v*.*.*" |
| 8 | + pull_request: |
| 9 | + types: |
| 10 | + - labeled |
| 11 | + |
| 12 | +jobs: |
| 13 | + release: |
| 14 | + if: github.event.action != 'labeled' |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 18 | + |
| 19 | + # Bump version on merging Pull Requests with specific labels. |
| 20 | + # (bump:major,bump:minor,bump:patch) |
| 21 | + - id: bumpr |
| 22 | + if: "!startsWith(github.ref, 'refs/tags/')" |
| 23 | + uses: haya14busa/action-bumpr@78ab5a104d20896c9c9122c64221b3aecf1a8cbb # v1.10.0 |
| 24 | + |
| 25 | + # Update corresponding major and minor tag. |
| 26 | + # e.g. Update v1 and v1.2 when releasing v1.2.3 |
| 27 | + - uses: haya14busa/action-update-semver@fb48464b2438ae82cc78237be61afb4f461265a1 # v1.2.1 |
| 28 | + if: "!steps.bumpr.outputs.skip" |
| 29 | + with: |
| 30 | + tag: ${{ steps.bumpr.outputs.next_version }} |
| 31 | + |
| 32 | + # Get tag name. |
| 33 | + - id: tag |
| 34 | + uses: haya14busa/action-cond@94f77f7a80cd666cb3155084e428254fea4281fd # v1.2.1 |
| 35 | + with: |
| 36 | + cond: "${{ startsWith(github.ref, 'refs/tags/') }}" |
| 37 | + if_true: ${{ github.ref }} |
| 38 | + if_false: ${{ steps.bumpr.outputs.next_version }} |
| 39 | + |
| 40 | + # Create release |
| 41 | + - if: "steps.tag.outputs.value != ''" |
| 42 | + env: |
| 43 | + TAG_NAME: ${{ steps.tag.outputs.value }} |
| 44 | + BODY: ${{ steps.bumpr.outputs.message }} |
| 45 | + # This token is provided by Actions, you do not need to create your own token |
| 46 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + run: | |
| 48 | + gh release create "${TAG_NAME}" -t "Release ${TAG_NAME/refs\/tags\//}" --notes "${BODY}" |
| 49 | +
|
| 50 | + release-check: |
| 51 | + if: github.event.action == 'labeled' |
| 52 | + runs-on: ubuntu-latest |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 55 | + - name: Post bumpr status comment |
| 56 | + uses: haya14busa/action-bumpr@78ab5a104d20896c9c9122c64221b3aecf1a8cbb # v1.10.0 |
0 commit comments