|
40 | 40 | ref: ${{ fromJSON(steps.release.outputs.pr).headBranchName }} |
41 | 41 | token: ${{ steps.app-token.outputs.token }} |
42 | 42 |
|
| 43 | + # Go modules require the module path and all import statements to |
| 44 | + # include the major version (e.g. /v7). release-please doesn't handle |
| 45 | + # this, so when a release PR bumps the major version we automatically |
| 46 | + # rewrite go.mod, imports, and READMEs on the release PR branch. |
| 47 | + - name: Migrate Go module path for major version bump |
| 48 | + if: steps.release.outputs.pr |
| 49 | + run: | |
| 50 | + CURRENT_MAJOR=$(grep -oP 'module github\.com/workos/workos-go/v\K[0-9]+' go.mod) |
| 51 | + NEW_VERSION=$(jq -r '."."' .release-please-manifest.json) |
| 52 | + NEW_MAJOR="${NEW_VERSION%%.*}" |
| 53 | +
|
| 54 | + if [ "$CURRENT_MAJOR" = "$NEW_MAJOR" ]; then |
| 55 | + echo "No major version change ($CURRENT_MAJOR → $NEW_MAJOR), skipping" |
| 56 | + exit 0 |
| 57 | + fi |
| 58 | +
|
| 59 | + echo "Major version bump detected: v$CURRENT_MAJOR → v$NEW_MAJOR" |
| 60 | +
|
| 61 | + sed -i "s|module github.com/workos/workos-go/v${CURRENT_MAJOR}|module github.com/workos/workos-go/v${NEW_MAJOR}|" go.mod |
| 62 | + find . -name '*.go' -not -path './.git/*' -type f \ |
| 63 | + -exec sed -i "s|github.com/workos/workos-go/v${CURRENT_MAJOR}|github.com/workos/workos-go/v${NEW_MAJOR}|g" {} + |
| 64 | + find . -name 'README.md' -not -path './.git/*' -type f \ |
| 65 | + -exec sed -i "s|workos-go/v${CURRENT_MAJOR}|workos-go/v${NEW_MAJOR}|g" {} + |
| 66 | +
|
| 67 | + git config user.name "workos-sdk-automation[bot]" |
| 68 | + git config user.email "255426317+workos-sdk-automation[bot]@users.noreply.github.com" |
| 69 | + git add -A |
| 70 | + if git diff --staged --quiet; then |
| 71 | + echo "No changes to commit" |
| 72 | + else |
| 73 | + git commit -m "chore: update go.mod and import paths for v${NEW_MAJOR}" |
| 74 | + git push |
| 75 | + fi |
| 76 | +
|
43 | 77 | # Inline pending changelog fragments under the version heading |
44 | 78 | # release-please just wrote in CHANGELOG.md. For PRs that have a |
45 | 79 | # fragment (the autogen flow always writes one), drop the line |
@@ -129,40 +163,6 @@ jobs: |
129 | 163 | git commit -m "chore: inline release notes from .changelog-pending" |
130 | 164 | git push |
131 | 165 |
|
132 | | - # Go modules require the module path and all import statements to |
133 | | - # include the major version (e.g. /v7). release-please doesn't handle |
134 | | - # this, so when a release PR bumps the major version we automatically |
135 | | - # rewrite go.mod, imports, and READMEs on the release PR branch. |
136 | | - - name: Migrate Go module path for major version bump |
137 | | - if: steps.release.outputs.pr |
138 | | - run: | |
139 | | - CURRENT_MAJOR=$(grep -oP 'module github\.com/workos/workos-go/v\K[0-9]+' go.mod) |
140 | | - NEW_VERSION=$(jq -r '."."' .release-please-manifest.json) |
141 | | - NEW_MAJOR="${NEW_VERSION%%.*}" |
142 | | -
|
143 | | - if [ "$CURRENT_MAJOR" = "$NEW_MAJOR" ]; then |
144 | | - echo "No major version change ($CURRENT_MAJOR → $NEW_MAJOR), skipping" |
145 | | - exit 0 |
146 | | - fi |
147 | | -
|
148 | | - echo "Major version bump detected: v$CURRENT_MAJOR → v$NEW_MAJOR" |
149 | | -
|
150 | | - sed -i "s|module github.com/workos/workos-go/v${CURRENT_MAJOR}|module github.com/workos/workos-go/v${NEW_MAJOR}|" go.mod |
151 | | - find . -name '*.go' -not -path './.git/*' -type f \ |
152 | | - -exec sed -i "s|github.com/workos/workos-go/v${CURRENT_MAJOR}|github.com/workos/workos-go/v${NEW_MAJOR}|g" {} + |
153 | | - find . -name 'README.md' -not -path './.git/*' -type f \ |
154 | | - -exec sed -i "s|workos-go/v${CURRENT_MAJOR}|workos-go/v${NEW_MAJOR}|g" {} + |
155 | | -
|
156 | | - git config user.name "workos-sdk-automation[bot]" |
157 | | - git config user.email "255426317+workos-sdk-automation[bot]@users.noreply.github.com" |
158 | | - git add -A |
159 | | - if git diff --staged --quiet; then |
160 | | - echo "No changes to commit" |
161 | | - else |
162 | | - git commit -m "chore: update go.mod and import paths for v${NEW_MAJOR}" |
163 | | - git push |
164 | | - fi |
165 | | -
|
166 | 166 | # Detect when a release-please release PR has merged, then tag and |
167 | 167 | # create the GitHub Release whose body is extracted from CHANGELOG.md |
168 | 168 | # (now rich, after the inline step above). Runs on every push to main; |
|
0 commit comments