|
47 | 47 | --repo "${REPO}" \ |
48 | 48 | --draft=false |
49 | 49 |
|
| 50 | + update-floating-tag: |
| 51 | + runs-on: 'ubuntu-latest' |
| 52 | + needs: |
| 53 | + - 'create-release' |
| 54 | + steps: |
| 55 | + - name: 'Update floating tag' |
| 56 | + uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea' # ratchet:actions/github-script@v7 |
| 57 | + env: |
| 58 | + RELEASE_VERSION: 'v${{ needs.create-release.outputs.version }}' |
| 59 | + REPO: '${{ github.repository }}' |
| 60 | + with: |
| 61 | + github-token: '${{ secrets.ACTIONS_BOT_TOKEN }}' |
| 62 | + script: |- |
| 63 | + const tag = process.env.RELEASE_VERSION; |
| 64 | + const major = tag.split(".")[0]; |
| 65 | + const githubActionsRef = `${process.env.REPO}@${major}` |
| 66 | +
|
| 67 | + // Try to update the ref first. If that fails, it probably does not |
| 68 | + // exist yet, and we should create it. |
| 69 | + try { |
| 70 | + await github.rest.git.updateRef({ |
| 71 | + owner: context.repo.owner, |
| 72 | + repo: context.repo.repo, |
| 73 | + ref: "tags/" + major, |
| 74 | + sha: context.sha, |
| 75 | + force: true, |
| 76 | + }); |
| 77 | + core.info(`Updated ${githubActionsRef} to ${context.sha} (${tag})`); |
| 78 | + } catch (err) { |
| 79 | + core.warning(`Failed to create tag ${major}: ${err}`); |
| 80 | +
|
| 81 | + await github.rest.git.createRef({ |
| 82 | + owner: context.repo.owner, |
| 83 | + repo: context.repo.repo, |
| 84 | + ref: "refs/tags/" + major, |
| 85 | + sha: context.sha, |
| 86 | + }); |
| 87 | + core.info(`Created ${githubActionsRef} at ${context.sha} (${tag})`); |
| 88 | + } |
| 89 | +
|
50 | 90 | cleanup-failed-release: |
51 | 91 | if: |- |
52 | 92 | ${{ always() && needs.create-release.outputs.created == 'true' && contains(fromJSON('["failure", "cancelled", "skipped"]'), needs.publish-release.result) }} |
|
0 commit comments