Skip to content
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

Handle patch versions in go.mod #93

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
id: go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version || (fromJSON(steps.go-mod.outputs.json).Go && format('{0}.x', fromJSON(steps.go-mod.outputs.json).Go)) }}
go-version: ${{ inputs.go-version || (fromJSON(steps.go-mod.outputs.json).Go && fromJSON(steps.go-mod.outputs.json).Go) }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know it's my fault here, but this is a redundant &&.

cache: ${{ inputs.go-cache }}
- name: Run repo-specific setup
uses: ./.github/actions/go-check-setup
Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,21 @@ jobs:
GO_MOD_VERSION: ${{ fromJSON(steps.go-mod.outputs.json).Go }}
run: |
if [[ "$MATRIX_GO" == "this" ]]; then
echo "version=$GO_MOD_VERSION.x" >> $GITHUB_OUTPUT
MAJOR=$(echo "$GO_MOD_VERSION" | cut -d. -f1)
MINOR=$(echo "$GO_MOD_VERSION" | cut -d. -f2)
PATCH=$(echo "$GO_MOD_VERSION" | cut -d. -f3)
if [[ -z "$PATCH" ]]; then
echo "version=$MAJOR.$MINOR.x" >> $GITHUB_OUTPUT
else
echo "version=$MAJOR.$MINOR.$PATCH" >> $GITHUB_OUTPUT
fi
elif [[ "$MATRIX_GO" == "next" ]]; then
MAJOR="${GO_MOD_VERSION%.[0-9]*}"
MINOR="${GO_MOD_VERSION#[0-9]*.}"
MAJOR=$(echo "$GO_MOD_VERSION" | cut -d. -f1)
MINOR=$(echo "$GO_MOD_VERSION" | cut -d. -f2)
echo "version=$MAJOR.$(($MINOR+1)).x" >> $GITHUB_OUTPUT
elif [[ "$MATRIX_GO" == "prev" ]]; then
MAJOR="${GO_MOD_VERSION%.[0-9]*}"
MINOR="${GO_MOD_VERSION#[0-9]*.}"
MAJOR=$(echo "$GO_MOD_VERSION" | cut -d. -f1)
MINOR=$(echo "$GO_MOD_VERSION" | cut -d. -f2)
echo "version=$MAJOR.$(($MINOR-1)).x" >> $GITHUB_OUTPUT
else
echo "version=$MATRIX_GO" >> $GITHUB_OUTPUT
Expand Down
Loading