Skip to content

Commit ed1991b

Browse files
authored
Merge pull request rails#52962 from rails/rm-releser
New release process using Trusted Publishing
2 parents d6e250d + 6929047 commit ed1991b

File tree

44 files changed

+899
-385
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+899
-385
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Rails releaser tests
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "tools/releaser/**"
7+
push:
8+
paths:
9+
- "tools/releaser/**"
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
releaser_tests:
16+
name: releaser tests
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up Ruby
22+
uses: ruby/setup-ruby@v1
23+
with:
24+
ruby-version: ruby
25+
- name: Bundle install
26+
run: bundle install
27+
working-directory: tools/releaser
28+
- run: bundle exec rake
29+
working-directory: tools/releaser

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
release:
9+
permissions:
10+
contents: write
11+
id-token: write
12+
13+
environment: release
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Set up Ruby
20+
uses: ruby/setup-ruby@v1
21+
with:
22+
ruby-version: ruby
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: lts/*
26+
registry-url: 'https://registry.npmjs.org'
27+
- name: Configure trusted publishing credentials
28+
uses: rubygems/[email protected]
29+
- name: Bundle install
30+
run: bundle install
31+
working-directory: tools/releaser
32+
- name: Run release rake task
33+
run: bundle exec rake push
34+
shell: bash
35+
working-directory: tools/releaser
36+
env:
37+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
38+
- name: Wait for release to propagate
39+
run: gem exec rubygems-await pkg/*.gem
40+
shell: bash

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ gem "minitest"
88
# We need a newish Rake since Active Job sets its test tasks' descriptions.
99
gem "rake", ">= 13"
1010

11+
gem "releaser", path: "tools/releaser"
12+
1113
gem "sprockets-rails", ">= 2.0.0", require: false
1214
gem "propshaft", ">= 0.1.7"
1315
gem "capybara", ">= 3.39"

Gemfile.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ PATH
121121
thor (~> 1.0, >= 1.2.2)
122122
zeitwerk (~> 2.6)
123123

124+
PATH
125+
remote: tools/releaser
126+
specs:
127+
releaser (1.0.0)
128+
minitest
129+
rake (~> 13.0)
130+
124131
GEM
125132
remote: https://rubygems.org/
126133
specs:
@@ -689,6 +696,7 @@ DEPENDENCIES
689696
redcarpet (~> 3.2.3)
690697
redis (>= 4.0.1)
691698
redis-namespace
699+
releaser!
692700
resque
693701
resque-scheduler
694702
rexml

RELEASING_RAILS.md

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Obviously Rails cannot be released when it depends on unreleased code.
2424
Contact the authors of those particular gems and work out a release date that
2525
suits them.
2626

27-
### Announce your plans to the rest of the team on Campfire
27+
### Announce your plans to the rest of the team on Basecamp
2828

2929
Let them know of your plans to release.
3030

@@ -56,58 +56,38 @@ Include an RC number if appropriate, e.g. `6.0.0.rc1`.
5656

5757
### Build and test the gem.
5858

59-
Run `rake verify` to generate the gems and install them locally. `verify` also
60-
generates a Rails app with a migration and boots it to smoke test with in your
61-
browser.
59+
Run `rake install` to generate the gems and install them locally. You can now
60+
use the version installed locally to generate a new app and check if everything
61+
is working as expected.
6262

6363
This will stop you from looking silly when you push an RC to rubygems.org and
6464
then realize it is broken.
6565

66-
### Check credentials for RubyGems, npm, and GitHub
67-
68-
For npm run `npm whoami` to check that you are logged in (`npm login` if not).
69-
70-
For RubyGems run `gem login`. If there's no output you are logged in.
66+
### Check credentials for GitHub
7167

7268
For GitHub run `gh auth status` to check that you are logged in (run `gh login` if not).
7369

74-
npm and RubyGems require MFA. The release task will attempt to use a yubikey if
75-
available, which as we have release several packages at once is strongly
76-
recommended. Check that `ykman oath accounts list` has an entry for both
77-
`npmjs.com` and `rubygems.org`, if not refer to
78-
https://tenderlovemaking.com/2021/10/26/publishing-gems-with-your-yubikey.html
79-
for setup instructions.
80-
81-
### Release to RubyGems and npm.
82-
83-
IMPORTANT: Several gems have JavaScript components that are released as npm
84-
packages, so you must have Node.js installed, have an npm account (npmjs.com),
85-
and be a package owner for `@rails/actioncable`, `@rails/actiontext`, and
86-
`@rails/activestorage`. You can check this by making sure your
87-
npm user (`npm whoami`) is listed as an owner (`npm owner ls <pkg>`) of each
88-
package. Do not release until you're set up with npm!
89-
9070
The release task will sign the release tag. If you haven't got commit signing
9171
set up, use https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work as a
9272
guide. You can generate keys with the GPG suite from here: https://gpgtools.org.
9373

94-
Run `rake changelog:header` to put a header with the new version in every
95-
CHANGELOG. Don't commit this, the release task handles it.
74+
Run `rake prep_release` to prepare the release. This will populate the gemspecs and
75+
npm package.json with the current RAILS_VERSION, add the header to the CHANGELOGs,
76+
build the gems, and check if bundler can resolve the dependencies.
9677

97-
Run `rake release`. This will populate the gemspecs and npm package.json with
98-
the current RAILS_VERSION, commit the changes, tag it, and push the gems to
99-
rubygems.org.
78+
You can now inspect the results in the diff and see if you are happy with the
79+
changes.
10080

101-
### Make GitHub Releases from pushed tags
81+
To release, Run `rake release`. This will commit the changes, tag it, and create a GitHub
82+
release with the proper release notes in draft mode.
10283

103-
We use GitHub Releases to publish the combined release summary for all gems. We
104-
can use a rake task and [GitHub cli](https://cli.github.com/) to do this
105-
(releases can also be created or edited on the web).
84+
Open the corresponding GitHub release draft and check that the release notes
85+
are correct. If everything is fine, publish the release.
10686

107-
```
108-
bundle exec rake changelog:release_summary > ../6-1-7-release-summary.md
109-
gh release create v6.1.7 -R rails/rails -F ../6-1-7-release-summary.md
110-
```
87+
### Publish the gems
88+
89+
To publish the gems approve the [Release workflow in GitHub Actions](https://github.com/rails/rails/actions/workflows/release.yml),
90+
that was created after the release was published.
11191

11292
### Send Rails release announcements
11393

@@ -117,7 +97,6 @@ lists where you should announce:
11797

11898
* [rubyonrails-core](https://discuss.rubyonrails.org/c/rubyonrails-core)
11999
* [rubyonrails-talk](https://discuss.rubyonrails.org/c/rubyonrails-talk)
120-
121100

122101
Use Markdown format for your announcement. Remember to ask people to report
123102
issues with the release candidate to the rails-core mailing list.

Rakefile

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,14 @@ require "tasks/release"
77
require "railties/lib/rails/api/task"
88
require "tools/preview_docs"
99

10-
desc "Build gem files for all projects"
11-
task build: "all:build"
12-
13-
desc "Build, install and verify the gem files in a generated Rails app."
14-
task verify: "all:verify"
15-
16-
desc "Prepare the release"
17-
task prep_release: "all:prep_release"
18-
19-
desc "Release all gems to rubygems and create a tag"
20-
task release: "all:release"
21-
2210
desc "Run all tests by default"
2311
task default: %w(test test:isolated)
2412

25-
%w(test test:isolated package gem).each do |task_name|
13+
%w(test test:isolated).each do |task_name|
2614
desc "Run #{task_name} task for all projects"
2715
task task_name do
2816
errors = []
29-
FRAMEWORKS.each do |project|
17+
Releaser::FRAMEWORKS.each do |project|
3018
system(%(cd #{project} && #{$0} #{task_name} --trace)) || errors << project
3119
end
3220
fail("Errors in #{errors.join(', ')}") unless errors.empty?
@@ -35,10 +23,10 @@ end
3523

3624
desc "Smoke-test all projects"
3725
task :smoke, [:frameworks, :isolated] do |task, args|
38-
frameworks = args[:frameworks] ? args[:frameworks].split(" ") : FRAMEWORKS
26+
frameworks = args[:frameworks] ? args[:frameworks].split(" ") : Releaser::FRAMEWORKS
3927
# The arguments are positional, and users may want to specify only the isolated flag.. so we allow 'all' as a default for the first argument:
4028
if frameworks.include?("all")
41-
frameworks = FRAMEWORKS
29+
frameworks = Releaser::FRAMEWORKS
4230
end
4331

4432
isolated = args[:isolated].nil? ? true : args[:isolated] == "true"
@@ -54,9 +42,6 @@ task :smoke, [:frameworks, :isolated] do |task, args|
5442
end
5543
end
5644

57-
desc "Install gems for all projects."
58-
task install: "all:install"
59-
6045
desc "Generate documentation for the Rails framework"
6146
if ENV["EDGE"]
6247
Rails::API::EdgeTask.new("rdoc")
@@ -78,9 +63,6 @@ task :preview_docs do
7863
system("tar -czf preview.tar.gz -C preview .")
7964
end
8065

81-
desc "Bump all versions to match RAILS_VERSION"
82-
task update_versions: "all:update_versions"
83-
8466
# We have a webhook configured in GitHub that gets invoked after pushes.
8567
# This hook triggers the following tasks:
8668
#

actioncable/Rakefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ require "action_cable"
88

99
task default: :test
1010

11-
task :package
12-
1311
ENV["RAILS_MINITEST_PLUGIN"] = "true"
1412

1513
Rake::TestTask.new do |t|

actionmailbox/Rakefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ require "bundler/setup"
44
require "bundler/gem_tasks"
55
require "rake/testtask"
66

7-
task :package
8-
97
ENV["RAILS_MINITEST_PLUGIN"] = "true"
108

119
Rake::TestTask.new do |t|

actionmailer/Rakefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ require "rake/testtask"
55
desc "Default Task"
66
task default: [ :test ]
77

8-
task :package
9-
108
ENV["RAILS_MINITEST_PLUGIN"] = "true"
119

1210
# Run the unit tests

actionpack/Rakefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ test_files = FileList["test/**/*_test.rb"]
77
desc "Default Task"
88
task default: :test
99

10-
task :package
11-
1210
ENV["RAILS_MINITEST_PLUGIN"] = "true"
1311

1412
# Run the unit tests

0 commit comments

Comments
 (0)