Repository navigation
feat(ENG-14534): pin the CLI version and release on each CLI bump #49
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
cloudsmith-iduffy
merged 5 commits into
master
from
eng-14534-auto-release-cloudsmith-cli-action-on-every-cloudsmith-cli
Oct 27, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8e82b9c
feat(ENG-14534): pin the CLI version and release on each CLI bump
cloudsmith-iduffy 18ccc86
fix(ENG-14534): keep queued releases and never pin an older CLI
cloudsmith-iduffy 4557d8e
fix: pin initial action release to CLI 1.29.0
BartoszBlizniak e4d7ae9
feat(ENG-14534): open the CLI bump pull request from this repository
cloudsmith-iduffy f27b5fa
fix(ENG-14534): pin CLI 1.30.0 and the merged open-cli-bump-pr action
cloudsmith-iduffy 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,37 @@ | ||
| name: Bump Cloudsmith CLI | ||
|
|
||
| # Opens a pull request that pins the default cli-version to a Cloudsmith CLI | ||
| # release. The CLI release workflow sends the cloudsmith-cli-release event. | ||
| # Run the workflow by hand to pin a specific version. | ||
| on: | ||
| repository_dispatch: | ||
| types: | ||
| - cloudsmith-cli-release | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: The Cloudsmith CLI version to pin, for example 1.29.1. | ||
| required: true | ||
|
|
||
| permissions: {} | ||
|
|
||
| concurrency: | ||
| group: bump-cli-version | ||
| cancel-in-progress: false | ||
| queue: max | ||
|
|
||
| jobs: | ||
| bump: | ||
| name: Open the bump pull request | ||
| permissions: | ||
| contents: read | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| steps: | ||
| - name: Open the bump pull request | ||
| uses: cloudsmith-io/cloudsmith-cli/.github/actions/open-cli-bump-pr@34f5fd967daaab552a66dd9a890d550c47a39b0c # master | ||
| with: | ||
| version: ${{ github.event.client_payload.version || inputs.version }} | ||
| bump-command: bash scripts/bump-cli-version.sh "$VERSION" | ||
| token: ${{ secrets.DOWNSTREAM_RELEASE_PUSH_TOKEN }} | ||
| ssh-signing-key: ${{ secrets.CLOUDSMITH_BOT_SSH_KEY }} |
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
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
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
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,62 @@ | ||
| #!/usr/bin/env bash | ||
|
cloudsmith-iduffy marked this conversation as resolved.
Resolved
|
||
| # Pins the default cli-version in action.yml to a new Cloudsmith CLI release | ||
| # and records the change as a release of the action in CHANGELOG.md. The | ||
| # release is a patch release, or a minor release that also includes the | ||
| # entries under [Unreleased] when there are any. | ||
| # Prints the new action version. Prints nothing when action.yml already pins | ||
| # that version or a newer one. | ||
| # Usage: scripts/bump-cli-version.sh CLI_VERSION | ||
| set -euo pipefail | ||
|
|
||
| cli_version="${1:-}" | ||
| [[ "$cli_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] \ | ||
| || { echo "usage: $0 MAJOR.MINOR.PATCH" >&2; exit 1; } | ||
|
|
||
| pinned_version="$(awk ' | ||
| /^ cli-version:/ { in_cli_version = 1 } | ||
| in_cli_version && /^ default:/ { gsub(/"/, "", $2); print $2; exit } | ||
| ' action.yml)" | ||
| [[ -n "$pinned_version" ]] || { echo "no cli-version default in action.yml" >&2; exit 1; } | ||
| newest_version="$(printf '%s\n' "$pinned_version" "$cli_version" | sort -V | tail -n 1)" | ||
| if [[ "$pinned_version" == "$newest_version" ]]; then | ||
| echo "action.yml already pins Cloudsmith CLI $pinned_version" >&2 | ||
| exit 0 | ||
| fi | ||
|
|
||
| released_version="$(sed -n 's/^## \[\([0-9]*\.[0-9]*\.[0-9]*\)\].*/\1/p' CHANGELOG.md | head -n 1)" | ||
| [[ -n "$released_version" ]] || { echo "no released version in CHANGELOG.md" >&2; exit 1; } | ||
| unreleased_changes="$(awk ' | ||
| /^## \[/ { in_unreleased = ($0 == "## [Unreleased]"); next } | ||
| in_unreleased && $0 != "" && $0 != "---" | ||
| ' CHANGELOG.md)" | ||
| IFS=. read -r major minor patch <<< "$released_version" | ||
| if [[ -n "$unreleased_changes" ]]; then | ||
| action_version="$major.$(( minor + 1 )).0" | ||
| else | ||
| action_version="$major.$minor.$(( patch + 1 ))" | ||
| fi | ||
|
|
||
| awk -v cli_version="$cli_version" ' | ||
| /^ cli-version:/ { in_cli_version = 1 } | ||
| in_cli_version && /^ default:/ { sub(/".*"/, "\"" cli_version "\""); in_cli_version = 0 } | ||
| { print } | ||
| ' action.yml > action.yml.new | ||
| mv action.yml.new action.yml | ||
|
|
||
| awk -v action_version="$action_version" -v cli_version="$cli_version" -v today="$(date -u +%Y-%m-%d)" ' | ||
| inserted && $0 != "" { print "" } | ||
| { inserted = 0; print } | ||
| previous == "## [Unreleased]" && $0 == "---" { | ||
| inserted = 1 | ||
| print "" | ||
| print "## [" action_version "] - " today | ||
| print "---" | ||
| print "### Changed" | ||
| print "" | ||
| print "- Pin the default `cli-version` to Cloudsmith CLI " cli_version "." | ||
| } | ||
| { previous = $0 } | ||
| ' CHANGELOG.md > CHANGELOG.md.new | ||
| mv CHANGELOG.md.new CHANGELOG.md | ||
|
|
||
| echo "$action_version" | ||
Oops, something went wrong.
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.