fix(publish): use Cargo.lock v3 format for rb-sys-dock compatibility #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish | |
| on: | |
| push: | |
| tags: ['v*'] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| ci-data: | |
| name: Fetch supported Ruby platforms + versions | |
| runs-on: ubuntu-latest | |
| outputs: | |
| result: ${{ steps.fetch.outputs.result }} | |
| steps: | |
| - id: fetch | |
| uses: oxidize-rb/actions/fetch-ci-data@v1 | |
| with: | |
| supported-ruby-platforms: | | |
| # arm-linux: 32-bit ARM, not a sensible target for an embedded database. | |
| # x64-mingw32: superseded by x64-mingw-ucrt for Ruby 3.1+. | |
| # aarch64-mingw-ucrt: no rb-sys-dock image exists for ARM Windows. | |
| # aarch64-linux-musl: no rb-sys-dock image for ARM musl. | |
| exclude: [arm-linux, x64-mingw32, aarch64-mingw-ucrt, aarch64-linux-musl] | |
| stable-ruby-versions: | | |
| exclude: [head] | |
| cross-gems: | |
| name: Cross-compile - ${{ matrix.ruby-platform }} | |
| needs: ci-data | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| ruby-platform: ${{ fromJSON(needs.ci-data.outputs.result).supported-ruby-platforms }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: "3.3" | |
| - name: Cross-compile precompiled native gem | |
| uses: oxidize-rb/actions/cross-gem@v1 | |
| with: | |
| platform: ${{ matrix.ruby-platform }} | |
| ruby-versions: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }} | |
| - name: Smoke install precompiled gem (Linux x86_64 only) | |
| if: matrix.ruby-platform == 'x86_64-linux' | |
| run: | | |
| gem install --verbose pkg/stoolap-*-x86_64-linux.gem | |
| ruby -rstoolap -e " | |
| db = Stoolap::Database.open(':memory:') | |
| db.exec('CREATE TABLE t (id INTEGER PRIMARY KEY)') | |
| db.execute('INSERT INTO t VALUES (\$1)', [1]) | |
| row = db.query_one('SELECT * FROM t') | |
| raise 'precompiled gem smoke failed' unless row == { 'id' => 1 } | |
| puts 'precompiled gem ok' | |
| " | |
| - name: Upload precompiled gem | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: cross-gem-${{ matrix.ruby-platform }} | |
| path: pkg/*-${{ matrix.ruby-platform }}.gem | |
| if-no-files-found: error | |
| retention-days: 1 | |
| source-gem: | |
| name: Build source gem | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: oxidize-rb/actions/setup-ruby-and-rust@v1 | |
| with: | |
| ruby-version: "3.3" | |
| bundler-cache: true | |
| cargo-cache: true | |
| cache-version: v1 | |
| - name: Ensure gemspec version matches the git tag | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| GEM_VERSION=$(grep VERSION lib/stoolap/version.rb | head -n 1 | cut -d'"' -f2) | |
| if [ "v$GEM_VERSION" != "${{ github.ref_name }}" ]; then | |
| echo "::error::gemspec version v$GEM_VERSION does not match tag ${{ github.ref_name }}" | |
| exit 1 | |
| fi | |
| - name: Build source gem | |
| run: bundle exec rake build | |
| - name: Upload source gem | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: source-gem | |
| path: pkg/stoolap-*.gem | |
| if-no-files-found: error | |
| retention-days: 1 | |
| release: | |
| name: Publish to RubyGems + GitHub Release | |
| needs: [cross-gems, source-gem] | |
| if: startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| environment: rubygems | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: "3.3" | |
| - name: Download all gem artifacts into pkg/ | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: "{cross-gem-*,source-gem}" | |
| merge-multiple: true | |
| path: pkg/ | |
| - name: List gems to publish | |
| run: ls -l pkg/ | |
| - name: Configure trusted publishing credentials | |
| uses: rubygems/configure-rubygems-credentials@v1 | |
| - name: Push gems to RubyGems | |
| working-directory: pkg/ | |
| run: | | |
| for gem in *.gem; do | |
| [ -f "$gem" ] || continue | |
| echo "pushing $gem" | |
| set +e | |
| gem push "$gem" > push.out 2>&1 | |
| status=$? | |
| set -e | |
| if [ $status -ne 0 ]; then | |
| sed 's/^/::error:: /' push.out | |
| if ! grep -q "Repushing of gem" push.out; then | |
| exit $status | |
| fi | |
| echo "::warning::${gem} already exists on RubyGems, skipping" | |
| else | |
| cat push.out | |
| fi | |
| done | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true | |
| files: pkg/*.gem |