-
Notifications
You must be signed in to change notification settings - Fork 144
[ci] Make the release workflows backport-safe #6854
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
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cfb0e7b
[ci] Make the release workflows backport-safe
gz 59c4af3
[ci] Extract the is-newest-version check into a composite action
gz f86d601
[ci] Address review: fail closed and filter tags strictly
gz 255e61f
[ci] Drop the action-pin rationale comment
gz 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,44 @@ | ||
| name: Is newest version | ||
| description: > | ||
| Decide whether the version being released is the newest of the repository's | ||
| v* tags, so release workflows can keep floating pointers (the GitHub | ||
| "latest" marker, :latest image tags, live docs and sandboxes) on the newest | ||
| version when shipping a backport from an old release line. Requires a | ||
| checkout with tags fetched; the new release's own tag must not exist yet. | ||
|
|
||
| inputs: | ||
| version: | ||
| description: The version being released, without the leading v. | ||
| required: true | ||
|
|
||
| outputs: | ||
| is_newest: | ||
| description: '"true" when the version is >= every existing v* tag, else "false".' | ||
| value: ${{ steps.compare.outputs.is_newest }} | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - id: compare | ||
| shell: bash | ||
| env: | ||
| VERSION: ${{ inputs.version }} | ||
| run: | | ||
| # Strict X.Y.Z filter: a stray non-numeric tag (vnext) or a | ||
| # pre-release tag (v1.2.3-rc1) would otherwise outrank real versions | ||
| # under sort -V and silently flip a normal release to a backport. | ||
| highest=$(git tag --list 'v[0-9]*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sed 's/^v//' | sort -V | tail -1 || true) | ||
| # Fail closed: an empty tag list on a release repo means the checkout | ||
| # did not fetch tags. Guessing "newest" here would move every | ||
| # floating pointer onto whatever is being released. | ||
| if [ -z "$highest" ]; then | ||
| echo "::error::no vX.Y.Z tags visible; was the checkout made with fetch-tags?" | ||
| exit 1 | ||
| fi | ||
| if [ "$(printf '%s\n%s\n' "$highest" "$VERSION" | sort -V | tail -1)" = "$VERSION" ]; then | ||
| echo "is_newest=true" >> "$GITHUB_OUTPUT" | ||
| echo "v$VERSION is the newest version (highest existing tag: v$highest)" | ||
| else | ||
| echo "is_newest=false" >> "$GITHUB_OUTPUT" | ||
| echo "v$VERSION is a backport (highest existing tag: v$highest); floating pointers stay put" | ||
| fi |
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
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
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.