-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
chore: Add workflow to update major version tag on release #939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+68
−0
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
737e005
chore: Add workflow to update major version tag on release
DenverCoder1 a070165
Clean up comments in update-major-version-tag.yml
DenverCoder1 338cd38
Update checkout action to version 7
DenverCoder1 2ee29d5
Add concurrency and better escaping
DenverCoder1 4512073
Modify concurrency settings and update tag handling
DenverCoder1 cf1d6b2
Update concurrency to cancel in-progress runs
DenverCoder1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| name: Update Major Version Tag | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| concurrency: | ||
| group: update-major-version-tag | ||
| # assume linear tag progression (not updating v1 and v2 at the same time) | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| update-major-tag: | ||
| runs-on: ubuntu-latest | ||
| if: ${{ !github.event.release.draft }} | ||
|
DenverCoder1 marked this conversation as resolved.
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v7 | ||
| with: | ||
| fetch-depth: 0 | ||
| fetch-tags: true | ||
|
|
||
| - name: Determine major version tag | ||
| id: major | ||
| env: | ||
| RELEASE_TAG: ${{ github.event.release.tag_name }} | ||
| run: | | ||
| tag="$RELEASE_TAG" | ||
|
|
||
| # Expect semver-ish tags like v1.2.3 or 1.2.3 | ||
| if [[ "$tag" =~ ^v?([0-9]+)\.[0-9]+\.[0-9]+(-.*)?$ ]]; then | ||
| major_num="${BASH_REMATCH[1]}" | ||
| else | ||
| echo "::error::Tag '$tag' does not look like a semver tag (vX.Y.Z). Skipping." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Preserve the "v" prefix convention if the release tag used one. | ||
| if [[ "$tag" == v* ]]; then | ||
| major_tag="v${major_num}" | ||
| else | ||
| major_tag="${major_num}" | ||
| fi | ||
|
|
||
| echo "major_tag=${major_tag}" >> "$GITHUB_OUTPUT" | ||
| echo "Resolved major tag: ${major_tag} (from release tag ${tag})" | ||
|
|
||
| - name: Configure git | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| - name: Move (or create) major version tag | ||
| env: | ||
| MAJOR_TAG: ${{ steps.major.outputs.major_tag }} | ||
| RELEASE_TAG: ${{ github.event.release.tag_name }} | ||
| run: | | ||
| # target_commitish is usually a branch name for tags created via the UI/API, | ||
| # so resolve it to the actual commit the release's tag points at instead. | ||
| commit_sha="$(git rev-list -n 1 "$RELEASE_TAG")" | ||
|
|
||
| echo "Pointing ${MAJOR_TAG} at ${commit_sha} (release ${RELEASE_TAG})" | ||
|
|
||
| git tag -fa "$MAJOR_TAG" "$commit_sha" -m "Update ${MAJOR_TAG} to ${RELEASE_TAG}" | ||
| git push origin "refs/tags/${MAJOR_TAG}" --force | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.