-
Notifications
You must be signed in to change notification settings - Fork 7
68 lines (55 loc) · 1.89 KB
/
Copy pathrelease.yml
File metadata and controls
68 lines (55 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Release
on:
release:
types: [published]
workflow_dispatch:
permissions:
contents: read
id-token: write
jobs:
verify:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- name: Run tests
run: bundle exec rake test
- name: Ensure version is bumped
run: |
CURRENT_VERSION="$(ruby -Ilib -e "require 'cloudstack_client/version'; puts CloudstackClient::VERSION")"
LATEST_JSON="$(curl -fsSL https://rubygems.org/api/v1/versions/cloudstack_client/latest.json || true)"
if [ -n "$LATEST_JSON" ]; then
LATEST_VERSION="$(printf '%s' "$LATEST_JSON" | ruby -rjson -e "puts JSON.parse(STDIN.read)['version']")"
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"
fi
- name: Build gem
run: bundle exec rake build
publish:
runs-on: ubuntu-latest
needs: verify
environment: rubygems
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- name: Check if RUBYGEMS_AUTH_TOKEN is set
run: |
if [ -z "${{ secrets.RUBYGEMS_AUTH_TOKEN }}" ]; then
echo 'RUBYGEMS_AUTH_TOKEN not set!'
exit 1
else
echo 'RUBYGEMS_AUTH_TOKEN is available.'
fi
- name: Publish gem to RubyGems
uses: rubygems/release-gem@v2
with:
api-key: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}