Make gem release workflow resumable #9
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: Release libui to RubyGems | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| workflow_dispatch: | |
| jobs: | |
| push: | |
| environment: release-rubygems | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # Default Ruby version: 3.4 (used for all platforms except x64-mingw32) | |
| include: | |
| - os: ubuntu-latest | |
| ruby-version: "3.4" | |
| gem_platform: x86_64-linux | |
| - os: ubuntu-24.04-arm | |
| ruby-version: "3.4" | |
| gem_platform: aarch64-linux | |
| - os: macos-15-intel | |
| ruby-version: "3.4" | |
| gem_platform: x86_64-darwin | |
| - os: macos-14 # Apple Silicon | |
| ruby-version: "3.4" | |
| gem_platform: arm64-darwin | |
| - os: windows-latest | |
| ruby-version: "2.7" # Ruby 2.7 is used for x64-mingw32 because newer Ruby versions default to x64-mingw-ucrt platform, causing bundler platform resolution conflicts | |
| gem_platform: x64-mingw32 | |
| - os: windows-latest | |
| ruby-version: "3.4" | |
| gem_platform: x64-mingw-ucrt | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
| contents: read | |
| env: | |
| GEM_PLATFORM: ${{ matrix.gem_platform }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler-cache: true | |
| - name: Show versions | |
| run: | | |
| ruby -v | |
| gem -v | |
| bundle -v | |
| shell: bash | |
| - name: Update RubyGems for Windows Ruby 2.7 (enable 'gem exec') | |
| if: ${{ matrix.gem_platform == 'x64-mingw32' }} | |
| run: | | |
| gem update --system 3.4.22 | |
| gem --version | |
| shell: bash | |
| - name: Prepare vendored binary (bundle exec rake vendor:auto) | |
| run: | | |
| bundle exec rake vendor:auto | |
| shell: bash | |
| - name: Build gem | |
| run: | | |
| gem build libui.gemspec | |
| shell: bash | |
| - name: Configure RubyGems credentials | |
| uses: rubygems/configure-rubygems-credentials@v2.0.0 | |
| - name: Push gem to RubyGems.org | |
| run: | | |
| ruby -rjson -rnet/http -ruri -rrubygems/package -e ' | |
| gem_file = Dir["libui-*.gem"].fetch(0) | |
| spec = Gem::Package.new(gem_file).spec | |
| version = spec.version.to_s | |
| platform = spec.platform.to_s | |
| uri = URI("https://rubygems.org/api/v1/versions/#{spec.name}.json") | |
| versions = JSON.parse(Net::HTTP.get(uri)) | |
| if versions.any? { |v| v["number"] == version && v["platform"] == platform } | |
| puts "#{spec.name} #{version} #{platform} already pushed; skipping" | |
| exit 0 | |
| end | |
| exec "gem", "push", gem_file | |
| ' | |
| shell: bash |