diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index 224f46d..551c07e 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -1,9 +1,9 @@ name: Push Gem on: - push: - tags: - - 'v*' + release: + types: + - published permissions: contents: read @@ -24,16 +24,16 @@ jobs: steps: # Set up - name: Harden Runner - uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1 + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: egress-policy: audit - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Ruby - uses: ruby/setup-ruby@cacc9f1c0b3f4eb8a16a6bb0ed10897b43b9de49 # v1.176.0 + uses: ruby/setup-ruby@a2bbe5b1b236842c1cb7dd11e8e3b51e0a616acc # v1.202.0 with: bundler-cache: true ruby-version: ruby # Release - - uses: rubygems/release-gem@612653d273a73bdae1df8453e090060bb4db5f31 # v1 + - uses: rubygems/release-gem@e6d709aa18a7ef2f2d758411014ca0077aeac188 diff --git a/Gemfile.lock b/Gemfile.lock index 5ae128d..4457eec 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - configure_trusted_publisher (0.1.10) + configure_trusted_publisher (0.2.0) bundler (~> 2.5) command_kit (~> 0.5.5) diff --git a/lib/configure_trusted_publisher/cli.rb b/lib/configure_trusted_publisher/cli.rb index f3e7e44..b3216fa 100644 --- a/lib/configure_trusted_publisher/cli.rb +++ b/lib/configure_trusted_publisher/cli.rb @@ -294,10 +294,12 @@ def gemspec def write_release_action(repository, rubygem_name, environment: nil) tag = "Automatically when a new tag matching v* is pushed" manual = "Manually by running a GitHub Action" + release = "Automatically when a new GitHub release is published" puts response = ask_multiple_choice( "How would you like releases for #{rubygem_name} to be triggered?", [ tag, + release, manual ], default: "2" @@ -312,7 +314,12 @@ def write_release_action(repository, rubygem_name, environment: nil) "name: Push Gem", nil, "on:", - " #{response == tag ? "push:\n tags:\n - 'v*'" : 'workflow_dispatch:'}", + (case response + when tag then " push:\n tags:\n - 'v*'" + when release then " release:\n types:\n - published" + when manual then " workflow_dispatch:" + else raise "Unknown response: #{response.inspect}" + end), nil, "permissions:", " contents: read", @@ -331,13 +338,13 @@ def write_release_action(repository, rubygem_name, environment: nil) " steps:", " # Set up", " - name: Harden Runner", - " uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1", + " uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2", " with:", " egress-policy: audit", nil, - " - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4", + " - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2", " - name: Set up Ruby", - " uses: ruby/setup-ruby@cacc9f1c0b3f4eb8a16a6bb0ed10897b43b9de49 # v1.176.0", + " uses: ruby/setup-ruby@a2bbe5b1b236842c1cb7dd11e8e3b51e0a616acc # v1.202.0", " with:", " bundler-cache: true", " ruby-version: ruby", diff --git a/lib/configure_trusted_publisher/version.rb b/lib/configure_trusted_publisher/version.rb index 1e26eab..a5b8f0f 100644 --- a/lib/configure_trusted_publisher/version.rb +++ b/lib/configure_trusted_publisher/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module ConfigureTrustedPublisher - VERSION = "0.1.10" + VERSION = "0.2.0" end