Skip to content

Commit

Permalink
Add workflow for floating the v1 tag to the latest release
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jeffwidman committed May 18, 2023
1 parent 86de090 commit 160adf6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ jobs:
echo " > https://github.com/${{ github.repository }}/releases/tag/untagged-XXXXXX" >> $GITHUB_STEP_SUMMARY
echo " # Use the generated URL to review/edit the release notes." >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "Once the release is tagged, move the floating \`v1\` tag to point at this release." >> $GITHUB_STEP_SUMMARY
echo "Once the release is tagged, another GitHub Action workflow automatically moves the floating \`v1\` tag to point at this release." >> $GITHUB_STEP_SUMMARY
32 changes: 32 additions & 0 deletions .github/workflows/release-move-tracking-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release - Move Tracking Tag

on:
release:
types: [published]

jobs:
Move-Tracking-Tag-To-Latest-Release:
runs-on: ubuntu-latest

# TODO: Should we filter this job...? Ie, what if the new release isn't a
# version? Or if it's an older patch version rather than a newer one?
# The logic gets tricky quickly... so IMO either we assume every new release
# is newest and always bump on release publish, or we switch to letting letting the
# release author decide by switching this to using `workflow_dispatch` and
# requiring a human to manually run this workflow after they tag a release.
# Safer, but more of a hassle and also an unnecessary precaution 99% of the time.

steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.DEPENDABOT_AUTOMATION_PAT }}

- name: Move the tracking tag
run: git tag -f v1

- name: Push the new tag value back to the repo
run: git push -f origin refs/tags/v1

- name: Set summary
run: |
echo ":rocket: Successfully moved the \`v1\` tag to point at release: ${{ github.event.release.name }} with SHA: \`$GITHUB_SHA\`." >> $GITHUB_STEP_SUMMARY
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,7 @@ jobs:
1. Run the action to generate a version bump PR.
2. Merge the PR.
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.
4. Update the `v1` tracking tag to point to the new version
```bash
git fetch --all --tags
git checkout v1.x.x # Check out the release tag
git tag -f v1 # Force update the tracking tag
git push -f --tags
```
4. Once the release is tagged, another GitHub Action workflow automatically moves the `v1` tracking tag to point to the new version.

</p>
</details>

0 comments on commit 160adf6

Please sign in to comment.