|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + environment: |
| 7 | + description: "GitHub environment for the workflow" |
| 8 | + type: string |
| 9 | + default: "rubygems" |
| 10 | + |
| 11 | +permissions: |
| 12 | + # for uploading artifacts to GitHub release |
| 13 | + contents: write |
| 14 | + |
| 15 | + # for trusted publishing and attest-build-provenance |
| 16 | + id-token: write |
| 17 | + |
| 18 | + # for attest-build-provenance |
| 19 | + attestations: write |
| 20 | + |
| 21 | +jobs: |
| 22 | + release: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + environment: ${{ inputs.environment }} |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: 📥 Checkout Repository |
| 28 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 29 | + with: |
| 30 | + persist-credentials: false |
| 31 | + - name: 🏗️ Set up Ruby |
| 32 | + uses: ruby/setup-ruby@2a18b06812b0e15bb916e1df298d3e740422c47e # v1.203.0 |
| 33 | + with: |
| 34 | + bundler-cache: true |
| 35 | + |
| 36 | + - name: 🔄 Sync version file |
| 37 | + run: | |
| 38 | + version="${GH_VERSION#v}" |
| 39 | + if ! ruby -e "require 'rubygems'; Gem::Version.new('$version')"; then |
| 40 | + echo "Error: Invalid version string '$version'" |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | + sed -i "s/VERSION = '.*'/VERSION = '${version}'/" lib/version.rb |
| 44 | +
|
| 45 | + git update-index --skip-worktree lib/version.rb |
| 46 | + env: |
| 47 | + GH_VERSION: ${{ github.event.release.tag_name }} |
| 48 | + |
| 49 | + - name: 🚀 Publish to rubygems |
| 50 | + uses: rubygems/release-gem@9e85cb11501bebc2ae661c1500176316d3987059 # v1.1.0 |
| 51 | + |
| 52 | + - name: 🗑️ Clean signable artifacts |
| 53 | + run: rm pkg/*.sigstore.json |
| 54 | + |
| 55 | + - name: 🔐 Generate Build Provenance |
| 56 | + uses: actions/attest-build-provenance@7668571508540a607bdfd90a87a560489fe372eb # v2.1.0 |
| 57 | + with: |
| 58 | + subject-path: "pkg/*" |
| 59 | + |
| 60 | + - name: 📥 Upload to GitHub |
| 61 | + run: | |
| 62 | + for file in pkg/*; do |
| 63 | + gh release upload "${GH_VERSION}" "$file" |
| 64 | + done |
| 65 | + env: |
| 66 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + GH_VERSION: ${{ github.event.release.tag_name }} |
0 commit comments