fix: v9 module path release workflow#559
Conversation
Greptile SummaryThis PR manually migrates the module path from
Confidence Score: 4/5Safe to merge; the changes are a mechanical import-path rename plus a workflow step reorder with no logic changes to the migration script itself. The module rename is straightforward and consistent across all files. The workflow change moves an identical block of shell earlier in the job, which is the intended fix. The migration step lacks .github/workflows/release-please.yml deserves a second look to confirm the migration step's error-handling behaviour meets expectations for future major-version bumps. Important Files Changed
|
| - name: Migrate Go module path for major version bump | ||
| if: steps.release.outputs.pr | ||
| run: | | ||
| CURRENT_MAJOR=$(grep -oP 'module github\.com/workos/workos-go/v\K[0-9]+' go.mod) | ||
| NEW_VERSION=$(jq -r '."."' .release-please-manifest.json) | ||
| NEW_MAJOR="${NEW_VERSION%%.*}" | ||
|
|
||
| if [ "$CURRENT_MAJOR" = "$NEW_MAJOR" ]; then | ||
| echo "No major version change ($CURRENT_MAJOR → $NEW_MAJOR), skipping" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Major version bump detected: v$CURRENT_MAJOR → v$NEW_MAJOR" | ||
|
|
||
| sed -i "s|module github.com/workos/workos-go/v${CURRENT_MAJOR}|module github.com/workos/workos-go/v${NEW_MAJOR}|" go.mod | ||
| find . -name '*.go' -not -path './.git/*' -type f \ | ||
| -exec sed -i "s|github.com/workos/workos-go/v${CURRENT_MAJOR}|github.com/workos/workos-go/v${NEW_MAJOR}|g" {} + | ||
| find . -name 'README.md' -not -path './.git/*' -type f \ | ||
| -exec sed -i "s|workos-go/v${CURRENT_MAJOR}|workos-go/v${NEW_MAJOR}|g" {} + | ||
|
|
||
| git config user.name "workos-sdk-automation[bot]" | ||
| git config user.email "255426317+workos-sdk-automation[bot]@users.noreply.github.com" | ||
| git add -A | ||
| if git diff --staged --quiet; then | ||
| echo "No changes to commit" | ||
| else | ||
| git commit -m "chore: update go.mod and import paths for v${NEW_MAJOR}" | ||
| git push | ||
| fi |
There was a problem hiding this comment.
Silent no-op risk when
grep returns empty
The CURRENT_MAJOR extraction on line 50 uses grep -oP with no fallback. If the regex matches nothing (e.g., the module path ever lacks a /vN suffix, or go.mod is temporarily in a state the pattern doesn't cover), CURRENT_MAJOR is silently set to an empty string. The comparison [ "" = "$NEW_MAJOR" ] then evaluates to false, so the sed commands run with v${CURRENT_MAJOR} expanding to just v — they match nothing, no files change, git diff --staged --quiet passes, and the step exits 0 reporting "No changes to commit" without the migration having run.
Adding set -euo pipefail at the top of the script would cause the step to fail loudly instead, and an explicit guard (if [ -z "$CURRENT_MAJOR" ]; then echo "::error::..."; exit 1; fi) would make the failure mode even clearer. This code is identical to what was present before the reorder, so it's a pre-existing gap — but now that this is the first step to commit, a silent skip here is harder to detect in the PR.
This module bump did not occur because the release process had an error. In this PR, the module rename is being done ahead of some changelog work (in case the changelog process breaks, which is what happened last time).
Closes #557