Skip to content

Commit a2a3a43

Browse files
authored
Add workflow for floating the v1 tag to the latest release (#361)
This adds a workflow for floating the `v1` tag to the latest release. This way we reduce the chance of someone fat-fingering the necessary `git` commands.
1 parent 6c5b8c2 commit a2a3a43

File tree

3 files changed

+45
-8
lines changed

3 files changed

+45
-8
lines changed

.github/workflows/release-bump-version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ jobs:
8080
echo " > https://github.com/${{ github.repository }}/releases/tag/untagged-XXXXXX" >> $GITHUB_STEP_SUMMARY
8181
echo " # Use the generated URL to review/edit the release notes." >> $GITHUB_STEP_SUMMARY
8282
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
83-
echo "Once the release is tagged, move the floating \`v1\` tag to point at this release." >> $GITHUB_STEP_SUMMARY
83+
echo "Once the release is tagged, another GitHub Action workflow automatically moves the floating \`v1\` tag to point at this release." >> $GITHUB_STEP_SUMMARY
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Release - Move Tracking Tag
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
Move-Tracking-Tag-To-Latest-Release:
9+
runs-on: ubuntu-latest
10+
11+
# We have a choice - defensiveness vs convenience:
12+
# 1. Be defensive by filtering if the release doesn't look like a normal
13+
# version, or if it's a patch release to an older version... the logic
14+
# gets tricky quickly. Easiest way to be 100% sure is stop running this
15+
# on `release` and instead require a human to manually run this workflow
16+
# after they tag a release.
17+
# 2. Minimize the upfront hassle by assuming every release is a normal
18+
# version release and the latest one. Today both are resoundingly true
19+
# as this repo isn't that active/busy, so we don't worry about
20+
# multiple release branches, pre-releases, etc.
21+
#
22+
# For now I've gone with option 2, as it is much more convenient and if we
23+
# typo something during a release it's easy to fix by immediately tagging a
24+
# correct release. And if we don't notice the typo, well, in that case
25+
# requiring a human to manually run the workflow wouldn't have protected us
26+
# either, we'd have had to filter by only things that look like versions.
27+
# Anyway, for now this is good enough, and if it gets to be a problem down
28+
# the road we increase the robustness of this.
29+
30+
steps:
31+
- uses: actions/checkout@v3
32+
with:
33+
token: ${{ secrets.DEPENDABOT_AUTOMATION_PAT }}
34+
35+
- name: Move the tracking tag
36+
run: git tag -f v1
37+
38+
- name: Push the new tag value back to the repo
39+
run: git push -f origin refs/tags/v1
40+
41+
- name: Set summary
42+
run: |
43+
echo ":rocket: Successfully moved the \`v1\` tag to point at release: ${{ github.event.release.name }} with SHA: \`$GITHUB_SHA\`." >> $GITHUB_STEP_SUMMARY

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,7 @@ jobs:
200200
1. Run the action to generate a version bump PR.
201201
2. Merge the PR.
202202
3. Tag that merge commit as a new release using the format `v1.2.3`. The job summary contains a URL pre-populated with the correct version for the title and tag.
203-
4. Update the `v1` tracking tag to point to the new version
204-
```bash
205-
git fetch --all --tags
206-
git checkout v1.x.x # Check out the release tag
207-
git tag -f v1 # Force update the tracking tag
208-
git push -f --tags
209-
```
203+
4. Once the release is tagged, another GitHub Action workflow automatically moves the `v1` tracking tag to point to the new version.
210204

211205
</p>
212206
</details>

0 commit comments

Comments
 (0)