Skip to content

Commit 9d98e60

Browse files
authored
Merge pull request #145 from bastelfreak/gem
CI: Fix gem release workflow
2 parents e21afbe + 496f2f6 commit 9d98e60

File tree

1 file changed

+88
-23
lines changed

1 file changed

+88
-23
lines changed

.github/workflows/gem_release.yaml

Lines changed: 88 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,101 @@ on:
66
tags:
77
- '*'
88

9+
permissions: {}
10+
911
jobs:
10-
release:
11-
name: Release gem
12-
runs-on: ubuntu-24.04
13-
# Optional but recommended to use a specific environment
14-
environment: release
12+
build-release:
1513
# Prevent releases from forked repositories
1614
if: github.repository_owner == 'OpenVoxProject'
15+
name: Build the gem
16+
runs-on: ubuntu-24.04
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Install Ruby
20+
uses: ruby/setup-ruby@v1
21+
with:
22+
ruby-version: 'ruby'
23+
- name: Build gem
24+
shell: bash
25+
run: gem build --verbose *.gemspec
26+
- name: Upload gem to GitHub cache
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: gem-artifact
30+
path: '*.gem'
31+
retention-days: 1
32+
compression-level: 0
1733

34+
create-github-release:
35+
needs: build-release
36+
name: Create GitHub release
37+
runs-on: ubuntu-24.04
1838
permissions:
19-
id-token: write
20-
contents: write
21-
packages: write
22-
39+
contents: write # clone repo and create release
2340
steps:
24-
- uses: voxpupuli/ruby-release@v0
25-
- name: Setup GitHub packages access
26-
run: |
27-
mkdir -p ~/.gem
28-
echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials
29-
chmod 0600 ~/.gem/credentials
30-
- name: Publish gem to GitHub packages
31-
run: gem push --key github --host https://rubygems.pkg.github.com/openvoxproject *.gem
32-
- name: Create Release Page
41+
- name: Download gem from GitHub cache
42+
uses: actions/download-artifact@v4
43+
with:
44+
name: gem-artifact
45+
- name: Create Release
3346
shell: bash
3447
env:
3548
GH_TOKEN: ${{ github.token }}
36-
run: gh release create ${{ github.ref_name }} --generate-notes
37-
- name: Attach gem to GitHub Release
38-
shell: bash
49+
run: gh release create --repo ${{ github.repository }} ${{ github.ref_name }} --generate-notes *.gem
50+
51+
release-to-github:
52+
needs: build-release
53+
name: Release to GitHub
54+
runs-on: ubuntu-24.04
55+
permissions:
56+
packages: write # publish to rubygems.pkg.github.com
57+
steps:
58+
- name: Download gem from GitHub cache
59+
uses: actions/download-artifact@v4
60+
with:
61+
name: gem-artifact
62+
- name: Publish gem to GitHub packages
63+
run: gem push --host https://rubygems.pkg.github.com/${{ github.repository_owner }} *.gem
3964
env:
40-
GH_TOKEN: ${{ github.token }}
41-
run: gh release upload ${{ github.ref_name }} *.gem
65+
GEM_HOST_API_KEY: ${{ secrets.GITHUB_TOKEN }}
66+
67+
release-to-rubygems:
68+
needs: build-release
69+
name: Release gem to rubygems.org
70+
runs-on: ubuntu-24.04
71+
environment: release # recommended by rubygems.org
72+
permissions:
73+
id-token: write # rubygems.org authentication
74+
steps:
75+
- name: Download gem from GitHub cache
76+
uses: actions/download-artifact@v4
77+
with:
78+
name: gem-artifact
79+
- uses: rubygems/[email protected]
80+
- name: Publish gem to rubygems.org
81+
shell: bash
82+
run: gem push *.gem
83+
84+
release-verification:
85+
name: Check that all releases are done
86+
runs-on: ubuntu-24.04
87+
permissions:
88+
contents: read # minimal permissions that we have to grant
89+
needs:
90+
- create-github-release
91+
- release-to-github
92+
- release-to-rubygems
93+
steps:
94+
- name: Download gem from GitHub cache
95+
uses: actions/download-artifact@v4
96+
with:
97+
name: gem-artifact
98+
- name: Install Ruby
99+
uses: ruby/setup-ruby@v1
100+
with:
101+
ruby-version: 'ruby'
102+
- name: Wait for release to propagate
103+
shell: bash
104+
run: |
105+
gem install rubygems-await
106+
gem await *.gem

0 commit comments

Comments
 (0)