Skip to content

Commit 85f779b

Browse files
committed
Version 1.6.12 using cloudstack_client 1.6.0
1 parent c7fe3cd commit 85f779b

6 files changed

Lines changed: 194 additions & 8 deletions

File tree

.github/workflows/release.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Release gem
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
paths:
10+
- 'lib/cloudstack-cli/version.rb'
11+
workflow_dispatch:
12+
inputs:
13+
tag:
14+
description: 'Existing git tag to release, for example v1.6.12'
15+
required: true
16+
type: string
17+
18+
permissions:
19+
contents: write
20+
21+
concurrency:
22+
group: release-${{ github.event.inputs.tag || github.ref_name || github.sha }}
23+
cancel-in-progress: false
24+
25+
jobs:
26+
release:
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Check out repository
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Resolve release metadata
36+
id: release
37+
run: |
38+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
39+
RELEASE_TAG='${{ github.event.inputs.tag }}'
40+
git fetch --force --tags origin
41+
git checkout "$RELEASE_TAG"
42+
VERSION="$(ruby -e 'require "./lib/cloudstack-cli/version"; print CloudstackCli::VERSION')"
43+
elif [ "$GITHUB_REF_TYPE" = "tag" ]; then
44+
RELEASE_TAG="$GITHUB_REF_NAME"
45+
VERSION="$(ruby -e 'require "./lib/cloudstack-cli/version"; print CloudstackCli::VERSION')"
46+
else
47+
VERSION="$(ruby -e 'require "./lib/cloudstack-cli/version"; print CloudstackCli::VERSION')"
48+
RELEASE_TAG="v$VERSION"
49+
fi
50+
51+
echo "release_tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
52+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
53+
54+
- name: Set up Ruby
55+
uses: ruby/setup-ruby@v1
56+
with:
57+
bundler-cache: true
58+
59+
- name: Verify tag matches gem version
60+
run: |
61+
VERSION='${{ steps.release.outputs.version }}'
62+
TAG_VERSION='${{ steps.release.outputs.release_tag }}'
63+
TAG_VERSION="${TAG_VERSION#v}"
64+
65+
if [ "$TAG_VERSION" != "$VERSION" ]; then
66+
echo "Tag version ($TAG_VERSION) does not match gem version ($VERSION)."
67+
exit 1
68+
fi
69+
70+
- name: Create release tag from main
71+
if: github.ref_type == 'branch'
72+
run: |
73+
RELEASE_TAG='${{ steps.release.outputs.release_tag }}'
74+
75+
git fetch --force --tags origin
76+
77+
if git rev-parse "$RELEASE_TAG" >/dev/null 2>&1; then
78+
TAG_SHA="$(git rev-list -n 1 "$RELEASE_TAG")"
79+
80+
if [ "$TAG_SHA" != "$GITHUB_SHA" ]; then
81+
echo "Tag $RELEASE_TAG already exists on $TAG_SHA, expected $GITHUB_SHA."
82+
exit 1
83+
fi
84+
else
85+
git config user.name 'github-actions[bot]'
86+
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
87+
git tag -a "$RELEASE_TAG" -m "Release $RELEASE_TAG"
88+
git push origin "$RELEASE_TAG"
89+
fi
90+
91+
git checkout "$RELEASE_TAG"
92+
93+
- name: Run test suite
94+
run: bundle exec rake test
95+
96+
- name: Build gem
97+
run: gem build cloudstack-cli.gemspec
98+
99+
- name: Check whether version already exists on RubyGems
100+
id: rubygems
101+
env:
102+
RELEASE_VERSION: ${{ steps.release.outputs.version }}
103+
run: |
104+
if ruby -rjson -ropen-uri -e 'versions = JSON.parse(URI.open("https://rubygems.org/api/v1/versions/cloudstack-cli.json", &:read)); exit(versions.any? { |item| item["number"] == ENV.fetch("RELEASE_VERSION") } ? 0 : 1)'; then
105+
echo "Version $RELEASE_VERSION already exists on RubyGems."
106+
echo 'exists=true' >> "$GITHUB_OUTPUT"
107+
else
108+
echo 'exists=false' >> "$GITHUB_OUTPUT"
109+
fi
110+
111+
- name: Publish to RubyGems
112+
if: steps.rubygems.outputs.exists != 'true'
113+
env:
114+
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
115+
run: |
116+
if [ -z "$GEM_HOST_API_KEY" ]; then
117+
echo 'Missing RUBYGEMS_API_KEY secret.'
118+
exit 1
119+
fi
120+
121+
gem push "cloudstack-cli-${{ steps.release.outputs.version }}.gem"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Update bundle
2+
3+
on:
4+
schedule:
5+
- cron: '0 6 1 * *'
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
update:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Check out repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Ruby
21+
uses: ruby/setup-ruby@v1
22+
with:
23+
bundler-cache: true
24+
25+
- name: Update bundle lockfile
26+
run: bundle update
27+
28+
- name: Run test suite
29+
run: bundle exec rake test
30+
31+
- name: Create pull request
32+
uses: peter-evans/create-pull-request@v7
33+
with:
34+
branch: github-actions/update-bundle
35+
commit-message: 'chore: update bundle lockfile'
36+
title: 'chore: update bundle lockfile'
37+
body: |
38+
Automated dependency refresh for the bundle lockfile.
39+
40+
- Runs `bundle update`
41+
- Verifies the test suite with `bundle exec rake test`
42+
delete-branch: true

Gemfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
PATH
22
remote: .
33
specs:
4-
cloudstack-cli (1.6.10)
5-
cloudstack_client (~> 1.5.10)
4+
cloudstack-cli (1.6.12)
5+
cloudstack_client (~> 1.6.0)
66
thor (~> 1.1.0)
77

88
GEM
99
remote: https://rubygems.org/
1010
specs:
11-
cloudstack_client (1.5.11)
12-
minitest (5.26.1)
13-
rake (13.3.1)
11+
cloudstack_client (1.6.0)
12+
minitest (5.27.0)
13+
rake (13.4.2)
1414
thor (1.1.0)
1515

1616
PLATFORMS
@@ -22,4 +22,4 @@ DEPENDENCIES
2222
rake (~> 13.0)
2323

2424
BUNDLED WITH
25-
2.5.22
25+
2.6.9

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,29 @@ $ cloudstack-cli router list --project Demo --status running --redundant-state B
197197
3. Currently you need to create a isolated network named "test-network" manually on the simulator
198198
4. Run `bundle exec rake test`
199199

200+
## Automation
201+
202+
GitHub Actions are configured for dependency maintenance and RubyGems releases.
203+
204+
### Bundle updates
205+
206+
The `Update bundle` workflow runs monthly and can also be started manually from the Actions tab. It runs `bundle update`, verifies the test suite, and opens a pull request with the updated lockfile.
207+
208+
### Releases
209+
210+
The `Release gem` workflow publishes to RubyGems when a tag like `v1.6.12` is pushed. It also runs when `lib/cloudstack-cli/version.rb` changes on `main`, creates the matching tag automatically, and publishes that version. You can still trigger it manually for an existing tag from the Actions tab.
211+
212+
Add the `RUBYGEMS_API_KEY` repository secret before using the release workflow.
213+
214+
Typical release flow:
215+
216+
1. Update `lib/cloudstack-cli/version.rb`.
217+
2. Commit and push the version change.
218+
3. Push to `main`.
219+
4. GitHub Actions creates the matching tag, verifies the tag matches the gem version, and pushes the release to RubyGems.
220+
221+
If you prefer, you can still create and push the matching tag yourself, for example `git tag v1.6.12 && git push origin v1.6.12`.
222+
200223
## Contributing
201224

202225
1. Fork it

cloudstack-cli.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ Gem::Specification.new do |gem|
2424
gem.add_development_dependency('rake', '~> 13.0')
2525
gem.add_development_dependency('minitest', '~> 5.11')
2626

27-
gem.add_dependency('cloudstack_client', '~> 1.5.10')
27+
gem.add_dependency('cloudstack_client', '~> 1.6.0')
2828
gem.add_dependency('thor', '~> 1.1.0')
2929
end

lib/cloudstack-cli/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module CloudstackCli
2-
VERSION = "1.6.11"
2+
VERSION = "1.6.12"
33
end

0 commit comments

Comments
 (0)