Publish #8
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: | |
workflow_run: | |
workflows: [CI] | |
types: [completed] | |
permissions: | |
contents: read | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
outputs: | |
run_publish: ${{ steps.precheck.outputs.run_publish }} | |
steps: | |
- uses: actions/checkout@v5 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: "3.4" | |
bundler-cache: true | |
- id: precheck | |
name: Release precheck | |
run: bundle exec rake ci:check_release | |
push: | |
needs: check | |
if: | | |
needs.check.outputs.run_publish == 'true' && | |
github.repository == 'ruby/json' && | |
github.ref_name == github.event.repository.default_branch | |
runs-on: ubuntu-latest | |
environment: | |
name: rubygems.org | |
url: https://rubygems.org/gems/json | |
permissions: | |
contents: write | |
id-token: write | |
strategy: | |
matrix: | |
ruby: ["ruby", "jruby"] | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 | |
with: | |
egress-policy: audit | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@eaecf785f6a34567a6d97f686bbb7bccc1ac1e5c # v1.237.0 | |
with: | |
ruby-version: ${{ matrix.ruby }} | |
bundler-cache: true | |
# https://github.com/rubygems/rubygems/issues/5882 | |
- name: Install dependencies and build for JRuby | |
run: | | |
sudo apt install default-jdk maven | |
gem update --system | |
gem install ruby-maven rake-compiler --no-document | |
rake compile | |
if: matrix.ruby == 'jruby' | |
- name: Install dependencies | |
run: bundle install --jobs 4 --retry 3 | |
- name: Publish to RubyGems | |
uses: rubygems/release-gem@a25424ba2ba8b387abc8ef40807c2c85b96cbe32 # v1.1.1 | |
- name: Create GitHub release | |
run: | | |
bundle exec rake ci:create_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
if: matrix.ruby != 'jruby' |