|
| 1 | +# .github/workflows/release.yml |
| 2 | +name: Gem Release |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - "v*" |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 15 | + ruby: ["3.0", "3.1", "3.2", "3.3"] |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v6 |
| 19 | + - uses: oxidize-rb/actions/setup-ruby-and-rust@v1 |
| 20 | + with: |
| 21 | + ruby-version: ${{ matrix.ruby }} |
| 22 | + bundler-cache: true |
| 23 | + - run: bundle exec rake compile |
| 24 | + - run: bundle exec rake test |
| 25 | + |
| 26 | + cross-compile: |
| 27 | + needs: [test] |
| 28 | + runs-on: ubuntu-latest |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + platform: ["x86_64-linux", "aarch64-linux", "x86_64-darwin", "arm64-darwin", "x64-mingw-ucrt"] |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v6 |
| 35 | + - uses: ruby/setup-ruby@v1 |
| 36 | + with: |
| 37 | + ruby-version: "3.1" |
| 38 | + - uses: oxidize-rb/actions/cross-gem@v1 |
| 39 | + with: |
| 40 | + platform: ${{ matrix.platform }} |
| 41 | + - uses: actions/upload-artifact@v6 |
| 42 | + with: |
| 43 | + name: gem-${{ matrix.platform }} |
| 44 | + path: pkg/*-${{ matrix.platform }}.gem |
| 45 | + |
| 46 | + release: |
| 47 | + needs: cross-compile |
| 48 | + runs-on: ubuntu-latest |
| 49 | + steps: |
| 50 | + - uses: actions/download-artifact@v7 |
| 51 | + with: |
| 52 | + path: artifacts |
| 53 | + - name: Move gems to pkg directory |
| 54 | + run: | |
| 55 | + mkdir -p pkg |
| 56 | + find artifacts -name "*.gem" -exec mv {} pkg/ \; |
| 57 | + - name: Publish to RubyGems |
| 58 | + env: |
| 59 | + RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} |
| 60 | + run: | |
| 61 | + mkdir -p ~/.gem |
| 62 | + echo "--- |
| 63 | + :rubygems_api_key: ${RUBYGEMS_API_KEY}" > ~/.gem/credentials |
| 64 | + chmod 0600 ~/.gem/credentials |
| 65 | + for gem in pkg/*.gem |
| 66 | + do |
| 67 | + gem push $gem |
| 68 | + done |
0 commit comments