From f26347c89690756c75f3bf2a87950317937d1fd7 Mon Sep 17 00:00:00 2001 From: Kirill Mokevnin Date: Fri, 26 Jun 2026 12:42:55 +0300 Subject: [PATCH] ci: publish gem from release-please run, matching hexlet-ide GitHub deliberately blocks GITHUB_TOKEN-triggered events from starting other workflows, so a release created by release-please never fired the release:published-based publish-gem workflow. Rather than introduce a PAT, fold publishing into the release workflow as a downstream job gated on the action's release_created output (the same pattern used in hexlet-ide): the publish job runs in the same workflow invocation that cuts the release, so no cross-workflow trigger is needed. Rename release-please.yml to release.yml (release-please + publish jobs) and reduce publish-gem.yml to a manual workflow_dispatch fallback for re-publishing an existing release. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/publish-gem.yml | 10 +++--- .github/workflows/release-please.yml | 20 ----------- .github/workflows/release.yml | 50 ++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 26 deletions(-) delete mode 100644 .github/workflows/release-please.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/publish-gem.yml b/.github/workflows/publish-gem.yml index 95c967e..6e0c494 100644 --- a/.github/workflows/publish-gem.yml +++ b/.github/workflows/publish-gem.yml @@ -1,13 +1,11 @@ -# This workflow is triggered when a GitHub release is created. -# It can also be run manually to re-publish to rubygems.org in case it failed for some reason. -# You can run this workflow by navigating to https://www.github.com/Hexlet/cloudpayments-ruby/actions/workflows/publish-gem.yml +# Manual fallback to (re-)publish a gem version to rubygems.org. +# The normal release flow publishes from the `release.yml` workflow's `publish` job. +# Run this manually only if that publish step needs to be retried for an existing release. +# Navigate to https://www.github.com/Hexlet/cloudpayments-ruby/actions/workflows/publish-gem.yml name: Publish Gem on: workflow_dispatch: - release: - types: [published] - jobs: publish: name: publish diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml deleted file mode 100644 index 9dba32d..0000000 --- a/.github/workflows/release-please.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Release Please -on: - push: - branches: - - main - -permissions: - contents: write - pull-requests: write - -jobs: - release-please: - name: release-please - runs-on: ubuntu-latest - if: github.repository == 'Hexlet/cloudpayments-ruby' - steps: - - uses: googleapis/release-please-action@v4 - with: - config-file: release-please-config.json - manifest-file: .release-please-manifest.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6574dd0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +name: Release Please + +on: + push: + branches: + - main + +jobs: + release-please: + runs-on: ubuntu-latest + if: github.repository == 'Hexlet/cloudpayments-ruby' + + permissions: + contents: write + pull-requests: write + + outputs: + release_created: ${{ steps.release.outputs.release_created }} + version: ${{ steps.release.outputs.tag_name }} + + steps: + - uses: googleapis/release-please-action@v5 + id: release + with: + token: ${{ secrets.GITHUB_TOKEN }} + config-file: release-please-config.json + manifest-file: .release-please-manifest.json + + publish: + needs: release-please + if: needs.release-please.outputs.release_created == 'true' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: false + + - run: |- + bundle install + + - name: Publish to RubyGems.org + run: bash ./bin/publish-gem + env: + # `RUBYGEMS_HOST` is only required for private gem repositories, not https://rubygems.org + RUBYGEMS_HOST: ${{ secrets.CLOUDPAYMENTS_RUBYGEMS_HOST || secrets.RUBYGEMS_HOST }} + GEM_HOST_API_KEY: ${{ secrets.CLOUDPAYMENTS_GEM_HOST_API_KEY || secrets.GEM_HOST_API_KEY }}