Skip to content

Commit 42efdd5

Browse files
authored
Merge pull request #355 from ruby-go-gem/release_gem
Release gem from GitHub Actions
2 parents 0ee8c6e + 6885381 commit 42efdd5

File tree

2 files changed

+55
-20
lines changed

2 files changed

+55
-20
lines changed

.github/workflows/release.yml

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,62 @@
1-
name: Create releases
1+
name: Publish new version
22

33
on:
4-
push:
5-
tags:
6-
- "v*"
7-
8-
permissions:
9-
contents: write
10-
actions: read
11-
pull-requests: read
4+
workflow_dispatch:
125

136
jobs:
14-
publish:
7+
publish-gem:
8+
name: Publish gem to rubygems.org
9+
10+
if: github.repository == 'ruby-go-gem/go-gem-wrapper'
11+
runs-on: ubuntu-latest
12+
13+
defaults:
14+
run:
15+
shell: bash
16+
working-directory: _gem/
17+
18+
environment:
19+
name: rubygems.org
20+
url: https://rubygems.org/gems/go_gem
21+
22+
permissions:
23+
contents: write
24+
id-token: write
25+
26+
steps:
27+
- name: Harden Runner
28+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
29+
with:
30+
egress-policy: audit
31+
32+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
33+
34+
- name: Set up Ruby
35+
uses: ruby/setup-ruby@eaecf785f6a34567a6d97f686bbb7bccc1ac1e5c # v1.237.0
36+
with:
37+
bundler-cache: true
38+
ruby-version: ruby
39+
40+
- name: Publish to RubyGems
41+
uses: rubygems/release-gem@a25424ba2ba8b387abc8ef40807c2c85b96cbe32 # v1.1.1
42+
43+
create-release:
44+
needs:
45+
- publish-gem
46+
1547
runs-on: ubuntu-latest
1648

49+
permissions:
50+
contents: write
51+
actions: read
52+
pull-requests: read
53+
1754
steps:
55+
- name: Harden Runner
56+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
57+
with:
58+
egress-policy: audit
59+
1860
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
1961

2062
- uses: ruby/setup-ruby@8aeb6ff8030dd539317f8e1769a044873b56ea71 # v1.268.0
@@ -24,13 +66,13 @@ jobs:
2466

2567
- name: Generate changelog
2668
run: |
27-
bundle exec rake changelog[,${TAG_NAME}] > /tmp/changelog.md
69+
version=$(bundle exec ruby -e 'puts GoGem::VERSION')
70+
bundle exec rake changelog[,v${version}] > /tmp/changelog.md
2871
cat /tmp/changelog.md
2972
env:
30-
TAG_NAME: ${{ github.ref_name }}
3173
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3274

33-
- name: Release
75+
- name: Create release
3476
uses: softprops/action-gh-release@5be0e66d93ac7ed76da52eca8bb058f665c3a5fe # v2.4.2
3577
with:
3678
body_path: /tmp/changelog.md

Rakefile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ end
99

1010
Dir["#{__dir__}/_tasks/*.rake"].each { |f| load f }
1111

12-
desc "Release package"
13-
task :release do
14-
Dir.chdir(File.join(__dir__, "_gem")) do
15-
sh "rake release"
16-
end
17-
end
18-
1912
desc "Generate changelog entry"
2013
task :changelog, [:before, :after] do |_, params|
2114
args = []

0 commit comments

Comments
 (0)