From a8be7ddc92ef744e8de9a2789fff024597386fb8 Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Mon, 23 Nov 2026 16:53:03 +0100 Subject: [PATCH 1/4] fix: keep lib/flagsmith/version.rb in sync with releases release-please's ruby strategy derives the version file path from the package name, which was not set, so it silently skipped lib/flagsmith/version.rb and Gemfile.lock. Every 5.x release was tagged with VERSION still at 4.3.0, which is also what the SDK reports in its user agent and analytics metadata. Set package-name and version-file so release-please bumps both files, and bring them up to date with the latest release (5.4.0). --- Gemfile.lock | 2 +- lib/flagsmith/version.rb | 2 +- release-please-config.json | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c316d44..fe7adac 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - flagsmith (4.3.0) + flagsmith (5.4.0) faraday (>= 2.0.1) faraday-retry jsonpath (~> 1.1) diff --git a/lib/flagsmith/version.rb b/lib/flagsmith/version.rb index 602d897..64008d8 100644 --- a/lib/flagsmith/version.rb +++ b/lib/flagsmith/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Flagsmith - VERSION = '4.3.0' + VERSION = '5.4.0' end diff --git a/release-please-config.json b/release-please-config.json index 72ebda0..0bff67d 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -3,6 +3,8 @@ "packages": { ".": { "release-type": "ruby", + "package-name": "flagsmith", + "version-file": "lib/flagsmith/version.rb", "changelog-path": "CHANGELOG.md", "bump-minor-pre-major": false, "bump-patch-for-minor-pre-major": false, From 046488c23adac4a02cf785e78b96897722637256 Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Mon, 23 Nov 2026 16:53:03 +0100 Subject: [PATCH 2/4] ci: publish gem to RubyGems via trusted publishing The Push Ruby Gem workflow was switched to manual-only in 2023 because it failed consistently. It ran `rake release[remote]`, which builds the gem and then tries to push a branch and tag to a git remote called `remote` that does not exist (from a detached tag checkout), before ever pushing the gem. It also relied on a long-lived GEM_HOST_API_KEY, which cannot push without an OTP now that the gemspec sets rubygems_mfa_required. Rewrite it to run when release-please publishes a release (as the Python SDK does), keeping workflow_dispatch for backfills: - build job (contents: read): check the version in lib/flagsmith/version.rb matches the release tag, run gem build and upload the .gem as an artifact. - publish job (id-token: write only, rubygems environment): download the artifact and gem push it using short-lived credentials from RubyGems trusted publishing via rubygems/configure-rubygems-credentials. No git operations or secrets are needed, nothing is inherited from the workflow-level permissions, and all actions are pinned to commit SHAs. --- .github/workflows/publish.yaml | 90 ++++++++++++++++++++++++++++------ 1 file changed, 74 insertions(+), 16 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 6bd001c..07576a1 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -1,27 +1,85 @@ -# This workflow will build the gem from gemspec and publish +# Builds the gem and publishes it to RubyGems.org using trusted publishing (OIDC). +# +# Runs automatically when release-please publishes a GitHub release. It can also be +# triggered manually (e.g. to backfill a release) from either the release tag or from +# main, in which case the version in lib/flagsmith/version.rb must already be tagged. name: Push Ruby Gem -# TODO: this workflow doesn't work, needs fixing but for now, I've just changed it so -# it will only run if triggered manually. Instructions for releasing manually are here: -# https://www.notion.so/flagsmith/SDKs-Deployment-Instructions-c1190a22238a45af9a51c7f0fea27f99 -on: workflow_dispatch +on: + release: + types: [published] + workflow_dispatch: + +permissions: {} jobs: - release: + build: runs-on: ubuntu-latest - env: - GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }} + + permissions: + contents: read + steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - fetch-depth: 0 # need all the commits - - uses: ruby/setup-ruby@v1 + persist-credentials: false + + - uses: ruby/setup-ruby@be3c7df29b3349ec6bcfc6b4792f1cf9f5237d18 # v1.343.0 with: ruby-version: .ruby-version - bundler-cache: true - - name: Buld and Push to rubygems.org + + - name: Check gem version matches release tag + env: + RELEASE_TAG: ${{ github.event.release.tag_name }} + REF_NAME: ${{ github.ref_name }} + REF_TYPE: ${{ github.ref_type }} run: | - bundle install - gem build flagsmith.gemspec - bundle exec rake release[remote] + version=$(ruby -r ./lib/flagsmith/version -e 'print Flagsmith::VERSION') + if [ -n "$RELEASE_TAG" ]; then + tag="$RELEASE_TAG" + elif [ "$REF_TYPE" = tag ]; then + tag="$REF_NAME" + else + tag="v$version" + if ! git ls-remote --exit-code --tags origin "refs/tags/$tag" > /dev/null; then + echo "::error::Version $version from lib/flagsmith/version.rb has no $tag tag; refusing to publish an unreleased version." + exit 1 + fi + fi + if [ "$tag" != "v$version" ]; then + echo "::error::Tag $tag does not match version $version in lib/flagsmith/version.rb." + exit 1 + fi + echo "Building flagsmith $version for tag $tag" + + - name: Build gem + run: gem build flagsmith.gemspec + + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: gem + path: flagsmith-*.gem + if-no-files-found: error + + publish: + runs-on: ubuntu-latest + needs: build + environment: rubygems + + permissions: + id-token: write # to authenticate with RubyGems.org via trusted publishing + + steps: + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: gem + + - uses: ruby/setup-ruby@be3c7df29b3349ec6bcfc6b4792f1cf9f5237d18 # v1.343.0 + with: + ruby-version: ruby + + - uses: rubygems/configure-rubygems-credentials@dc5a8d8553e6ee01fc26761a49e99e733d17954a # v2.1.0 + + - name: Push gem to RubyGems.org + run: gem push flagsmith-*.gem From 59b18a99c13d03c13276eb757984b017a4173f07 Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Mon, 23 Nov 2026 17:01:45 +0100 Subject: [PATCH 3/4] ci: only allow manual gem publishing from main or a release tag --- .github/workflows/publish.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 07576a1..0bcdf3a 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -40,12 +40,15 @@ jobs: tag="$RELEASE_TAG" elif [ "$REF_TYPE" = tag ]; then tag="$REF_NAME" - else + elif [ "$REF_NAME" = main ]; then tag="v$version" if ! git ls-remote --exit-code --tags origin "refs/tags/$tag" > /dev/null; then echo "::error::Version $version from lib/flagsmith/version.rb has no $tag tag; refusing to publish an unreleased version." exit 1 fi + else + echo "::error::Manual runs must start from main or a release tag, not $REF_NAME." + exit 1 fi if [ "$tag" != "v$version" ]; then echo "::error::Tag $tag does not match version $version in lib/flagsmith/version.rb." From 7c8aaa0425143c43819edb39787cf3c1ea4ed273 Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Mon, 23 Nov 2026 17:10:41 +0100 Subject: [PATCH 4/4] ci: only publish gems from release tags --- .github/workflows/publish.yaml | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 0bcdf3a..05d3554 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -1,8 +1,7 @@ # Builds the gem and publishes it to RubyGems.org using trusted publishing (OIDC). # # Runs automatically when release-please publishes a GitHub release. It can also be -# triggered manually (e.g. to backfill a release) from either the release tag or from -# main, in which case the version in lib/flagsmith/version.rb must already be tagged. +# triggered manually from a release tag, e.g. to retry a failed publish. name: Push Ruby Gem @@ -16,6 +15,8 @@ permissions: {} jobs: build: runs-on: ubuntu-latest + # Only ever publish tagged code: release events run on the release tag, and manual runs must pick one too. + if: github.ref_type == 'tag' permissions: contents: read @@ -29,33 +30,6 @@ jobs: with: ruby-version: .ruby-version - - name: Check gem version matches release tag - env: - RELEASE_TAG: ${{ github.event.release.tag_name }} - REF_NAME: ${{ github.ref_name }} - REF_TYPE: ${{ github.ref_type }} - run: | - version=$(ruby -r ./lib/flagsmith/version -e 'print Flagsmith::VERSION') - if [ -n "$RELEASE_TAG" ]; then - tag="$RELEASE_TAG" - elif [ "$REF_TYPE" = tag ]; then - tag="$REF_NAME" - elif [ "$REF_NAME" = main ]; then - tag="v$version" - if ! git ls-remote --exit-code --tags origin "refs/tags/$tag" > /dev/null; then - echo "::error::Version $version from lib/flagsmith/version.rb has no $tag tag; refusing to publish an unreleased version." - exit 1 - fi - else - echo "::error::Manual runs must start from main or a release tag, not $REF_NAME." - exit 1 - fi - if [ "$tag" != "v$version" ]; then - echo "::error::Tag $tag does not match version $version in lib/flagsmith/version.rb." - exit 1 - fi - echo "Building flagsmith $version for tag $tag" - - name: Build gem run: gem build flagsmith.gemspec