-
Notifications
You must be signed in to change notification settings - Fork 0
Fix Go module v2+ versioning in release workflows #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -323,9 +323,22 @@ jobs: | |
| - name: Re-announce to Go proxy | ||
| if: steps.ensure.outputs.release_url | ||
| run: | | ||
| set -euo pipefail | ||
| CURR=$(git tag -l 'v*' | grep -v '/' | sort -V | tail -n1 || true) | ||
| [ -z "$CURR" ] && exit 0 | ||
| GOPROXY=proxy.golang.org go list -m github.com/CrisisTextLine/modular@${CURR} | ||
|
|
||
| # Extract major version | ||
| MAJOR_VERSION="${CURR#v}" | ||
| MAJOR_VERSION="${MAJOR_VERSION%%.*}" | ||
|
Comment on lines
+331
to
+332
|
||
|
|
||
| # Construct correct module path with version suffix for v2+ | ||
| if [ "$MAJOR_VERSION" -ge 2 ]; then | ||
| MODULE_NAME="github.com/CrisisTextLine/modular/v${MAJOR_VERSION}" | ||
| else | ||
| MODULE_NAME="github.com/CrisisTextLine/modular" | ||
| fi | ||
|
|
||
| GOPROXY=proxy.golang.org go list -m ${MODULE_NAME}@${CURR} | ||
|
|
||
| ensure-modules: | ||
| needs: detect | ||
|
|
@@ -359,7 +372,16 @@ jobs: | |
| TAG=$(git tag -l "modules/${M}/v*" | sort -V | tail -n1 || true) | ||
| [ -z "$TAG" ] && { echo "Module $M has no tags yet; skipping."; continue; } | ||
| VER=${TAG##*/} | ||
| MOD_PATH="github.com/CrisisTextLine/modular/modules/${M}" | ||
|
|
||
| # Extract major version and construct correct module path | ||
| MAJOR_VERSION="${VER#v}" | ||
| MAJOR_VERSION="${MAJOR_VERSION%%.*}" | ||
| if [ "$MAJOR_VERSION" -ge 2 ]; then | ||
| MOD_PATH="github.com/CrisisTextLine/modular/modules/${M}/v${MAJOR_VERSION}" | ||
| else | ||
| MOD_PATH="github.com/CrisisTextLine/modular/modules/${M}" | ||
| fi | ||
|
|
||
| if gh release view "$TAG" >/dev/null 2>&1; then | ||
| echo "Release exists for $TAG" | ||
| URL=$(gh release view "$TAG" --json url --jq .url || echo '') | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -198,6 +198,57 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "reason=$REASON" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Next version: $NEXT_VERSION ($REASON)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 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%%.*}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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%%.*}" | |
| - 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")" |
There was a problem hiding this comment.
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.