From 40ff2aff62cbb2ef9ddbccaae140c939362a91b1 Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Mon, 12 Feb 2024 15:11:30 -0700 Subject: [PATCH] add GitHub release workflow (#28) using RubyGems Trusted Publishers --- .github/workflows/release.yml | 46 +++++++++++++++++++++++++++++++++++ Gemfile.lock | 2 ++ Gemfile.ruby-2.6.lock | 2 ++ bundler-multilock.gemspec | 1 + 4 files changed, 51 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..66ac3f6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +name: Release a New Version + +on: + workflow_dispatch: + inputs: + version: + description: "New Version. major|minor|patch|rc or an explicit version number." + required: true + default: patch + type: string + +permissions: + contents: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + id-token: write + outputs: + new_version: ${{ steps.bump_version.outputs.new_version }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - uses: git-actions/set-user@v1 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2 + bundler-cache: true + rubygems: latest + - name: Bump version + id: bump_version + env: + GH_TOKEN: ${{ github.token }} + run: | + bundle config unset deployment + bundle exec gem bump -v ${{ inputs.version }} -m "v%{version}" + bundle install + git add Gemfile.lock Gemfile.ruby-2.6.lock + git commit --amend --no-edit + - uses: rubygems/release-gem@v1 diff --git a/Gemfile.lock b/Gemfile.lock index 5a21bfc..978dd05 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,6 +13,7 @@ GEM irb (~> 1.10) reline (>= 0.3.8) diff-lcs (1.5.0) + gem-release (2.2.2) io-console (0.7.2) irb (1.11.0) rdoc @@ -91,6 +92,7 @@ PLATFORMS DEPENDENCIES bundler-multilock! debug (~> 1.9) + gem-release (~> 2.2) irb (~> 1.11) rake (~> 13.0) rspec (~> 3.12) diff --git a/Gemfile.ruby-2.6.lock b/Gemfile.ruby-2.6.lock index 02e5c86..a52884e 100644 --- a/Gemfile.ruby-2.6.lock +++ b/Gemfile.ruby-2.6.lock @@ -11,6 +11,7 @@ GEM irb (>= 1.5.0) reline (>= 0.3.1) diff-lcs (1.5.0) + gem-release (2.2.2) io-console (0.7.2) irb (1.6.3) reline (>= 0.3.0) @@ -42,6 +43,7 @@ PLATFORMS DEPENDENCIES bundler-multilock! debug (= 1.8.0) + gem-release (~> 2.2) irb (= 1.6.3) rake (~> 13.0) rspec (~> 3.12) diff --git a/bundler-multilock.gemspec b/bundler-multilock.gemspec index 9016c2a..538bddf 100644 --- a/bundler-multilock.gemspec +++ b/bundler-multilock.gemspec @@ -18,6 +18,7 @@ Gem::Specification.new do |spec| spec.add_dependency "bundler", ">= 2.4.19", "< 2.6" + spec.add_development_dependency "gem-release", "~> 2.2" spec.add_development_dependency "rake", "~> 13.0" spec.add_development_dependency "rspec", "~> 3.12" end