diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml new file mode 100644 index 00000000..95e45247 --- /dev/null +++ b/.github/actions/setup-go/action.yml @@ -0,0 +1,51 @@ +name: "Setup Go" +description: "Setup Go environment by downloading and extracting from go.dev" +inputs: + go-version: + description: "The Go version to download and use" + required: true +runs: + using: "composite" + steps: + - name: Download and setup Go + shell: bash + run: | + set -e + GO_VERSION="${{ inputs.go-version }}" + GO_VERSION="${GO_VERSION#go}" # Remove 'go' prefix if present + + # Determine OS and architecture + if [[ "$RUNNER_OS" == "macOS" ]]; then + OS="darwin" + ARCH="arm64" + else + OS="linux" + ARCH="amd64" + fi + + DOWNLOAD_URL="https://go.dev/dl/go${GO_VERSION}.${OS}-${ARCH}.tar.gz" + echo "Downloading Go from: ${DOWNLOAD_URL}" + + # Create temporary directory for download + TMP_DIR=$(mktemp -d) + curl -L "${DOWNLOAD_URL}" -o "${TMP_DIR}/go.tar.gz" + + # Remove existing Go installation if any + sudo rm -rf /usr/local/go + + # Extract to /usr/local + sudo tar -C /usr/local -xzf "${TMP_DIR}/go.tar.gz" + + # Clean up + rm -rf "${TMP_DIR}" + + # Add to PATH + echo "/usr/local/go/bin" >> $GITHUB_PATH + echo "$HOME/go/bin" >> $GITHUB_PATH + + - name: Verify Go installation + shell: bash + run: | + # Verify installation + echo "Verifying Go installation..." + go version diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 7765694a..d415626b 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -40,9 +40,9 @@ jobs: - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v5 + uses: ./.github/actions/setup-go with: - go-version: '1.23' + go-version: '1.23.6' - name: Install dependencies on macOS if: startsWith(matrix.os, 'macos') diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml index 243bead5..dae0b76d 100644 --- a/.github/workflows/fmt.yml +++ b/.github/workflows/fmt.yml @@ -13,9 +13,9 @@ jobs: - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v5 + uses: ./.github/actions/setup-go with: - go-version: '1.23' + go-version: '1.23.6' - name: Check formatting run: | diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 8ea61021..c418efdc 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -35,9 +35,9 @@ jobs: clang --version - name: Set up Go - uses: actions/setup-go@v5 + uses: ./.github/actions/setup-go with: - go-version: '1.23' + go-version: '1.23.6' - name: Build run: go build -v ./... diff --git a/.github/workflows/llgo.yml b/.github/workflows/llgo.yml index e9722c5f..45c9ca8f 100644 --- a/.github/workflows/llgo.yml +++ b/.github/workflows/llgo.yml @@ -17,7 +17,7 @@ jobs: - macos-latest - ubuntu-24.04 llvm: [18] - go: ['1.20', '1.21', '1.22', '1.23'] + go: ['1.20.14', '1.21.13', '1.22.12', '1.23.6'] runs-on: ${{matrix.os}} steps: - uses: actions/checkout@v4 @@ -35,9 +35,9 @@ jobs: pip3.12 install --break-system-packages "${py_deps[@]}" - name: Set up Go for build - uses: actions/setup-go@v5 + uses: ./.github/actions/setup-go with: - go-version: '1.23' + go-version: '1.23.6' - name: Install working-directory: compiler @@ -98,7 +98,7 @@ jobs: matrix: os: [ubuntu-24.04, macos-latest] llvm: [18] - go: ['1.20', '1.21', '1.22', '1.23'] + go: ['1.20.14', '1.21.13', '1.22.12', '1.23.6'] runs-on: ${{matrix.os}} steps: - uses: actions/checkout@v4 @@ -108,9 +108,9 @@ jobs: llvm-version: ${{matrix.llvm}} - name: Set up Go 1.23 for building llgo - uses: actions/setup-go@v5 + uses: ./.github/actions/setup-go with: - go-version: '1.23' + go-version: '1.23.6' - name: Install llgo working-directory: compiler @@ -119,26 +119,26 @@ jobs: echo "LLGO_ROOT=$GITHUB_WORKSPACE" >> $GITHUB_ENV - name: Set up Go for testing - uses: actions/setup-go@v5 + uses: ./.github/actions/setup-go with: go-version: ${{matrix.go}} - name: Test Hello World with go.mod 1.20 - if: matrix.go == '1.20' || matrix.go == '1.21' || matrix.go == '1.22' || matrix.go == '1.23' + if: startsWith(matrix.go, '1.20') || startsWith(matrix.go, '1.21') || startsWith(matrix.go, '1.22') || startsWith(matrix.go, '1.23') uses: ./.github/actions/test-helloworld with: go-version: ${{matrix.go}} mod-version: '1.20' - name: Test Hello World with go.mod 1.21 - if: matrix.go == '1.21' || matrix.go == '1.22' || matrix.go == '1.23' + if: startsWith(matrix.go, '1.21') || startsWith(matrix.go, '1.22') || startsWith(matrix.go, '1.23') uses: ./.github/actions/test-helloworld with: go-version: ${{matrix.go}} mod-version: '1.21' - name: Test Hello World with go.mod 1.22 - if: matrix.go == '1.22' || matrix.go == '1.23' + if: startsWith(matrix.go, '1.22') || startsWith(matrix.go, '1.23') uses: ./.github/actions/test-helloworld with: go-version: ${{matrix.go}}