diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 6bd001c..05d3554 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -1,27 +1,62 @@ -# 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 from a release tag, e.g. to retry a failed publish. 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 }} + # 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 + 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 - run: | - bundle install - gem build flagsmith.gemspec - bundle exec rake release[remote] + + - 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 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,