Skip to content

Commit ed3aa41

Browse files
committed
Release job: Cleanup github actions
This follows our best practice from https://github.com/voxpupuli/gem-workflow-test/blob/master/.github/workflows/release.yml (except for the release to rubygems, because that namespace is owned by Perforce).
1 parent d6ced3d commit ed3aa41

1 file changed

Lines changed: 45 additions & 29 deletions

File tree

.github/workflows/release.yml

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,60 @@ 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'
17-
18-
permissions:
19-
id-token: write
20-
contents: write
21-
packages: write
22-
15+
name: Build the gem
16+
runs-on: ubuntu-24.04
2317
steps:
24-
# we cannot publish to rubygems.org until we rename the project
25-
# https://rubygems.org/gems/vanagon owned by Perforce
26-
# - uses: voxpupuli/ruby-release@v0
2718
- uses: actions/checkout@v4
28-
with:
29-
fetch-depth: 0
3019
- name: Install Ruby
3120
uses: ruby/setup-ruby@v1
3221
with:
33-
ruby-version: '3.4'
34-
env:
35-
BUNDLE_WITHOUT: ec2-engine:development:test
22+
ruby-version: 'ruby'
3623
- name: Build gem
37-
run: gem build --strict --verbose *.gemspec
38-
- name: Setup GitHub packages access
39-
run: |
40-
mkdir -p ~/.gem
41-
echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials
42-
chmod 0600 ~/.gem/credentials
43-
- name: Publish gem to GitHub packages
44-
run: gem push --key github --host https://rubygems.pkg.github.com/openvoxproject *.gem
45-
- name: Create Release Page
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
33+
34+
create-github-release:
35+
needs: build-release
36+
name: Create GitHub release
37+
runs-on: ubuntu-24.04
38+
permissions:
39+
contents: write # clone repo and create release
40+
steps:
41+
- name: Download gem from GitHub cache
42+
uses: actions/download-artifact@v4
43+
with:
44+
name: gem-artifact
45+
- name: Create Release
4646
shell: bash
4747
env:
4848
GH_TOKEN: ${{ github.token }}
49-
run: gh release create ${{ github.ref_name }} --generate-notes
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
64+
env:
65+
GEM_HOST_API_KEY: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)