Skip to content

Commit f91d0e7

Browse files
Copilotniwo
andauthored
Enforce version bump before release build
Agent-Logs-Url: https://github.com/niwo/cloudstack_client/sessions/6e43498d-ff8d-4991-82bf-c21abfa5113b Co-authored-by: niwo <57439+niwo@users.noreply.github.com>
1 parent 8a574fa commit f91d0e7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

.github/workflows/release.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ jobs:
2525
- name: Run tests
2626
run: bundle exec rake test
2727

28+
- name: Ensure version is bumped
29+
run: |
30+
CURRENT_VERSION="$(ruby -Ilib -e "require 'cloudstack_client/version'; puts CloudstackClient::VERSION")"
31+
LATEST_JSON="$(curl -fsSL https://rubygems.org/api/v1/versions/cloudstack_client/latest.json || true)"
32+
if [ -n "$LATEST_JSON" ]; then
33+
LATEST_VERSION="$(printf '%s' "$LATEST_JSON" | ruby -rjson -e "puts JSON.parse(STDIN.read)['version']")"
34+
ruby -e "require 'rubygems/version'; current = Gem::Version.new('$CURRENT_VERSION'); latest = Gem::Version.new('$LATEST_VERSION'); abort(\"Version must be bumped before building (current=#{current}, latest=#{latest})\") unless current > latest"
35+
fi
36+
2837
- name: Build gem
2938
run: bundle exec rake build
3039

@@ -43,9 +52,6 @@ jobs:
4352
ruby-version: '3.2'
4453
bundler-cache: true
4554

46-
- name: Build gem
47-
run: bundle exec rake build
48-
4955
- name: Publish gem to RubyGems
5056
uses: rubygems/release-gem@v1
5157
with:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ To enable publishing, add this repository secret:
175175

176176
- `RUBYGEMS_AUTH_TOKEN`: your RubyGems API key with push permissions
177177

178-
The release workflow uses the `rubygems` environment and pushes the built gem automatically.
178+
The release workflow checks that `CloudstackClient::VERSION` is greater than the latest version on RubyGems before building, then uses the `rubygems` environment to publish.
179179

180180
## References
181181

0 commit comments

Comments
 (0)