|
1 | | -name: Ruby Gem |
2 | | - |
3 | | -on: |
4 | | - push: |
5 | | - branches: [ "master" ] |
6 | | - pull_request: |
7 | | - branches: [ "master" ] |
8 | | - |
| 1 | +# .github/workflows/push_gem.yml |
9 | 2 | jobs: |
10 | | - build: |
11 | | - name: Build + Publish |
| 3 | + push: |
| 4 | + name: Push gem to RubyGems.org |
12 | 5 | runs-on: ubuntu-latest |
| 6 | + |
13 | 7 | permissions: |
14 | | - contents: read |
15 | | - packages: write |
| 8 | + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing |
| 9 | + contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag |
16 | 10 |
|
17 | 11 | steps: |
18 | | - - uses: actions/checkout@v4 |
19 | | - - name: Set up Ruby 2.6 |
20 | | - # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, |
21 | | - # change this to (see https://github.com/ruby/setup-ruby#versioning): |
22 | | - # uses: ruby/setup-ruby@v1 |
23 | | - uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 |
24 | | - with: |
25 | | - ruby-version: 2.6.x |
26 | | - |
27 | | - - name: Publish to GPR |
28 | | - run: | |
29 | | - mkdir -p $HOME/.gem |
30 | | - touch $HOME/.gem/credentials |
31 | | - chmod 0600 $HOME/.gem/credentials |
32 | | - printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials |
33 | | - gem build *.gemspec |
34 | | - gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem |
35 | | - env: |
36 | | - GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}" |
37 | | - OWNER: ${{ github.repository_owner }} |
| 12 | + # Set up |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + persist-credentials: false |
| 16 | + - name: Set up Ruby |
| 17 | + uses: ruby/setup-ruby@v1 |
| 18 | + with: |
| 19 | + bundler-cache: true |
| 20 | + ruby-version: ruby |
38 | 21 |
|
39 | | - - name: Publish to RubyGems |
40 | | - run: | |
41 | | - mkdir -p $HOME/.gem |
42 | | - touch $HOME/.gem/credentials |
43 | | - chmod 0600 $HOME/.gem/credentials |
44 | | - printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials |
45 | | - gem build *.gemspec |
46 | | - gem push *.gem |
47 | | - env: |
48 | | - GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}" |
| 22 | + # Release |
| 23 | + - uses: rubygems/release-gem@v1 |
0 commit comments