Skip to content

Commit

Permalink
Adding a custom go-setup command
Browse files Browse the repository at this point in the history
Signed-off-by: apostasie <[email protected]>
  • Loading branch information
apostasie committed Dec 13, 2024
1 parent 2b0705a commit bbc28d7
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/actions/install-go/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: "Setup Go"
description: "Nerdctl go installation, with canary support. Will by default install go for the supported patch-version."
inputs:
stable:
required: false
default: "false"
description: "Set this to true if you want the latest patch version of the main supported version specified in go.mod"
old-stable:
required: false
default: "false"
description: "Set this to true if you want the latest patch version of the main supported version specified in go.mod"
canary:
required: false
default: "false"
description: "Set this to true if you want the bleeding edge golang version (RC, etc)"
_current:
required: false
default: "1.23.1" # 1.23.4
description: "Set this to true if you want the latest patch version of the main supported version specified in go.mod"
_stable:
required: false
default: "1.23.x"
description: "Set this to true if you want the latest patch version of the main supported version specified in go.mod"
_old_stable:
required: false
default: "1.22.x"
description: "Set this to true if you want the latest patch version of the main supported version specified in go.mod"

runs:
using: composite
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
- name: Set GO env
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.canary }}" == "true" ]; then
golang::canary
elif [ "${{ inputs.stable }}" == "true" ]; then
echo "GO_VERSION=$INPUT__STABLE" >> "$GITHUB_ENV"
elif [ "${{ inputs.old-stable }}" == "true" ]; then
echo "GO_VERSION=$INPUT__OLD_STABLE" >> "$GITHUB_ENV"
else
echo "GO_VERSION=$INPUT__CURRENT" >> "$GITHUB_ENV"
fi
- name: "Setup Go"
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version: ${{ env.GO_VERSION }}
cache: true
35 changes: 35 additions & 0 deletions .github/workflows/ci_debugging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: ci_debugging

on:
push:
branches:
- main
- 'release/**'
pull_request:
paths-ignore:
- '**.md'

jobs:
# This job builds the dependency target of the test docker image for all supported architectures and cache it in GHA
go_stable:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: ./.github/actions/install-go
- run: |
go version
- uses: ./.github/actions/install-go
with:
stable: true
- run: |
go version
- uses: ./.github/actions/install-go
with:
old-stable: true
- run: |
go version
- uses: ./.github/actions/install-go
with:
canary: true
- run: |
go version

0 comments on commit bbc28d7

Please sign in to comment.