|
| 1 | +# Releasing Shakapacker |
| 2 | + |
| 3 | +This guide is for Shakapacker maintainers who need to publish a new release. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. **Install required tools:** |
| 8 | + |
| 9 | + ```bash |
| 10 | + bundle install # Installs gem-release |
| 11 | + yarn global add release-it # Installs release-it for npm publishing |
| 12 | + ``` |
| 13 | + |
| 14 | +2. **Ensure you have publishing access:** |
| 15 | + |
| 16 | + - npm: You must be a collaborator on the [shakapacker npm package](https://www.npmjs.com/package/shakapacker) |
| 17 | + - RubyGems: You must be an owner of the [shakapacker gem](https://rubygems.org/gems/shakapacker) |
| 18 | + |
| 19 | +3. **Enable 2FA on both platforms:** |
| 20 | + - npm: 2FA is required for publishing |
| 21 | + - RubyGems: 2FA is required for publishing |
| 22 | + |
| 23 | +## Release Process |
| 24 | + |
| 25 | +### 1. Prepare the Release |
| 26 | + |
| 27 | +Before running the release task: |
| 28 | + |
| 29 | +1. Ensure all desired changes are merged to `main` branch |
| 30 | +2. Update `CHANGELOG.md` with the new version and release notes |
| 31 | +3. Commit the CHANGELOG changes |
| 32 | +4. Ensure your working directory is clean (`git status` shows no uncommitted changes) |
| 33 | + |
| 34 | +### 2. Run the Release Task |
| 35 | + |
| 36 | +The automated release task handles the entire release process: |
| 37 | + |
| 38 | +```bash |
| 39 | +# For a specific version (e.g., 9.1.0) |
| 40 | +rake create_release[9.1.0] |
| 41 | + |
| 42 | +# For a beta release (note: use period, not dash) |
| 43 | +rake create_release[9.2.0.beta.1] # Creates npm package 9.2.0-beta.1 |
| 44 | + |
| 45 | +# For a patch version bump (auto-increments) |
| 46 | +rake create_release |
| 47 | + |
| 48 | +# Dry run to test without publishing |
| 49 | +rake create_release[9.1.0,true] |
| 50 | +``` |
| 51 | + |
| 52 | +### 3. What the Release Task Does |
| 53 | + |
| 54 | +The `create_release` task automatically: |
| 55 | + |
| 56 | +1. **Pulls latest changes** from the repository |
| 57 | +2. **Bumps version numbers** in: |
| 58 | + - `lib/shakapacker/version.rb` (Ruby gem version) |
| 59 | + - `package.json` (npm package version - converted from Ruby format) |
| 60 | +3. **Publishes to npm:** |
| 61 | + - Prompts for npm OTP (2FA code) |
| 62 | + - Creates git tag |
| 63 | + - Pushes to GitHub |
| 64 | +4. **Publishes to RubyGems:** |
| 65 | + - Prompts for RubyGems OTP (2FA code) |
| 66 | +5. **Updates spec/dummy lockfiles:** |
| 67 | + - Runs `bundle install` to update `Gemfile.lock` |
| 68 | + - Runs `npm install` to update `package-lock.json` (yarn.lock may also be updated for multi-package-manager compatibility testing) |
| 69 | +6. **Commits and pushes lockfile changes** automatically |
| 70 | + |
| 71 | +### 4. Version Format |
| 72 | + |
| 73 | +**Important:** Use Ruby gem version format (no dashes): |
| 74 | + |
| 75 | +- ✅ Correct: `9.1.0`, `9.2.0.beta.1`, `9.0.0.rc.2` |
| 76 | +- ❌ Wrong: `9.1.0-beta.1`, `9.0.0-rc.2` |
| 77 | + |
| 78 | +The task automatically converts Ruby gem format to npm semver format: |
| 79 | + |
| 80 | +- Ruby: `9.2.0.beta.1` → npm: `9.2.0-beta.1` |
| 81 | +- Ruby: `9.0.0.rc.2` → npm: `9.0.0-rc.2` |
| 82 | + |
| 83 | +**Examples:** |
| 84 | + |
| 85 | +```bash |
| 86 | +# Regular release |
| 87 | +rake create_release[9.1.0] # Gem: 9.1.0, npm: 9.1.0 |
| 88 | + |
| 89 | +# Beta release |
| 90 | +rake create_release[9.2.0.beta.1] # Gem: 9.2.0.beta.1, npm: 9.2.0-beta.1 |
| 91 | + |
| 92 | +# Release candidate |
| 93 | +rake create_release[10.0.0.rc.1] # Gem: 10.0.0.rc.1, npm: 10.0.0-rc.1 |
| 94 | +``` |
| 95 | + |
| 96 | +### 5. During the Release |
| 97 | + |
| 98 | +1. When prompted for **npm OTP**, enter your 2FA code from your authenticator app |
| 99 | +2. Accept defaults for release-it options |
| 100 | +3. When prompted for **RubyGems OTP**, enter your 2FA code |
| 101 | +4. The script will automatically commit and push lockfile updates |
| 102 | + |
| 103 | +### 6. After Release |
| 104 | + |
| 105 | +1. Verify the release on: |
| 106 | + |
| 107 | + - [npm](https://www.npmjs.com/package/shakapacker) |
| 108 | + - [RubyGems](https://rubygems.org/gems/shakapacker) |
| 109 | + - [GitHub releases](https://github.com/shakacode/shakapacker/releases) |
| 110 | + |
| 111 | +2. Check that the lockfile commit was pushed: |
| 112 | + |
| 113 | + ```bash |
| 114 | + git log --oneline -5 |
| 115 | + # Should see "Update spec/dummy lockfiles after release" |
| 116 | + ``` |
| 117 | + |
| 118 | +3. Announce the release (if appropriate): |
| 119 | + - Post in relevant Slack/Discord channels |
| 120 | + - Tweet about major releases |
| 121 | + - Update documentation if needed |
| 122 | + |
| 123 | +## Troubleshooting |
| 124 | + |
| 125 | +### Uncommitted Changes After Release |
| 126 | + |
| 127 | +If you see uncommitted changes to lockfiles after a release, this means: |
| 128 | + |
| 129 | +1. The release was successful but the lockfile commit step may have failed |
| 130 | +2. **Solution:** Manually commit these files: |
| 131 | + ```bash |
| 132 | + git add spec/dummy/Gemfile.lock spec/dummy/package-lock.json spec/dummy/yarn.lock |
| 133 | + git commit -m 'Update spec/dummy lockfiles after release' |
| 134 | + git push |
| 135 | + ``` |
| 136 | + |
| 137 | +### Failed npm or RubyGems Publish |
| 138 | + |
| 139 | +If publishing fails partway through: |
| 140 | + |
| 141 | +1. Check which step failed (npm or RubyGems) |
| 142 | +2. If npm failed: Fix the issue and manually run `npm publish` |
| 143 | +3. If RubyGems failed: Fix the issue and manually run `gem release` |
| 144 | +4. Then manually update and commit spec/dummy lockfiles |
| 145 | + |
| 146 | +### Wrong Version Format |
| 147 | + |
| 148 | +If you accidentally use npm format (with dashes): |
| 149 | + |
| 150 | +1. The gem will be created with an invalid version |
| 151 | +2. **Solution:** Don't push the changes, reset your branch: |
| 152 | + ```bash |
| 153 | + git reset --hard HEAD |
| 154 | + ``` |
| 155 | +3. Re-run with correct Ruby gem format |
| 156 | + |
| 157 | +## Manual Release Steps |
| 158 | + |
| 159 | +If you need to release manually (not recommended): |
| 160 | + |
| 161 | +1. **Bump version:** |
| 162 | + |
| 163 | + ```bash |
| 164 | + gem bump --version 9.1.0 |
| 165 | + bundle install |
| 166 | + ``` |
| 167 | + |
| 168 | +2. **Publish to npm:** |
| 169 | + |
| 170 | + ```bash |
| 171 | + release-it 9.1.0 --npm.publish |
| 172 | + ``` |
| 173 | + |
| 174 | +3. **Publish to RubyGems:** |
| 175 | + |
| 176 | + ```bash |
| 177 | + gem release |
| 178 | + ``` |
| 179 | + |
| 180 | +4. **Update lockfiles:** |
| 181 | + ```bash |
| 182 | + cd spec/dummy |
| 183 | + bundle install |
| 184 | + npm install |
| 185 | + cd ../.. |
| 186 | + git add spec/dummy/Gemfile.lock spec/dummy/package-lock.json spec/dummy/yarn.lock |
| 187 | + git commit -m 'Update spec/dummy lockfiles after release' |
| 188 | + git push |
| 189 | + ``` |
| 190 | + |
| 191 | +## Questions? |
| 192 | + |
| 193 | +If you encounter issues not covered here, please: |
| 194 | + |
| 195 | +1. Check the [CONTRIBUTING.md](../CONTRIBUTING.md) guide |
| 196 | +2. Ask in the maintainers channel |
| 197 | +3. Update this documentation for future releases |
0 commit comments