|
1 | | -name: Release |
| 1 | +--- |
| 2 | +name: Gem Release |
2 | 3 |
|
3 | 4 | on: |
4 | 5 | push: |
5 | 6 | tags: |
6 | 7 | - '*' |
7 | 8 |
|
8 | 9 | jobs: |
9 | | - release: |
10 | | - runs-on: ubuntu-latest |
| 10 | + build-release: |
| 11 | + # Prevent releases from forked repositories |
11 | 12 | if: github.repository_owner == 'voxpupuli' |
| 13 | + name: Build the gem |
| 14 | + runs-on: ubuntu-24.04 |
| 15 | + permissions: |
| 16 | + contents: write # clone repo and create release |
12 | 17 | steps: |
13 | 18 | - uses: actions/checkout@v4 |
14 | | - - name: Install Ruby 3.3 |
| 19 | + - name: Install Ruby |
15 | 20 | uses: ruby/setup-ruby@v1 |
16 | 21 | with: |
17 | | - ruby-version: '3.3' |
18 | | - env: |
19 | | - BUNDLE_WITHOUT: release |
| 22 | + ruby-version: 'ruby' |
20 | 23 | - name: Build gem |
21 | | - run: gem build --strict --verbose *.gemspec |
| 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 | + - name: Create Release Page |
| 34 | + shell: bash |
| 35 | + env: |
| 36 | + GH_TOKEN: ${{ github.token }} |
| 37 | + run: gh release create ${{ github.ref_name }} --generate-notes |
| 38 | + - name: Attach gem to GitHub Release |
| 39 | + shell: bash |
| 40 | + env: |
| 41 | + GH_TOKEN: ${{ github.token }} |
| 42 | + run: gh release upload ${{ github.ref_name }} *.gem |
| 43 | + |
| 44 | + release-to-github: |
| 45 | + needs: build-release |
| 46 | + name: Release to GitHub |
| 47 | + runs-on: ubuntu-24.04 |
| 48 | + permissions: |
| 49 | + packages: write # publish to rubygems.pkg.github.com |
| 50 | + steps: |
| 51 | + - name: Download gem from GitHub cache |
| 52 | + uses: actions/download-artifact@v4 |
| 53 | + with: |
| 54 | + name: gem-artifact |
| 55 | + - name: Publish gem to GitHub packages |
| 56 | + run: GEM_HOST_API_KEY=${{ secrets.GITHUB_TOKEN }} gem push --key github --host https://rubygems.pkg.github.com/${{ github.repository_owner }} *.gem |
| 57 | + |
| 58 | + release-to-rubygems: |
| 59 | + needs: build-release |
| 60 | + name: Release gem to rubygems.org |
| 61 | + runs-on: ubuntu-24.04 |
| 62 | + environment: release # recommended by rubygems.org |
| 63 | + permissions: |
| 64 | + id-token: write # rubygems.org authentication |
| 65 | + steps: |
| 66 | + - name: Download gem from GitHub cache |
| 67 | + uses: actions/download-artifact@v4 |
| 68 | + with: |
| 69 | + name: gem-artifact |
| 70 | + - uses: rubygems/[email protected] |
22 | 71 | - name: Publish gem to rubygems.org |
| 72 | + shell: bash |
23 | 73 | run: gem push *.gem |
24 | | - env: |
25 | | - GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}' |
26 | | - - name: Setup GitHub packages access |
| 74 | + |
| 75 | + release-verification: |
| 76 | + name: Check that all releases are done |
| 77 | + runs-on: ubuntu-24.04 |
| 78 | + permissions: |
| 79 | + contents: read # minimal permissions that we have to grant |
| 80 | + needs: |
| 81 | + - release-to-github |
| 82 | + - release-to-rubygems |
| 83 | + steps: |
| 84 | + - name: Download gem from GitHub cache |
| 85 | + uses: actions/download-artifact@v4 |
| 86 | + with: |
| 87 | + name: gem-artifact |
| 88 | + - name: Install Ruby |
| 89 | + uses: ruby/setup-ruby@v1 |
| 90 | + with: |
| 91 | + ruby-version: 'ruby' |
| 92 | + - name: Wait for release to propagate |
| 93 | + shell: bash |
27 | 94 | run: | |
28 | | - mkdir -p ~/.gem |
29 | | - echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials |
30 | | - chmod 0600 ~/.gem/credentials |
31 | | - - name: Publish gem to GitHub packages |
32 | | - run: gem push --key github --host https://rubygems.pkg.github.com/voxpupuli *.gem |
| 95 | + gem install rubygems-await |
| 96 | + gem await *.gem |
0 commit comments