Skip to content

Commit

Permalink
refactor: improve Go version extraction reliability in CI
Browse files Browse the repository at this point in the history
refactor: improve Go version extraction reliability in CI
  • Loading branch information
rjan90 committed Nov 14, 2024
1 parent 00fbbca commit 9a2a56f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,21 @@ jobs:
REPO="filecoin-project/lotus"
LATEST_RELEASE=$(curl -s "https://api.github.com/repos/${REPO}/releases/latest" | jq -r .tag_name)
GO_MOD_URL="https://raw.githubusercontent.com/${REPO}/${LATEST_RELEASE}/go.mod"
GO_VERSION=$(curl -s $GO_MOD_URL | grep -oP 'go \K[0-9]+\.[0-9]+(\.[0-9]+)?')
# Download go.mod and check if successful
GO_MOD=$(curl -s $GO_MOD_URL)
if [ $? -ne 0 ]; then
echo "Error: Failed to download go.mod from $GO_MOD_URL"
exit 1
fi
GO_VERSION=$(echo "$GO_MOD" | awk '/^go / {print $2; exit}')
if [ -z "$GO_VERSION" ]; then
echo "Error: Could not find Go version in go.mod"
exit 1
fi
echo "Found Go version: $GO_VERSION"
echo "current_go_version=$GO_VERSION" >> $GITHUB_OUTPUT
- name: Update version.json
Expand Down

0 comments on commit 9a2a56f

Please sign in to comment.