Skip to content

Commit

Permalink
Merge pull request #16 from rubygems/segiddins/add-support-for-releas…
Browse files Browse the repository at this point in the history
…ing-on-release-published

Add support for releasing on release published
  • Loading branch information
segiddins authored Nov 19, 2024
2 parents ff92ed6 + 51b3cf2 commit f424022
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/push_gem.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Push Gem

on:
push:
tags:
- 'v*'
release:
types:
- published

permissions:
contents: read
Expand All @@ -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
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
15 changes: 11 additions & 4 deletions lib/configure_trusted_publisher/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion lib/configure_trusted_publisher/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ConfigureTrustedPublisher
VERSION = "0.1.10"
VERSION = "0.2.0"
end

0 comments on commit f424022

Please sign in to comment.