Skip to content

Commit

Permalink
Add Trusted Publishing workflow (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
dentarg authored Jun 21, 2024
1 parent 5b7197d commit 9ed8fe7
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on:
push:
tags:
- addressable-*

jobs:
release:
if: github.repository == 'sporkmonger/addressable'
runs-on: ubuntu-latest
permissions:
id-token: write # for trusted publishing
steps:
# tags are named addressable-VERSION, e.g. addressable-2.8.6
- name: Set VERSION from git tag
run: echo "VERSION=$(echo ${{ github.ref }} | cut -d - -f 2)" >> "$GITHUB_ENV"

- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: ruby

- uses: rubygems/[email protected]

# ensure gem can be built and installed
- run: bundle exec rake gem:install

# push gem to rubygems.org
- run: gem push --verbose pkg/addressable-${VERSION}.gem
12 changes: 12 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Releasing Addressable

1. Update `CHANGELOG.md`
1. Update `lib/addressable/version.rb` with the new version
1. Run `rake gem:gemspec` to update gemspec
1. Run `rake gem:install` to sanity check your work
1. Create pull request with all that
1. Merge the pull request when CI is green
1. Ensure you have latest changes locally
1. Run`VERSION=x.y.z rake git:tag:create` to create tag in git
1. Push tag to upstream: `git push --tags upstream`
1. Watch GitHub Actions build and push the gem to RubyGems.org
3 changes: 0 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,4 @@ PKG_FILES = FileList[

task :default => "spec"

WINDOWS = (RUBY_PLATFORM =~ /mswin|win32|mingw|bccwin|cygwin/) rescue false
SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])

Dir['tasks/**/*.rake'].each { |rake| load rake }
4 changes: 2 additions & 2 deletions tasks/gem.rake
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace :gem do

desc "Install the gem"
task :install => ["clobber", "gem:package"] do
sh "#{SUDO} gem install --local pkg/#{GEM_SPEC.full_name}"
sh "gem install --local ./pkg/#{GEM_SPEC.full_name}.gem"
end

desc "Uninstall the gem"
Expand All @@ -65,7 +65,7 @@ namespace :gem do
if installed_list &&
(installed_list.collect { |s| s.version.to_s}.include?(PKG_VERSION))
sh(
"#{SUDO} gem uninstall --version '#{PKG_VERSION}' " +
"gem uninstall --version '#{PKG_VERSION}' " +
"--ignore-dependencies --executables #{PKG_NAME}"
)
end
Expand Down

0 comments on commit 9ed8fe7

Please sign in to comment.