Fix Go module v2+ versioning in release workflows#146
Conversation
Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for Go semantic versioning v2+ module path requirements, where major versions 2 and above must include a /vN suffix in the module path (e.g., github.com/CrisisTextLine/modular/v2). The changes automate this requirement in the release workflows and provide comprehensive documentation.
- Automated
go.modmodule path updates for v2+ releases in all workflows - New documentation explaining Go module versioning rules and troubleshooting
- Test script to validate version handling logic
- Whitespace cleanup in test files
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/test-version-handling.sh | New test script demonstrating version-to-module-path logic |
| application_issue_reproduction_test.go | Whitespace cleanup (trailing spaces removed) |
| README.md | Added link to new Go Module Versioning Guide |
| GO_MODULE_VERSIONING.md | Comprehensive guide on Go module versioning with examples and troubleshooting |
| .github/workflows/release.yml | Added automated go.mod update step and corrected Go proxy announcement for v2+ |
| .github/workflows/release-all.yml | Updated Go proxy announcements to use correct module paths for v2+ |
| .github/workflows/module-release.yml | Added automated go.mod update step and fixed module announcements for v2+ |
| - name: Update go.mod for major version v2+ | ||
| if: steps.detect.outputs.core_changed == 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| VERSION="${{ steps.version.outputs.next_version }}" | ||
|
|
||
| # Extract major version from VERSION (e.g., v2.0.0 -> 2) | ||
| MAJOR_VERSION="${VERSION#v}" | ||
| MAJOR_VERSION="${MAJOR_VERSION%%.*}" |
There was a problem hiding this comment.
The major version extraction logic is duplicated in three places in this file (lines 208-209, 348-349) and across multiple workflow files. Consider extracting this into a reusable shell function or a separate script that can be sourced by all workflows to ensure consistency and maintainability.
| - name: Update go.mod for major version v2+ | |
| if: steps.detect.outputs.core_changed == 'true' | |
| run: | | |
| set -euo pipefail | |
| VERSION="${{ steps.version.outputs.next_version }}" | |
| # Extract major version from VERSION (e.g., v2.0.0 -> 2) | |
| MAJOR_VERSION="${VERSION#v}" | |
| MAJOR_VERSION="${MAJOR_VERSION%%.*}" | |
| - name: Create major version extraction script | |
| run: | | |
| mkdir -p .github/scripts | |
| cat > .github/scripts/extract_major_version.sh <<'EOF' | |
| #!/bin/sh | |
| # Usage: ./extract_major_version.sh v2.0.0 | |
| VERSION="$1" | |
| MAJOR="${VERSION#v}" | |
| MAJOR="${MAJOR%%.*}" | |
| echo "$MAJOR" | |
| EOF | |
| chmod +x .github/scripts/extract_major_version.sh | |
| - name: Update go.mod for major version v2+ | |
| if: steps.detect.outputs.core_changed == 'true' | |
| run: | | |
| set -euo pipefail | |
| VERSION="${{ steps.version.outputs.next_version }}" | |
| # Extract major version from VERSION (e.g., v2.0.0 -> 2) using reusable script | |
| MAJOR_VERSION="$(.github/scripts/extract_major_version.sh "$VERSION")" |
| # Extract major version from VERSION (e.g., v2.0.0 -> 2) | ||
| MAJOR_VERSION="${VERSION#v}" | ||
| MAJOR_VERSION="${MAJOR_VERSION%%.*}" | ||
|
|
There was a problem hiding this comment.
The major version extraction logic is duplicated in three places in this file (lines 256-257, 396-397) and across multiple workflow files. Consider extracting this into a reusable shell function or a separate script that can be sourced by all workflows to ensure consistency and maintainability.
| # Extract major version from VERSION (e.g., v2.0.0 -> 2) | |
| MAJOR_VERSION="${VERSION#v}" | |
| MAJOR_VERSION="${MAJOR_VERSION%%.*}" | |
| # Function to extract major version from a version string (e.g., v2.0.0 -> 2) | |
| extract_major_version() { | |
| local ver="$1" | |
| ver="${ver#v}" | |
| echo "${ver%%.*}" | |
| } | |
| MAJOR_VERSION="$(extract_major_version "$VERSION")" | |
| MAJOR_VERSION="${CURR#v}" | ||
| MAJOR_VERSION="${MAJOR_VERSION%%.*}" |
There was a problem hiding this comment.
The major version extraction logic is duplicated in two places in this file (lines 331-332, 377-378) and across multiple workflow files. Consider extracting this into a reusable shell function or a separate script that can be sourced by all workflows to ensure consistency and maintainability.
Go requires module paths to include major version suffixes (
/v2,/v3) when releasing v2.0.0+. Release workflows failed withmodule path must match major versionerrors.Changes
Workflow Updates
go.modmodule paths with/vNsuffixmodule-release.yml,release.yml,release-all.ymlImplementation
Behavior
go.mod, commits, then proceeds with releaseDocumentation
GO_MODULE_VERSIONING.md: Complete guide covering versioning rules, manual procedures, troubleshootingscripts/test-version-handling.sh: Demonstrates version→path logicREADME.mdwith link to versioning guideOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.