-
Notifications
You must be signed in to change notification settings - Fork 651
CI: go install action #3760
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
Closed
Closed
CI: go install action #3760
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: "Go install" | ||
description: "This action will install go (currently supported version by default). Operator may optionally require the `strategy` input: | ||
- 'canary', for the latest RC/beta | ||
- 'latest-stable', for the latest patch release for the currently supported version (this is normally the default, unless nerdctl is lagging) | ||
- 'old-stable' for the latest patch release of the minimum minor go version nerdctl is supporting" | ||
inputs: | ||
cache-dependency-path: | ||
description: 'Used to specify the path to a dependency file - go.sum' | ||
strategy: | ||
default: "" | ||
description: "You may set this to `canary`, `latest-stable`, or `old-stable`. Otherwise defauls to the explicitly supported version." | ||
# These below are technically not input variables (that we expect people to specific or change). | ||
# We are just abusing the system here for convenience, since a composite action does not let you define env. | ||
# This here is the one, central location where we would update go versions when there is a newly supported go version. | ||
_current: | ||
default: "1.23.4" | ||
description: "What we consider the current blessed go version (typically the latest patch release of the last major.minor version)" | ||
_stable: | ||
default: "1.23.x" | ||
description: "The latest major.minor version we support" | ||
_old_stable: | ||
default: "1.22.x" | ||
description: "The minimum major.minor go version that we still support" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: "Set GO_VERSION environment variable from user strategy" | ||
shell: bash | ||
run: | | ||
golang::canary(){ | ||
# Enable extended globbing features to use advanced pattern matching | ||
shopt -s extglob | ||
# Get latest golang version and split it in components | ||
norm=() | ||
while read -r line; do | ||
line_trimmed="${line//+([[:space:]])/}" | ||
norm+=("$line_trimmed") | ||
done < \ | ||
<(sed -E 's/^go([0-9]+)[.]([0-9]+)([.]([0-9]+))?(([a-z]+)([0-9]+))?/\1.\2\n\4\n\6\n\7/i' \ | ||
<(curl -fsSL "https://go.dev/dl/?mode=json&include=all" | jq -rc .[0].version) \ | ||
) | ||
# Serialize version, making sure we have a patch version, and separate possible rcX into .rc-X | ||
[ "${norm[1]}" != "" ] || norm[1]="0" | ||
norm[1]=".${norm[1]}" | ||
[ "${norm[2]}" == "" ] || norm[2]="-${norm[2]}" | ||
[ "${norm[3]}" == "" ] || norm[3]=".${norm[3]}" | ||
# Save it | ||
IFS= | ||
echo "GO_VERSION=${norm[*]}" >> "$GITHUB_ENV" | ||
} | ||
|
||
if [ "${{ inputs.strategy }}" == "canary" ]; then | ||
golang::canary | ||
elif [ "${{ inputs.strategy }}" == "latest-stable" ]; then | ||
echo "GO_VERSION=${{ inputs._stable }}" >> "$GITHUB_ENV" | ||
elif [ "${{ inputs.strategy }}" == "old-stable" ]; then | ||
echo "GO_VERSION=${{ inputs._old_stable }}" >> "$GITHUB_ENV" | ||
else | ||
echo "GO_VERSION=${{ inputs._current }}" >> "$GITHUB_ENV" | ||
fi | ||
- name: "Setup Go" | ||
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
cache-dependency-path: ${{ inputs.cache-dependency-path }} | ||
# See https://github.com/containerd/nerdctl/issues/3733 | ||
# GitHub cache is very limited. We currently depend on it for the (more important) build dependencies caching. | ||
# Disabling this here will slow down the setup a bit. | ||
cache: false | ||
- name: "Cleanup go version string" | ||
shell: bash | ||
# Remove possible trailing .x | ||
run: | | ||
echo "GO_VERSION=${GO_VERSION%.x*}" >> "$GITHUB_ENV" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sorry, I feel that the maintenance cost is rather increasing with this PR
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.
Rebased to remove the noise.
This particular code has just been moved out of a helper script, so, I am not completely sure what is perceived as adding complexity.
Anyhow, it is fine - these type of feelings are not something we can really argue about. I'll close.