ci: bump Gemfile.lock for 0.1.1 (frozen-mode deploy) #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: Release | |
| on: | |
| push: | |
| tags: ["v*"] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: rubygems | |
| url: https://rubygems.org/gems/postio | |
| permissions: | |
| contents: read | |
| id-token: write # Trusted Publishers (OIDC) | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: "3.3" | |
| bundler-cache: true | |
| - name: Verify tag matches gem version | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: | | |
| TAG="${GITHUB_REF#refs/tags/v}" | |
| VERSION=$(ruby -r ./lib/postio/version -e "puts Postio::VERSION") | |
| if [ "$TAG" != "$VERSION" ]; then | |
| echo "::error::Tag v$TAG does not match Postio::VERSION $VERSION" | |
| exit 1 | |
| fi | |
| - name: Run offline tests | |
| run: bundle exec rspec | |
| - name: Configure Trusted Publisher (exchange GH OIDC for RubyGems token) | |
| uses: rubygems/configure-rubygems-credentials@main | |
| - name: Build gem | |
| run: gem build postio.gemspec | |
| - name: Skip if version already on RubyGems (idempotent) | |
| id: check | |
| run: | | |
| VERSION=$(ruby -r ./lib/postio/version -e "puts Postio::VERSION") | |
| STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://rubygems.org/api/v1/versions/postio.json") | |
| if [ "$STATUS" = "200" ] && curl -s "https://rubygems.org/api/v1/versions/postio.json" | grep -q "\"number\":\"$VERSION\""; then | |
| echo "already-published=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "already-published=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Push gem to RubyGems | |
| if: steps.check.outputs.already-published == 'false' | |
| run: gem push postio-*.gem |