Skip to content

Commit 668d8c1

Browse files
Copilotniwo
andauthored
Add GitHub Actions CI and RubyGems release workflows
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 f9faf27 commit 668d8c1

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
ruby-version: ['3.2', '3.3', '3.4']
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Ruby
20+
uses: ruby/setup-ruby@v1
21+
with:
22+
ruby-version: ${{ matrix.ruby-version }}
23+
bundler-cache: true
24+
25+
- name: Run tests
26+
run: bundle exec rake test
27+
28+
- name: Build gem
29+
run: bundle exec rake build

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
verify:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Ruby
17+
uses: ruby/setup-ruby@v1
18+
with:
19+
ruby-version: '3.2'
20+
bundler-cache: true
21+
22+
- name: Run tests
23+
run: bundle exec rake test
24+
25+
- name: Build gem
26+
run: bundle exec rake build
27+
28+
publish:
29+
runs-on: ubuntu-latest
30+
needs: verify
31+
environment: rubygems
32+
permissions:
33+
contents: read
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
39+
- name: Set up Ruby
40+
uses: ruby/setup-ruby@v1
41+
with:
42+
ruby-version: '3.2'
43+
bundler-cache: true
44+
45+
- name: Build gem
46+
run: bundle exec rake build
47+
48+
- name: Publish gem to RubyGems
49+
env:
50+
RUBYGEMS_AUTH_TOKEN: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
51+
run: gem push "$(ls pkg/*.gem | sort | tail -n 1)"

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,19 @@ $ cloudstack_client list_apis > data/4.15.json
164164
$ gzip data/4.15.json
165165
```
166166

167+
### GitHub Actions
168+
169+
This repository includes GitHub Actions workflows for:
170+
171+
- Running tests and gem build on every push and pull request (`CI`)
172+
- Publishing the gem to RubyGems when a GitHub Release is published (`Release`)
173+
174+
To enable publishing, add this repository secret:
175+
176+
- `RUBYGEMS_AUTH_TOKEN`: your RubyGems API key with push permissions
177+
178+
The release workflow uses the `rubygems` environment and pushes the built gem automatically.
179+
167180
## References
168181

169182
- [Apache CloudStack API documentation](http://cloudstack.apache.org/api/apidocs-4.15/)

0 commit comments

Comments
 (0)