Skip to content

Commit 80eb21e

Browse files
Modernize release process for monorepo (#1856)
* Modernize release process for monorepo - Replace release-it with native Yarn workspace publish commands - Update release rake task to handle both NPM packages (react-on-rails and react-on-rails-pro) - Synchronize versions across gem and both NPM packages - Set react-on-rails-pro to use exact version dependency on react-on-rails - Remove obsolete release scripts from package.json files - Delete packages/react-on-rails/scripts/release - Update documentation with comprehensive release instructions The new release process: 1. Bumps version in lib/react_on_rails/version.rb (source of truth) 2. Updates all 3 package.json files with new version 3. Updates react-on-rails-pro dependency to exact version 4. Commits, tags, and pushes changes 5. Publishes both NPM packages using yarn workspace publish 6. Publishes Ruby gem Benefits: - No external release-it dependency - Both NPM packages properly released - Version sync enforced across all 5 files - Single command releases everything: rake release[X.Y.Z] 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com> * Fix syntax error and RuboCop violations in release.rake - Remove extra end statement that was causing syntax error - Fix string concatenation to use interpolation - Fix operator precedence ambiguity - Convert multi-line unless blocks to modifier form - Refactor unless/else to if/else for clarity - Fix line length violation - Eliminate duplicate separator line code All RuboCop violations resolved. File now passes bundle exec rubocop with zero offenses. * Add skip_push option to release task - Add 4th argument 'skip_push' to skip git push operations - Useful for testing the release process locally - Commits and tags are still created, but not pushed to remote - Displays warning message when push is skipped - Update documentation with new parameter and example usage Example: rake release[16.2.0,false,npm,skip_push] 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Add parameter validation for registry and skip_push - Validate registry parameter accepts only: 'verdaccio', 'npm', or empty string - Validate skip_push parameter accepts only: 'skip_push' or empty string - Raise ArgumentError with clear message for invalid values - Prevents silent failures from typos or incorrect usage Examples of errors: rake release[16.2.0,false,foo] → ArgumentError: Invalid registry value 'foo' rake release[16.2.0,false,npm,skip] → ArgumentError: Invalid skip_push value 'skip' 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * run bundle on the gem root while releasing * update dependency version of rorp package to 16.1.2 * Revert "update dependency version of rorp package to 16.1.2" This reverts commit 324fb8c. * update dependency version of rorp package to 16.1.1 --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 486ab53 commit 80eb21e

File tree

6 files changed

+340
-107
lines changed

6 files changed

+340
-107
lines changed

docs/contributor-info/releasing.md

Lines changed: 151 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,185 @@
11
# Install and Release
22

3-
We're now releasing this as a combined ruby gem plus npm package. We will keep the version numbers in sync.
3+
We're releasing this as a combined Ruby gem plus two NPM packages. We keep the version numbers in sync across all packages.
44

55
## Testing the Gem before Release from a Rails App
66

77
See [Contributing](https://github.com/shakacode/react_on_rails/tree/master/CONTRIBUTING.md)
88

9-
## Releasing a new gem version
9+
## Releasing a New Version
1010

1111
Run `rake -D release` to see instructions on how to release via the rake task.
1212

13-
As of 01-26-2016, this would give you an output like this:
13+
### Release Command
1414

15+
```bash
16+
rake release[gem_version,dry_run]
1517
```
16-
rake release[gem_version,dry_run,tools_install]
17-
Releases both the gem and node package using the given version.
1818

19-
IMPORTANT: the gem version must be in valid rubygem format (no dashes).
20-
It will be automatically converted to a valid npm semver by the rake task
21-
for the node package version. This only makes a difference for pre-release
22-
versions such as `3.0.0.beta.1` (npm version would be `3.0.0-beta.1`).
19+
**Arguments:**
2320

24-
This task will also globally install gem-release (ruby gem) and
25-
release-it (node package) unless you specify skip installing tools.
21+
- `gem_version`: The new version in rubygem format (no dashes). Pass no argument to automatically perform a patch version bump.
22+
- `dry_run`: Optional. Pass `true` to see what would happen without actually releasing.
2623

27-
2nd argument: Perform a dry run by passing 'true' as a second argument.
28-
3rd argument: Skip installing tools by passing 'false' as a third argument (default is true).
24+
**Example:**
2925

30-
Example: `rake release[2.1.0,false,false]`
26+
```bash
27+
rake release[16.2.0] # Release version 16.2.0
28+
rake release[16.2.0,true] # Dry run to preview changes
29+
rake release # Auto-bump patch version
3130
```
3231

33-
Running `rake release[2.1.0]` will create a commit that looks like this:
32+
### What Gets Released
3433

34+
The release task publishes three packages with the same version number:
35+
36+
1. **react-on-rails** NPM package
37+
2. **react-on-rails-pro** NPM package
38+
3. **react_on_rails** Ruby gem
39+
40+
### Version Synchronization
41+
42+
The task updates versions in all the following files:
43+
44+
- `lib/react_on_rails/version.rb` (source of truth)
45+
- `package.json` (root workspace)
46+
- `packages/react-on-rails/package.json`
47+
- `packages/react-on-rails-pro/package.json` (both version field and react-on-rails dependency)
48+
- `spec/dummy/Gemfile.lock`
49+
50+
**Note:** The `react-on-rails-pro` package declares an exact version dependency on `react-on-rails` (e.g., `"react-on-rails": "16.2.0"`). This ensures users install compatible versions of both packages.
51+
52+
### Pre-release Versions
53+
54+
For pre-release versions, the gem version format is automatically converted to NPM semver format:
55+
56+
- Gem: `3.0.0.beta.1`
57+
- NPM: `3.0.0-beta.1`
58+
59+
### Release Process
60+
61+
When you run `rake release[X.Y.Z]`, the task will:
62+
63+
1. Check for uncommitted changes (will abort if found)
64+
2. Pull latest changes from the remote repository
65+
3. Clean up example directories
66+
4. Bump the gem version in `lib/react_on_rails/version.rb`
67+
5. Update all package.json files with the new version
68+
6. Update the Pro package's dependency on react-on-rails
69+
7. Update the dummy app's Gemfile.lock
70+
8. Commit all version changes with message "Bump version to X.Y.Z"
71+
9. Create a git tag `vX.Y.Z`
72+
10. Push commits and tags to the remote repository
73+
11. Publish `react-on-rails` to NPM (requires 2FA token)
74+
12. Publish `react-on-rails-pro` to NPM (requires 2FA token)
75+
13. Publish `react_on_rails` to RubyGems (requires 2FA token)
76+
77+
### Two-Factor Authentication
78+
79+
You'll need to enter OTP tokens when prompted:
80+
81+
- Once for publishing `react-on-rails` to NPM
82+
- Once for publishing `react-on-rails-pro` to NPM
83+
- Once for publishing `react_on_rails` to RubyGems
84+
85+
### Post-Release Steps
86+
87+
After a successful release, you'll see instructions to:
88+
89+
1. Update the CHANGELOG.md:
90+
91+
```bash
92+
bundle exec rake update_changelog
93+
```
94+
95+
2. Update the dummy app's Gemfile.lock:
96+
97+
```bash
98+
cd spec/dummy && bundle update react_on_rails
99+
```
100+
101+
3. Commit the CHANGELOG and Gemfile.lock:
102+
```bash
103+
cd /path/to/react_on_rails
104+
git commit -a -m 'Update CHANGELOG.md and spec/dummy Gemfile.lock'
105+
git push
106+
```
107+
108+
## Requirements
109+
110+
This task depends on the `gem-release` Ruby gem, which is installed via `bundle install`.
111+
112+
For NPM publishing, you must be logged in to npm and have publish permissions for both packages:
113+
114+
```bash
115+
npm login
35116
```
36-
commit d07005cde9784c69e41d73fb9a0ebe8922e556b3
37-
Author: Rob Wise <robert.wise@outlook.com>
38-
Date: Tue Jan 26 19:49:14 2016 -0500
39117

40-
Release 2.1.0
118+
## Troubleshooting
119+
120+
### Dry Run First
121+
122+
Always test with a dry run before actually releasing:
123+
124+
```bash
125+
rake release[16.2.0,true]
126+
```
127+
128+
This shows you exactly what would be updated without making any changes.
129+
130+
### If Release Fails
131+
132+
If the release fails partway through (e.g., during NPM publish):
133+
134+
1. Check what was published:
135+
136+
- NPM: `npm view react-on-rails@X.Y.Z`
137+
- RubyGems: `gem list react_on_rails -r -a`
138+
139+
2. If the git tag was created but packages weren't published:
140+
141+
- Delete the tag: `git tag -d vX.Y.Z && git push origin :vX.Y.Z`
142+
- Revert the version commit: `git reset --hard HEAD~1 && git push -f`
143+
- Start over with `rake release[X.Y.Z]`
144+
145+
3. If some packages were published but not others:
146+
- You can manually publish the missing packages:
147+
```bash
148+
cd packages/react-on-rails && yarn publish --new-version X.Y.Z
149+
cd ../react-on-rails-pro && yarn publish --new-version X.Y.Z
150+
gem release
151+
```
152+
153+
## Version History
154+
155+
Running `rake release[X.Y.Z]` will create a commit that looks like this:
156+
157+
```
158+
commit abc123...
159+
Author: Your Name <your.email@example.com>
160+
Date: Mon Jan 1 12:00:00 2024 -0500
161+
162+
Bump version to 16.2.0
41163

42164
diff --git a/lib/react_on_rails/version.rb b/lib/react_on_rails/version.rb
43-
index 3de9606..b71aa7a 100644
165+
index 1234567..abcdefg 100644
44166
--- a/lib/react_on_rails/version.rb
45167
+++ b/lib/react_on_rails/version.rb
46168
@@ -1,3 +1,3 @@
47169
module ReactOnRails
48-
- VERSION = "2.0.2".freeze
49-
+ VERSION = "2.1.0".freeze
170+
- VERSION = "16.1.1"
171+
+ VERSION = "16.2.0"
50172
end
173+
51174
diff --git a/package.json b/package.json
52-
index aa7b000..af8761e 100644
175+
index 2345678..bcdefgh 100644
53176
--- a/package.json
54177
+++ b/package.json
55178
@@ -1,6 +1,6 @@
56179
{
57-
"name": "react-on-rails",
58-
- "version": "2.0.2",
59-
+ "version": "2.1.0",
60-
"description": "react-on-rails JavaScript for react_on_rails Ruby gem",
61-
"main": "packages/react-on-rails/lib/ReactOnRails.js",
62-
"directories": {
63-
diff --git a/spec/dummy/Gemfile.lock b/spec/dummy/Gemfile.lock
64-
index 8ef51df..4489bfe 100644
65-
--- a/spec/dummy/Gemfile.lock
66-
+++ b/spec/dummy/Gemfile.lock
67-
@@ -1,7 +1,7 @@
68-
PATH
69-
remote: ../..
70-
specs:
71-
- react_on_rails (2.0.2)
72-
+ react_on_rails (2.1.0)
73-
connection_pool
74-
execjs (~> 2.5)
75-
rails (>= 3.2)
76-
(END)
180+
"name": "react-on-rails-workspace",
181+
- "version": "16.1.1",
182+
+ "version": "16.2.0",
183+
...
184+
}
77185
```

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@
7070
"yalc:publish": "yarn workspaces run yalc:publish",
7171
"yalc": "yarn workspaces run yalc",
7272
"publish": "yarn workspaces run publish",
73-
"release:patch": "yarn workspaces run release:patch",
74-
"release:minor": "yarn workspaces run release:minor",
75-
"release:major": "yarn workspaces run release:major",
7673
"postinstall": "test -f .lefthook.yml && test -d .git && command -v bundle >/dev/null 2>&1 && bundle exec lefthook install || true"
7774
},
7875
"repository": {

packages/react-on-rails-pro/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"./ServerComponentFetchError": "./lib/ServerComponentFetchError.js"
5555
},
5656
"dependencies": {
57-
"react-on-rails": "*"
57+
"react-on-rails": "16.1.1"
5858
},
5959
"peerDependencies": {
6060
"react": ">= 16",

packages/react-on-rails/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
"prepare": "nps build.prepack",
1515
"prepublishOnly": "yarn run build",
1616
"yalc:publish": "yalc publish",
17-
"yalc": "yalc",
18-
"release:patch": "./scripts/release patch",
19-
"release:minor": "./scripts/release minor",
20-
"release:major": "./scripts/release major"
17+
"yalc": "yalc"
2118
},
2219
"repository": {
2320
"type": "git",

packages/react-on-rails/scripts/release

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)