Skip to content

Fix Go module v2+ versioning in release workflows#146

Merged
intel352 merged 4 commits intomainfrom
copilot/update-go-versioning-process
Oct 30, 2025
Merged

Fix Go module v2+ versioning in release workflows#146
intel352 merged 4 commits intomainfrom
copilot/update-go-versioning-process

Conversation

Copy link

Copilot AI commented Oct 30, 2025

Go requires module paths to include major version suffixes (/v2, /v3) when releasing v2.0.0+. Release workflows failed with module path must match major version errors.

Changes

Workflow Updates

  • Pre-release validation: Detect v2+ releases and auto-update go.mod module paths with /vN suffix
  • Go proxy announcements: Construct correct versioned module paths when announcing to proxy
  • Applied to: module-release.yml, release.yml, release-all.yml

Implementation

# For v2.0.0 release, automatically transforms:
module github.com/CrisisTextLine/modular/modules/reverseproxy
# Into:
module github.com/CrisisTextLine/modular/modules/reverseproxy/v2

# Then announces with correct path:
go list -m github.com/CrisisTextLine/modular/modules/reverseproxy/v2@v2.0.0

Behavior

  • v0.x, v1.x: No changes, works as before
  • v2+: Auto-updates go.mod, commits, then proceeds with release
  • Validation: Fails fast with clear error if existing suffix mismatches target version

Documentation

  • GO_MODULE_VERSIONING.md: Complete guide covering versioning rules, manual procedures, troubleshooting
  • scripts/test-version-handling.sh: Demonstrates version→path logic
  • Updated README.md with link to versioning guide
Original prompt

In the Release All Components workflow, the step Announce to Go proxy errored for the reverseproxy module:

Run VERSION=v2.0.0
  VERSION=v2.0.0
  MODULE_NAME="github.com/CrisisTextLine/modular/modules/reverseproxy"
  
  go get ${MODULE_NAME}@${VERSION}
  
  echo "Announced version reverseproxy@${VERSION} to Go proxy"
  shell: /usr/bin/bash -e {0}
  env:
    GOTOOLCHAIN: local
go: github.com/CrisisTextLine/modular/modules/reverseproxy@v2.0.0: invalid version: module contains a go.mod file, so module path must match major version ("github.com/CrisisTextLine/modular/modules/reverseproxy/v2")
Error: Process completed with exit code 1.

So we need to change at least something about our packaging and release process so that the framework itself as well as supporting modules, can be properly Go versioned.

Please follow Go best practices and adjust our workflow(s) accordingly.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits October 30, 2025 10:35
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>
Copilot AI changed the title [WIP] Fix Go module path for reverseproxy module Fix Go module v2+ versioning in release workflows Oct 30, 2025
Copilot AI requested a review from intel352 October 30, 2025 10:47
@intel352 intel352 marked this pull request as ready for review October 30, 2025 14:19
Copilot AI review requested due to automatic review settings October 30, 2025 14:19
@intel352 intel352 merged commit 5d394f7 into main Oct 30, 2025
3 checks passed
@intel352 intel352 deleted the copilot/update-go-versioning-process branch October 30, 2025 14:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.mod module 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+

Comment on lines +201 to +209
- 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%%.*}"
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
- 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")"

Copilot uses AI. Check for mistakes.
Comment on lines +255 to +258
# Extract major version from VERSION (e.g., v2.0.0 -> 2)
MAJOR_VERSION="${VERSION#v}"
MAJOR_VERSION="${MAJOR_VERSION%%.*}"

Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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")"

Copilot uses AI. Check for mistakes.
Comment on lines +331 to +332
MAJOR_VERSION="${CURR#v}"
MAJOR_VERSION="${MAJOR_VERSION%%.*}"
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants