Skip to content

Commit 29c6d38

Browse files
authored
Also update floating tags on release (#44)
GitHub changed the immutable actions program, and it no longer computes floating tags.
1 parent 145cb9a commit 29c6d38

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,46 @@ jobs:
4747
--repo "${REPO}" \
4848
--draft=false
4949
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+
5090
cleanup-failed-release:
5191
if: |-
5292
${{ always() && needs.create-release.outputs.created == 'true' && contains(fromJSON('["failure", "cancelled", "skipped"]'), needs.publish-release.result) }}

0 commit comments

Comments
 (0)