mirror of
https://github.com/actions/setup-go.git
synced 2026-06-26 07:28:11 +00:00
Compare commits
No commits in common. "main" and "v5.3.0" have entirely different histories.
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -7,7 +7,7 @@ assignees: ''
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<!--- Please direct any generic questions related to actions to our support community forum at https://github.com/orgs/community/discussions/categories/actions --->
|
<!--- Please direct any generic questions related to actions to our support community forum at https://github.community/c/code-to-cloud/github-actions/41 --->
|
||||||
<!--- Before opening up a new bug report, please make sure to check for similar existing issues -->
|
<!--- Before opening up a new bug report, please make sure to check for similar existing issues -->
|
||||||
|
|
||||||
**Description:**
|
**Description:**
|
||||||
|
|||||||
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@ -5,7 +5,7 @@ title: ''
|
|||||||
labels: feature request, needs triage
|
labels: feature request, needs triage
|
||||||
assignees: ''
|
assignees: ''
|
||||||
---
|
---
|
||||||
<!--- Please direct any generic questions related to actions to our support community forum at https://github.com/orgs/community/discussions/categories/actions --->
|
<!--- Please direct any generic questions related to actions to our support community forum at https://github.community/c/code-to-cloud/github-actions/41 --->
|
||||||
<!--- Before opening up a new feature request, please make sure to check for similar existing issues and pull requests -->
|
<!--- Before opening up a new feature request, please make sure to check for similar existing issues and pull requests -->
|
||||||
|
|
||||||
**Description:**
|
**Description:**
|
||||||
|
|||||||
2
.github/workflows/basic-validation.yml
vendored
2
.github/workflows/basic-validation.yml
vendored
@ -15,4 +15,4 @@ jobs:
|
|||||||
name: Basic validation
|
name: Basic validation
|
||||||
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
|
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
|
||||||
with:
|
with:
|
||||||
node-version: '24.x'
|
node-version: '20'
|
||||||
|
|||||||
2
.github/workflows/check-dist.yml
vendored
2
.github/workflows/check-dist.yml
vendored
@ -16,4 +16,4 @@ jobs:
|
|||||||
name: Check dist/
|
name: Check dist/
|
||||||
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
|
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
|
||||||
with:
|
with:
|
||||||
node-version: '24.x'
|
node-version: '20'
|
||||||
|
|||||||
143
.github/workflows/microsoft-validation.yml
vendored
143
.github/workflows/microsoft-validation.yml
vendored
@ -1,143 +0,0 @@
|
|||||||
name: Validate Microsoft build of Go
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
pull_request:
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
microsoft-basic:
|
|
||||||
name: 'Microsoft build of Go ${{ matrix.go-version }} on ${{ matrix.os }}'
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
go-version: ['1.25', '1.24']
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Setup Microsoft build of Go ${{ matrix.go-version }}
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.go-version }}
|
|
||||||
go-download-base-url: 'https://aka.ms/golang/release/latest'
|
|
||||||
cache: false
|
|
||||||
|
|
||||||
- name: Verify Go installation
|
|
||||||
run: go version
|
|
||||||
|
|
||||||
- name: Verify Go env
|
|
||||||
run: go env
|
|
||||||
|
|
||||||
- name: Verify Go is functional
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
# Create a simple Go program and run it
|
|
||||||
mkdir -p /tmp/test-go && cd /tmp/test-go
|
|
||||||
cat > main.go << 'EOF'
|
|
||||||
package main
|
|
||||||
import "fmt"
|
|
||||||
func main() {
|
|
||||||
fmt.Println("Hello from Microsoft build of Go!")
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
go run main.go
|
|
||||||
|
|
||||||
microsoft-env-var:
|
|
||||||
name: 'Microsoft build of Go via env var on ${{ matrix.os }}'
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
env:
|
|
||||||
GO_DOWNLOAD_BASE_URL: 'https://aka.ms/golang/release/latest'
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Setup Microsoft build of Go via environment variable
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version: '1.25'
|
|
||||||
cache: false
|
|
||||||
|
|
||||||
- name: Verify Go installation
|
|
||||||
run: go version
|
|
||||||
|
|
||||||
- name: Verify Go is functional
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir -p /tmp/test-go && cd /tmp/test-go
|
|
||||||
cat > main.go << 'EOF'
|
|
||||||
package main
|
|
||||||
import "fmt"
|
|
||||||
func main() {
|
|
||||||
fmt.Println("Hello from Microsoft build of Go via env var!")
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
go run main.go
|
|
||||||
|
|
||||||
microsoft-architecture:
|
|
||||||
name: 'Microsoft build of Go arch ${{ matrix.architecture }} on ${{ matrix.os }}'
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, macos-latest]
|
|
||||||
architecture: [x64]
|
|
||||||
include:
|
|
||||||
- os: macos-latest
|
|
||||||
architecture: arm64
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Setup Microsoft build of Go with architecture
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version: '1.25'
|
|
||||||
go-download-base-url: 'https://aka.ms/golang/release/latest'
|
|
||||||
architecture: ${{ matrix.architecture }}
|
|
||||||
cache: false
|
|
||||||
|
|
||||||
- name: Verify Go installation
|
|
||||||
run: go version
|
|
||||||
|
|
||||||
microsoft-with-cache:
|
|
||||||
name: 'Microsoft build of Go with caching on ${{ matrix.os }}'
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Setup Microsoft build of Go with caching
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version: '1.25'
|
|
||||||
go-download-base-url: 'https://aka.ms/golang/release/latest'
|
|
||||||
cache: true
|
|
||||||
|
|
||||||
- name: Verify Go installation
|
|
||||||
run: go version
|
|
||||||
|
|
||||||
- name: Verify Go is functional
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir -p /tmp/test-go && cd /tmp/test-go
|
|
||||||
go mod init test
|
|
||||||
cat > main.go << 'EOF'
|
|
||||||
package main
|
|
||||||
import "fmt"
|
|
||||||
func main() {
|
|
||||||
fmt.Println("Hello from cached Microsoft build of Go!")
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
go run main.go
|
|
||||||
@ -14,7 +14,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checking out
|
- name: Checking out
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v4
|
||||||
- name: Publish
|
- name: Publish
|
||||||
id: publish
|
id: publish
|
||||||
uses: actions/publish-immutable-action@v0.0.4
|
uses: actions/publish-immutable-action@v0.0.4
|
||||||
|
|||||||
@ -22,7 +22,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Update the ${{ env.TAG_NAME }} tag
|
- name: Update the ${{ env.TAG_NAME }} tag
|
||||||
uses: actions/publish-action@v0.4.0
|
uses: actions/publish-action@v0.3.0
|
||||||
with:
|
with:
|
||||||
source-tag: ${{ env.TAG_NAME }}
|
source-tag: ${{ env.TAG_NAME }}
|
||||||
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
||||||
|
|||||||
76
.github/workflows/versions.yml
vendored
76
.github/workflows/versions.yml
vendored
@ -18,9 +18,9 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Go Stable
|
- name: Setup Go Stable
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -33,9 +33,9 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Go oldStable
|
- name: Setup Go oldStable
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -48,16 +48,16 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
version: [stable, oldstable]
|
version: [stable, oldstable]
|
||||||
architecture: [x64, x32]
|
architecture: [x64, x32]
|
||||||
exclude:
|
exclude:
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
architecture: x32
|
architecture: x32
|
||||||
- os: macos-latest-large
|
- os: macos-13
|
||||||
architecture: x32
|
architecture: x32
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }}
|
- name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }}
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -72,7 +72,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest, macos-latest-large]
|
os: [macos-latest, windows-latest, ubuntu-latest, macos-13]
|
||||||
go: [1.21.13, 1.22.8, 1.23.2]
|
go: [1.21.13, 1.22.8, 1.23.2]
|
||||||
include:
|
include:
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
@ -82,7 +82,7 @@ jobs:
|
|||||||
go: 1.23.2
|
go: 1.23.2
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: setup-go ${{ matrix.go }}
|
- name: setup-go ${{ matrix.go }}
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -98,10 +98,10 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
go-version: ['1.20', '1.21', '1.22', '1.23']
|
go-version: ['1.20', '1.21', '1.22', '1.23']
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Go and check latest
|
- name: Setup Go and check latest
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -115,9 +115,9 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Go and check latest
|
- name: Setup Go and check latest
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -131,9 +131,9 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Go and check latest
|
- name: Setup Go and check latest
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -142,48 +142,16 @@ jobs:
|
|||||||
run: __tests__/verify-go.sh 1.21
|
run: __tests__/verify-go.sh 1.21
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
go-version-file-with-tool-versions:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- name: Setup Go and check latest
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version-file: __tests__/data/.tool-versions
|
|
||||||
- name: verify go
|
|
||||||
run: __tests__/verify-go.sh 1.23.2
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
go-version-file-with-go-version:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- name: Setup Go from .go-version file
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
go-version-file: __tests__/data/.go-version
|
|
||||||
- name: verify go
|
|
||||||
run: __tests__/verify-go.sh 1.22.4
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
setup-versions-from-manifest:
|
setup-versions-from-manifest:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest, macos-latest-large]
|
os: [macos-latest, windows-latest, ubuntu-latest, macos-13]
|
||||||
go: [1.20.14, 1.21.10, 1.22.8, 1.23.2]
|
go: [1.20.14, 1.21.10, 1.22.8, 1.23.2]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: setup-go ${{ matrix.go }}
|
- name: setup-go ${{ matrix.go }}
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -199,11 +167,11 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [windows-latest, ubuntu-latest, macos-latest-large]
|
os: [windows-latest, ubuntu-latest, macos-13]
|
||||||
go: [1.11.12]
|
go: [1.11.12]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: setup-go ${{ matrix.go }}
|
- name: setup-go ${{ matrix.go }}
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -219,7 +187,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
go-version: [1.20.14, 1.21, 1.22, 1.23]
|
go-version: [1.20.14, 1.21, 1.22, 1.23]
|
||||||
include:
|
include:
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
@ -228,10 +196,10 @@ jobs:
|
|||||||
architecture: x64
|
architecture: x64
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
architecture: x64
|
architecture: x64
|
||||||
- os: macos-latest-large
|
- os: macos-13
|
||||||
architecture: x64
|
architecture: x64
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Go and check latest
|
- name: Setup Go and check latest
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
|||||||
6
.github/workflows/windows-validation.yml
vendored
6
.github/workflows/windows-validation.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
|||||||
cache: [false, true]
|
cache: [false, true]
|
||||||
go: [1.20.1]
|
go: [1.20.1]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: 'Setup ${{ matrix.cache }}, cache: ${{ matrix.go }}'
|
- name: 'Setup ${{ matrix.cache }}, cache: ${{ matrix.go }}'
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -88,7 +88,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
cache: [false, true]
|
cache: [false, true]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: 'Setup default go, cache: ${{ matrix.cache }}'
|
- name: 'Setup default go, cache: ${{ matrix.cache }}'
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -121,7 +121,7 @@ jobs:
|
|||||||
cache: [false]
|
cache: [false]
|
||||||
go: [1.20.1]
|
go: [1.20.1]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}'
|
- name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}'
|
||||||
uses: ./
|
uses: ./
|
||||||
|
|||||||
@ -12,5 +12,4 @@ allowed:
|
|||||||
- 0bsd
|
- 0bsd
|
||||||
|
|
||||||
reviewed:
|
reviewed:
|
||||||
npm:
|
npm:
|
||||||
- "@actions/http-client"
|
|
||||||
BIN
.licenses/npm/@actions/cache.dep.yml
generated
BIN
.licenses/npm/@actions/cache.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/core.dep.yml
generated
BIN
.licenses/npm/@actions/core.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/exec.dep.yml
generated
BIN
.licenses/npm/@actions/exec.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@actions/glob-0.4.0.dep.yml
generated
Normal file
BIN
.licenses/npm/@actions/glob-0.4.0.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@actions/http-client.dep.yml
generated
BIN
.licenses/npm/@actions/http-client.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/io.dep.yml
generated
BIN
.licenses/npm/@actions/io.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/tool-cache.dep.yml
generated
BIN
.licenses/npm/@actions/tool-cache.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@azure/core-auth.dep.yml
generated
BIN
.licenses/npm/@azure/core-auth.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-client.dep.yml
generated
BIN
.licenses/npm/@azure/core-client.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-http-compat.dep.yml
generated
BIN
.licenses/npm/@azure/core-http-compat.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@azure/core-lro.dep.yml
generated
BIN
.licenses/npm/@azure/core-lro.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-paging.dep.yml
generated
BIN
.licenses/npm/@azure/core-paging.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-rest-pipeline.dep.yml
generated
BIN
.licenses/npm/@azure/core-rest-pipeline.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-tracing.dep.yml
generated
BIN
.licenses/npm/@azure/core-tracing.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-util.dep.yml
generated
BIN
.licenses/npm/@azure/core-util.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/core-xml.dep.yml
generated
BIN
.licenses/npm/@azure/core-xml.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/logger.dep.yml
generated
BIN
.licenses/npm/@azure/logger.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/ms-rest-js.dep.yml
generated
Normal file
BIN
.licenses/npm/@azure/ms-rest-js.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@azure/storage-blob.dep.yml
generated
BIN
.licenses/npm/@azure/storage-blob.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@fastify/busboy.dep.yml
generated
Normal file
BIN
.licenses/npm/@fastify/busboy.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@nodable/entities.dep.yml
generated
BIN
.licenses/npm/@nodable/entities.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@opentelemetry/api.dep.yml
generated
Normal file
BIN
.licenses/npm/@opentelemetry/api.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/plugin-framework.dep.yml
generated
Normal file
BIN
.licenses/npm/@protobuf-ts/plugin-framework.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/plugin.dep.yml
generated
Normal file
BIN
.licenses/npm/@protobuf-ts/plugin.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/protoc.dep.yml
generated
Normal file
BIN
.licenses/npm/@protobuf-ts/protoc.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/runtime-rpc.dep.yml
generated
BIN
.licenses/npm/@protobuf-ts/runtime-rpc.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/runtime.dep.yml
generated
BIN
.licenses/npm/@protobuf-ts/runtime.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@types/node-fetch.dep.yml
generated
Normal file
BIN
.licenses/npm/@types/node-fetch.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@types/node.dep.yml
generated
Normal file
BIN
.licenses/npm/@types/node.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@types/tunnel.dep.yml
generated
Normal file
BIN
.licenses/npm/@types/tunnel.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@typespec/ts-http-runtime.dep.yml
generated
BIN
.licenses/npm/@typespec/ts-http-runtime.dep.yml
generated
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/brace-expansion.dep.yml
generated
BIN
.licenses/npm/brace-expansion.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/camel-case.dep.yml
generated
Normal file
BIN
.licenses/npm/camel-case.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/combined-stream.dep.yml
generated
Normal file
BIN
.licenses/npm/combined-stream.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/debug.dep.yml
generated
BIN
.licenses/npm/debug.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/dot-object.dep.yml
generated
Normal file
BIN
.licenses/npm/dot-object.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/form-data-2.5.1.dep.yml
generated
Normal file
BIN
.licenses/npm/form-data-2.5.1.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/form-data-4.0.0.dep.yml
generated
Normal file
BIN
.licenses/npm/form-data-4.0.0.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/fs.realpath.dep.yml
generated
Normal file
BIN
.licenses/npm/fs.realpath.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/glob.dep.yml
generated
Normal file
BIN
.licenses/npm/glob.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/inflight.dep.yml
generated
Normal file
BIN
.licenses/npm/inflight.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/lodash.dep.yml
generated
Normal file
BIN
.licenses/npm/lodash.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/lru-cache.dep.yml
generated
Normal file
BIN
.licenses/npm/lru-cache.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/mime-types.dep.yml
generated
Normal file
BIN
.licenses/npm/mime-types.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/minimatch.dep.yml
generated
BIN
.licenses/npm/minimatch.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/no-case.dep.yml
generated
Normal file
BIN
.licenses/npm/no-case.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/node-fetch.dep.yml
generated
Normal file
BIN
.licenses/npm/node-fetch.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/once.dep.yml
generated
Normal file
BIN
.licenses/npm/once.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/pascal-case.dep.yml
generated
Normal file
BIN
.licenses/npm/pascal-case.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/path-is-absolute.dep.yml
generated
Normal file
BIN
.licenses/npm/path-is-absolute.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/path-to-regexp.dep.yml
generated
Normal file
BIN
.licenses/npm/path-to-regexp.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/prettier.dep.yml
generated
Normal file
BIN
.licenses/npm/prettier.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/sax.dep.yml
generated
Normal file
BIN
.licenses/npm/sax.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/ts-poet.dep.yml
generated
Normal file
BIN
.licenses/npm/ts-poet.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/tslib-1.14.1.dep.yml
generated
Normal file
BIN
.licenses/npm/tslib-1.14.1.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/tslib-2.6.2.dep.yml
generated
Normal file
BIN
.licenses/npm/tslib-2.6.2.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/twirp-ts.dep.yml
generated
Normal file
BIN
.licenses/npm/twirp-ts.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/typescript.dep.yml
generated
Normal file
BIN
.licenses/npm/typescript.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/undici.dep.yml
generated
BIN
.licenses/npm/undici.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/uuid-3.4.0.dep.yml
generated
Normal file
BIN
.licenses/npm/uuid-3.4.0.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/uuid-8.3.2.dep.yml
generated
Normal file
BIN
.licenses/npm/uuid-8.3.2.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/webidl-conversions.dep.yml
generated
Normal file
BIN
.licenses/npm/webidl-conversions.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/whatwg-url.dep.yml
generated
Normal file
BIN
.licenses/npm/whatwg-url.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/wrappy.dep.yml
generated
Normal file
BIN
.licenses/npm/wrappy.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/xml-naming.dep.yml
generated
BIN
.licenses/npm/xml-naming.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/xml2js.dep.yml
generated
Normal file
BIN
.licenses/npm/xml2js.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/xmlbuilder.dep.yml
generated
Normal file
BIN
.licenses/npm/xmlbuilder.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/yallist.dep.yml
generated
Normal file
BIN
.licenses/npm/yallist.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/yaml.dep.yml
generated
Normal file
BIN
.licenses/npm/yaml.dep.yml
generated
Normal file
Binary file not shown.
341
README.md
341
README.md
@ -3,96 +3,68 @@
|
|||||||
[](https://github.com/actions/setup-go/actions/workflows/basic-validation.yml)
|
[](https://github.com/actions/setup-go/actions/workflows/basic-validation.yml)
|
||||||
[](https://github.com/actions/setup-go/actions/workflows/versions.yml)
|
[](https://github.com/actions/setup-go/actions/workflows/versions.yml)
|
||||||
|
|
||||||
This action sets up a Go environment for use in GitHub Actions by:
|
This action sets up a go environment for use in actions by:
|
||||||
|
|
||||||
- Optionally downloading and caching a version of Go by version and adding it to the PATH
|
- Optionally downloading and caching a version of Go by version and adding to `PATH`.
|
||||||
- Optionally caching Go modules and build outputs
|
- Registering problem matchers for error output.
|
||||||
- Registering problem matchers for error output
|
|
||||||
|
|
||||||
## Breaking changes in V6
|
# V5
|
||||||
|
|
||||||
The V6 edition of the action includes:
|
The V5 edition of the action offers:
|
||||||
- **Upgraded Node.js runtime from node20 to node24**
|
|
||||||
> Make sure your runner is on version v2.327.1 or later to ensure compatibility with this release. See [Release Notes](https://github.com/actions/runner/releases/tag/v2.327.1)
|
|
||||||
|
|
||||||
- **Go toolchain**
|
- Upgraded Node.js runtime from node16 to node20
|
||||||
- Supports both `go` and `toolchain` directives in `go.mod`. If the `toolchain` directive is present, its version is used; otherwise, the action falls back to the `go` directive.
|
|
||||||
|
|
||||||
- **Cache key update**
|
|
||||||
- By default, the cache key for Go modules is based on `go.mod`. To use `go.sum`, configure the `cache-dependency-path` input.
|
|
||||||
|
|
||||||
See full release notes on the [releases page](https://github.com/actions/setup-go/releases).
|
See full release notes on the [releases page](https://github.com/actions/setup-go/releases).
|
||||||
|
|
||||||
## Usage
|
# V4
|
||||||
|
|
||||||
See [action.yml](action.yml).
|
The V4 edition of the action offers:
|
||||||
|
|
||||||
<!-- start usage -->
|
- Enabled caching by default
|
||||||
```yaml
|
|
||||||
- uses: actions/setup-go@v6
|
|
||||||
with:
|
|
||||||
# Version or version range of Go to use
|
|
||||||
go-version: '1.23'
|
|
||||||
|
|
||||||
# Path to go.mod, go.work, .go-version, or .tool-versions file
|
|
||||||
# Note: if both go-version and go-version-file are provided, go-version takes precedence.
|
|
||||||
go-version-file: 'go.mod'
|
|
||||||
|
|
||||||
# Set this option if you want the action to check for the latest available version
|
|
||||||
# Default: false
|
|
||||||
check-latest: false
|
|
||||||
|
|
||||||
# GitHub token for authentication
|
|
||||||
token: ${{ github.token }}
|
|
||||||
|
|
||||||
# Used to specify whether caching is needed.
|
|
||||||
# Default: true
|
|
||||||
cache: true
|
|
||||||
|
|
||||||
# Path to dependency files for caching
|
|
||||||
cache-dependency-path: 'go.sum'
|
|
||||||
|
|
||||||
# Architecture to install (auto-detected if not specified)
|
|
||||||
architecture: 'x64'
|
|
||||||
|
|
||||||
# Custom base URL for Go downloads (e.g., for mirrors)
|
|
||||||
go-download-base-url: ''
|
|
||||||
```
|
|
||||||
<!-- end usage -->
|
|
||||||
|
|
||||||
**Basic:**
|
The action will try to enable caching unless the `cache` input is explicitly set to false.
|
||||||
|
|
||||||
|
Please see "[Caching dependency files and build outputs](https://github.com/actions/setup-go#caching-dependency-files-and-build-outputs)" for more information.
|
||||||
|
|
||||||
|
# V3
|
||||||
|
|
||||||
|
The V3 edition of the action offers:
|
||||||
|
|
||||||
|
- Adds `GOBIN` to the `PATH`
|
||||||
|
- Proxy support
|
||||||
|
- Check latest version
|
||||||
|
- Caching packages dependencies
|
||||||
|
- stable and oldstable aliases
|
||||||
|
- Bug Fixes (including issues around version matching and semver)
|
||||||
|
|
||||||
|
The action will first check the local cache for a version match. If a version is not found locally, it will pull it from
|
||||||
|
the `main` branch of the [go-versions](https://github.com/actions/go-versions/blob/main/versions-manifest.json)
|
||||||
|
repository. On miss or failure, it will fall back to downloading directly
|
||||||
|
from [go dist](https://storage.googleapis.com/golang). To change the default behavior, please use
|
||||||
|
the [check-latest input](#check-latest-version).
|
||||||
|
|
||||||
|
**Note:** The `setup-go` action uses executable binaries which are built by Golang side. The action does not build
|
||||||
|
golang from source code.
|
||||||
|
|
||||||
|
Matching by [semver spec](https://github.com/npm/node-semver):
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v6
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.25' # The Go version to download (if necessary) and use.
|
go-version: '^1.13.1' # The Go version to download (if necessary) and use.
|
||||||
- run: go run hello.go
|
- run: go version
|
||||||
```
|
```
|
||||||
|
|
||||||
**Version resolution behavior:**
|
```yaml
|
||||||
|
steps:
|
||||||
The action resolves the requested version in the following order:
|
- uses: actions/checkout@v4
|
||||||
1. **Local cache** - Checks the local tool cache for a matching [semver](https://github.com/npm/node-semver#versions) version.
|
- uses: actions/setup-go@v5
|
||||||
2. **go-versions repository** - If the requested version isn’t available in the tool cache, it pulls the version manifest from the `main` branch of the [go-versions repository](https://github.com/actions/go-versions/blob/main/versions-manifest.json).
|
with:
|
||||||
3. **Direct download** - If that lookup misses or fails, it will fall back to downloading directly from the [official Go distribution site](https://go.dev/dl).
|
go-version: '>=1.17.0'
|
||||||
|
- run: go version
|
||||||
To change the default behavior, please use
|
```
|
||||||
the [check-latest input](docs/advanced-usage.md#check-latest-version).
|
|
||||||
|
|
||||||
> **Note**: The `setup-go` action uses executable binaries built by the Go team and does not build Go binaries from source code.
|
|
||||||
|
|
||||||
## Supported version syntax
|
|
||||||
|
|
||||||
The `go-version` input supports the following syntax:
|
|
||||||
|
|
||||||
- Specific versions: `1.25`, `1.24.11`, `1.24.0-rc.1`, `1.23.0-beta.1`
|
|
||||||
- SemVer version range syntax: `^1.25.1`, `~1.24.1`, `>=1.25.0-rc.1`, `<1.25.0`, `>=1.22.0 <1.24.0`
|
|
||||||
- Aliases: `stable`, `oldstable`
|
|
||||||
- Wildcards: `1.25.x`, `1.x`
|
|
||||||
|
|
||||||
For details on Semantic Versioning, see [the semver package documentation](https://github.com/npm/node-semver).
|
|
||||||
|
|
||||||
> **Note**: Due to the peculiarities of YAML parsing, it is recommended to wrap the version in single quotation marks:
|
> **Note**: Due to the peculiarities of YAML parsing, it is recommended to wrap the version in single quotation marks:
|
||||||
>
|
>
|
||||||
@ -100,9 +72,195 @@ For details on Semantic Versioning, see [the semver package documentation](https
|
|||||||
> go-version: '1.20'
|
> go-version: '1.20'
|
||||||
> ```
|
> ```
|
||||||
>
|
>
|
||||||
> The recommendation is based on the YAML parser's behavior, which interprets non-wrapped values as numbers and, in the case of version `1.20`, trims it down to `1.2`, which may not be very obvious.
|
> The recommendation is based on the YAML parser's behavior, which interprets non-wrapped values as numbers and, in the case of version 1.20, trims it down to 1.2, which may not be very obvious.
|
||||||
|
|
||||||
For more usage examples, please refer to the section: [Using go-version input](docs/advanced-usage.md#using-the-go-version-input) of the [Advanced usage](docs/advanced-usage.md) guide.
|
Matching an unstable pre-release:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.18.0-rc.1' # The Go version to download (if necessary) and use.
|
||||||
|
- run: go version
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.16.0-beta.1' # The Go version to download (if necessary) and use.
|
||||||
|
- run: go version
|
||||||
|
```
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
See [action.yml](action.yml)
|
||||||
|
|
||||||
|
## Basic
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.16.1' # The Go version to download (if necessary) and use.
|
||||||
|
- run: go run hello.go
|
||||||
|
```
|
||||||
|
|
||||||
|
## Check latest version
|
||||||
|
|
||||||
|
The `check-latest` flag defaults to `false`. Use the default or set `check-latest` to `false` if you prefer stability
|
||||||
|
and if you want to ensure a specific Go version is always used.
|
||||||
|
|
||||||
|
If `check-latest` is set to `true`, the action first checks if the cached version is the latest one. If the locally
|
||||||
|
cached version is not the most up-to-date, a Go version will then be downloaded. Set `check-latest` to `true` if you
|
||||||
|
want the most up-to-date Go version to always be used.
|
||||||
|
|
||||||
|
> Setting `check-latest` to `true` has performance implications as downloading Go versions is slower than using cached
|
||||||
|
> versions.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.14'
|
||||||
|
check-latest: true
|
||||||
|
- run: go run hello.go
|
||||||
|
```
|
||||||
|
|
||||||
|
## Using stable/oldstable aliases
|
||||||
|
|
||||||
|
If `stable` is provided, action will get the latest stable version from
|
||||||
|
the [`go-versions`](https://github.com/actions/go-versions/blob/main/versions-manifest.json) repository manifest.
|
||||||
|
|
||||||
|
If `oldstable` is provided, when current release is 1.19.x, action will resolve version as 1.18.x, where x is the latest
|
||||||
|
patch release.
|
||||||
|
|
||||||
|
**Note:** using these aliases will result in same version as using corresponding minor release with `check-latest` input
|
||||||
|
set to `true`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: 'stable'
|
||||||
|
- run: go run hello.go
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: 'oldstable'
|
||||||
|
- run: go run hello.go
|
||||||
|
```
|
||||||
|
|
||||||
|
## Caching dependency files and build outputs:
|
||||||
|
|
||||||
|
The action has a built-in functionality for caching and restoring go modules and build outputs. It
|
||||||
|
uses [toolkit/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under the hood but requires less configuration settings.
|
||||||
|
The `cache` input is optional, and caching is turned on by default.
|
||||||
|
|
||||||
|
The action defaults to search for the dependency file - go.sum in the repository root, and uses its hash as a part of
|
||||||
|
the cache key. Use `cache-dependency-path` input for cases when multiple dependency files are used, or they are located
|
||||||
|
in different subdirectories. The input supports glob patterns.
|
||||||
|
|
||||||
|
If some problem that prevents success caching happens then the action issues the warning in the log and continues the execution of the pipeline.
|
||||||
|
|
||||||
|
**Caching in monorepos**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.17'
|
||||||
|
check-latest: true
|
||||||
|
cache-dependency-path: |
|
||||||
|
subdir/go.sum
|
||||||
|
tools/go.sum
|
||||||
|
# cache-dependency-path: "**/*.sum"
|
||||||
|
|
||||||
|
- run: go run hello.go
|
||||||
|
```
|
||||||
|
|
||||||
|
## Getting go version from the go.mod file
|
||||||
|
|
||||||
|
The `go-version-file` input accepts a path to a `go.mod` file or a `go.work` file that contains the version of Go to be used by a project.
|
||||||
|
|
||||||
|
The `go` directive in `go.mod` can specify a patch version or omit it altogether (e.g., `go 1.22.0` or `go 1.22`).
|
||||||
|
If a patch version is specified, that specific patch version will be used.
|
||||||
|
If no patch version is specified, it will search for the latest available patch version in the cache,
|
||||||
|
[versions-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json), and the
|
||||||
|
[official Go language website](https://golang.org/dl/?mode=json&include=all), in that order.
|
||||||
|
|
||||||
|
If both the `go-version` and the `go-version-file` inputs are provided then the `go-version` input is used.
|
||||||
|
> The action will search for the `go.mod` file relative to the repository root
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: 'path/to/go.mod'
|
||||||
|
- run: go version
|
||||||
|
```
|
||||||
|
|
||||||
|
## Matrix testing
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go: [ '1.14', '1.13' ]
|
||||||
|
name: Go ${{ matrix.go }} sample
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Setup go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go }}
|
||||||
|
- run: go run hello.go
|
||||||
|
```
|
||||||
|
|
||||||
|
### Supported version syntax
|
||||||
|
|
||||||
|
The `go-version` input supports the following syntax:
|
||||||
|
|
||||||
|
- Specific versions: `1.15`, `1.16.1`, `1.17.0-rc.2`, `1.16.0-beta.1`
|
||||||
|
- SemVer's version range syntax: `^1.13.1`, `>=1.18.0-rc.1`
|
||||||
|
|
||||||
|
For more information about semantic versioning, please refer to [semver](https://github.com/npm/node-semver)
|
||||||
|
documentation.
|
||||||
|
|
||||||
|
## Using `setup-go` on GHES
|
||||||
|
|
||||||
|
`setup-go` comes pre-installed on the appliance with GHES if Actions is enabled.
|
||||||
|
When dynamically downloading Go distributions, `setup-go` downloads distributions from [`actions/go-versions`](https://github.com/actions/go-versions) on github.com (outside of the appliance).
|
||||||
|
|
||||||
|
These calls to `actions/go-versions` are made via unauthenticated requests, which are limited to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting).
|
||||||
|
If more requests are made within the time frame, then the action leverages the `raw API` to retrieve the version-manifest. This approach does not impose a rate limit and hence facilitates unrestricted consumption. This is particularly beneficial for GHES runners, which often share the same IP, to avoid the quick exhaustion of the unauthenticated rate limit.
|
||||||
|
If that fails as well the action will try to download versions directly from https://storage.googleapis.com/golang.
|
||||||
|
|
||||||
|
If that fails as well you can get a higher rate limit with [generating a personal access token on github.com](https://github.com/settings/tokens/new) and passing it as the `token` input to the action:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GH_DOTCOM_TOKEN }}
|
||||||
|
go-version: '1.18'
|
||||||
|
```
|
||||||
|
|
||||||
|
If the runner is not able to access github.com, any Go versions requested during a workflow run must come from the runner's tool cache.
|
||||||
|
See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server@3.2/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)"
|
||||||
|
for more information.
|
||||||
|
|
||||||
## Recommended permissions
|
## Recommended permissions
|
||||||
|
|
||||||
@ -113,36 +271,13 @@ permissions:
|
|||||||
contents: read # access to check out code and install dependencies
|
contents: read # access to check out code and install dependencies
|
||||||
```
|
```
|
||||||
|
|
||||||
## Caching dependency files and build outputs
|
# License
|
||||||
|
|
||||||
The action includes built-in caching and restoration for Go modules and build outputs. It uses
|
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||||
[toolkit/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under the hood, but requires less configuration.
|
|
||||||
The `cache` input is optional, and caching is enabled by default. To disable caching, set `cache: false`.
|
|
||||||
|
|
||||||
By default, the action looks for `go.mod` in the repository root and uses its hash as part of the cache key. Use the `cache-dependency-path` input when you have multiple dependency files, or when they’re located in different subdirectories. This input supports glob patterns.
|
# Contributions
|
||||||
|
|
||||||
If caching cannot be performed for any reason, the action logs a warning and continues workflow execution.
|
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
||||||
|
|
||||||
For examples of using `cache-dependency-path`, see the [Caching](docs/advanced-usage.md#caching) section of the [Advanced usage](docs/advanced-usage.md) guide.
|
|
||||||
|
|
||||||
|
|
||||||
## Advanced usage
|
|
||||||
|
|
||||||
- [Using the go-version input](docs/advanced-usage.md#using-the-go-version-input)
|
|
||||||
- [Using the go-version-file input](docs/advanced-usage.md#using-the-go-version-file-input)
|
|
||||||
- [Check latest version](docs/advanced-usage.md#check-latest-version)
|
|
||||||
- [Caching](docs/advanced-usage.md#caching)
|
|
||||||
- [Outputs](docs/advanced-usage.md#outputs)
|
|
||||||
- [Custom download URL](docs/advanced-usage.md#custom-download-url)
|
|
||||||
- [Using `setup-go` on GHES](docs/advanced-usage.md#using-setup-go-on-ghes)
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
The scripts and documentation in this project are released under the [MIT License](LICENSE).
|
|
||||||
|
|
||||||
## Contributions
|
|
||||||
|
|
||||||
Contributions are welcome! See our [Contributor's Guide](docs/contributors.md).
|
|
||||||
|
|
||||||
## Code of Conduct
|
## Code of Conduct
|
||||||
|
|
||||||
|
|||||||
@ -1,83 +1,94 @@
|
|||||||
import * as cache from '@actions/cache';
|
import * as cache from '@actions/cache';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as glob from '@actions/glob';
|
import * as glob from '@actions/glob';
|
||||||
import fs from 'fs';
|
|
||||||
|
|
||||||
import * as cacheRestore from '../src/cache-restore';
|
import * as cacheRestore from '../src/cache-restore';
|
||||||
import * as cacheUtils from '../src/cache-utils';
|
import * as cacheUtils from '../src/cache-utils';
|
||||||
import {PackageManagerInfo} from '../src/package-managers';
|
import {PackageManagerInfo} from '../src/package-managers';
|
||||||
|
|
||||||
describe('restoreCache', () => {
|
describe('restoreCache', () => {
|
||||||
let hashFilesSpy: jest.SpyInstance;
|
//Arrange
|
||||||
let getCacheDirectoryPathSpy: jest.SpyInstance;
|
const hashFilesSpy = jest.spyOn(glob, 'hashFiles');
|
||||||
let restoreCacheSpy: jest.SpyInstance;
|
const getCacheDirectoryPathSpy = jest.spyOn(
|
||||||
let infoSpy: jest.SpyInstance;
|
cacheUtils,
|
||||||
let setOutputSpy: jest.SpyInstance;
|
'getCacheDirectoryPath'
|
||||||
|
);
|
||||||
|
const restoreCacheSpy = jest.spyOn(cache, 'restoreCache');
|
||||||
|
const infoSpy = jest.spyOn(core, 'info');
|
||||||
|
const setOutputSpy = jest.spyOn(core, 'setOutput');
|
||||||
|
|
||||||
const versionSpec = '1.13.1';
|
const versionSpec = '1.13.1';
|
||||||
const packageManager = 'default';
|
const packageManager = 'default';
|
||||||
const cacheDependencyPath = 'path';
|
const cacheDependencyPath = 'path';
|
||||||
|
|
||||||
let originalWorkspace: string | undefined;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
originalWorkspace = process.env.GITHUB_WORKSPACE;
|
|
||||||
process.env.GITHUB_WORKSPACE = '/test/workspace';
|
|
||||||
//Arrange
|
|
||||||
hashFilesSpy = jest.spyOn(glob, 'hashFiles');
|
|
||||||
getCacheDirectoryPathSpy = jest.spyOn(cacheUtils, 'getCacheDirectoryPath');
|
|
||||||
restoreCacheSpy = jest.spyOn(cache, 'restoreCache');
|
|
||||||
infoSpy = jest.spyOn(core, 'info');
|
|
||||||
setOutputSpy = jest.spyOn(core, 'setOutput');
|
|
||||||
|
|
||||||
getCacheDirectoryPathSpy.mockImplementation(
|
getCacheDirectoryPathSpy.mockImplementation(
|
||||||
(PackageManager: PackageManagerInfo) => {
|
(PackageManager: PackageManagerInfo) => {
|
||||||
return Promise.resolve([
|
return new Promise<string[]>(resolve => {
|
||||||
'cache_directory_path',
|
resolve(['cache_directory_path', 'cache_directory_path']);
|
||||||
'cache_directory_path'
|
});
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
process.env.GITHUB_WORKSPACE = originalWorkspace;
|
|
||||||
jest.restoreAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw if dependency file path is not valid', async () => {
|
it('should throw if dependency file path is not valid', async () => {
|
||||||
// Arrange
|
//Arrange
|
||||||
hashFilesSpy.mockImplementation(() => Promise.resolve(''));
|
hashFilesSpy.mockImplementation((somePath: string) => {
|
||||||
// Act + Assert
|
return new Promise<string>(resolve => {
|
||||||
await expect(
|
resolve('');
|
||||||
cacheRestore.restoreCache(
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//Act + Assert
|
||||||
|
await expect(async () => {
|
||||||
|
await cacheRestore.restoreCache(
|
||||||
versionSpec,
|
versionSpec,
|
||||||
packageManager,
|
packageManager,
|
||||||
cacheDependencyPath
|
cacheDependencyPath
|
||||||
)
|
);
|
||||||
).rejects.toThrow(
|
}).rejects.toThrow(
|
||||||
'Some specified paths were not resolved, unable to cache dependencies.'
|
'Some specified paths were not resolved, unable to cache dependencies.'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should inform if cache hit is not occurred', async () => {
|
it('should inform if cache hit is not occured', async () => {
|
||||||
// Arrange
|
//Arrange
|
||||||
hashFilesSpy.mockImplementation(() => Promise.resolve('file_hash'));
|
hashFilesSpy.mockImplementation((somePath: string) => {
|
||||||
restoreCacheSpy.mockImplementation(() => Promise.resolve(''));
|
return new Promise<string>(resolve => {
|
||||||
// Act + Assert
|
resolve('file_hash');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
restoreCacheSpy.mockImplementation(() => {
|
||||||
|
return new Promise<string>(resolve => {
|
||||||
|
resolve('');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//Act + Assert
|
||||||
await cacheRestore.restoreCache(
|
await cacheRestore.restoreCache(
|
||||||
versionSpec,
|
versionSpec,
|
||||||
packageManager,
|
packageManager,
|
||||||
cacheDependencyPath
|
cacheDependencyPath
|
||||||
);
|
);
|
||||||
expect(infoSpy).toHaveBeenCalledWith('Cache is not found');
|
expect(infoSpy).toHaveBeenCalledWith(`Cache is not found`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set output if cache hit is occurred', async () => {
|
it('should set output if cache hit is occured', async () => {
|
||||||
// Arrange
|
//Arrange
|
||||||
hashFilesSpy.mockImplementation(() => Promise.resolve('file_hash'));
|
hashFilesSpy.mockImplementation((somePath: string) => {
|
||||||
restoreCacheSpy.mockImplementation(() => Promise.resolve('cache_key'));
|
return new Promise<string>(resolve => {
|
||||||
// Act + Assert
|
resolve('file_hash');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
restoreCacheSpy.mockImplementation(() => {
|
||||||
|
return new Promise<string>(resolve => {
|
||||||
|
resolve('cache_key');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//Act + Assert
|
||||||
await cacheRestore.restoreCache(
|
await cacheRestore.restoreCache(
|
||||||
versionSpec,
|
versionSpec,
|
||||||
packageManager,
|
packageManager,
|
||||||
@ -85,18 +96,4 @@ describe('restoreCache', () => {
|
|||||||
);
|
);
|
||||||
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
|
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if dependency file is not found in workspace', async () => {
|
|
||||||
jest.spyOn(fs, 'readdirSync').mockReturnValue(['main.go'] as any);
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
cacheRestore.restoreCache(
|
|
||||||
versionSpec,
|
|
||||||
packageManager
|
|
||||||
// No cacheDependencyPath
|
|
||||||
)
|
|
||||||
).rejects.toThrow(
|
|
||||||
'Dependencies file is not found in /test/workspace. Supported file pattern: go.mod'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,155 +0,0 @@
|
|||||||
import * as cache from '@actions/cache';
|
|
||||||
import * as core from '@actions/core';
|
|
||||||
import fs from 'fs';
|
|
||||||
|
|
||||||
import {run} from '../src/cache-save';
|
|
||||||
import * as cacheUtils from '../src/cache-utils';
|
|
||||||
import {State} from '../src/constants';
|
|
||||||
|
|
||||||
describe('cache-save', () => {
|
|
||||||
const primaryKey = 'primary-key';
|
|
||||||
|
|
||||||
let primaryKeyValue: string;
|
|
||||||
let matchedKeyValue: string;
|
|
||||||
|
|
||||||
let getBooleanInputSpy: jest.SpyInstance;
|
|
||||||
let getStateSpy: jest.SpyInstance;
|
|
||||||
let infoSpy: jest.SpyInstance;
|
|
||||||
let warningSpy: jest.SpyInstance;
|
|
||||||
let debugSpy: jest.SpyInstance;
|
|
||||||
let setFailedSpy: jest.SpyInstance;
|
|
||||||
let saveCacheSpy: jest.SpyInstance;
|
|
||||||
let getCacheDirectoryPathSpy: jest.SpyInstance;
|
|
||||||
let existsSpy: jest.SpyInstance;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
primaryKeyValue = primaryKey;
|
|
||||||
matchedKeyValue = 'matched-key';
|
|
||||||
|
|
||||||
getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
|
|
||||||
getBooleanInputSpy.mockReturnValue(true);
|
|
||||||
|
|
||||||
getStateSpy = jest.spyOn(core, 'getState');
|
|
||||||
getStateSpy.mockImplementation((key: string) => {
|
|
||||||
if (key === State.CachePrimaryKey) {
|
|
||||||
return primaryKeyValue;
|
|
||||||
}
|
|
||||||
if (key === State.CacheMatchedKey) {
|
|
||||||
return matchedKeyValue;
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
});
|
|
||||||
|
|
||||||
infoSpy = jest.spyOn(core, 'info');
|
|
||||||
infoSpy.mockImplementation(() => undefined);
|
|
||||||
|
|
||||||
warningSpy = jest.spyOn(core, 'warning');
|
|
||||||
warningSpy.mockImplementation(() => undefined);
|
|
||||||
|
|
||||||
debugSpy = jest.spyOn(core, 'debug');
|
|
||||||
debugSpy.mockImplementation(() => undefined);
|
|
||||||
|
|
||||||
setFailedSpy = jest.spyOn(core, 'setFailed');
|
|
||||||
setFailedSpy.mockImplementation(() => undefined);
|
|
||||||
|
|
||||||
saveCacheSpy = jest.spyOn(cache, 'saveCache');
|
|
||||||
saveCacheSpy.mockImplementation(() => Promise.resolve(0));
|
|
||||||
|
|
||||||
getCacheDirectoryPathSpy = jest.spyOn(cacheUtils, 'getCacheDirectoryPath');
|
|
||||||
getCacheDirectoryPathSpy.mockImplementation(() =>
|
|
||||||
Promise.resolve(['cache_directory_path', 'cache_directory_path'])
|
|
||||||
);
|
|
||||||
|
|
||||||
existsSpy = jest.spyOn(fs, 'existsSync');
|
|
||||||
existsSpy.mockImplementation(() => true);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
jest.restoreAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not save cache when the cache input is false', async () => {
|
|
||||||
getBooleanInputSpy.mockReturnValue(false);
|
|
||||||
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(saveCacheSpy).not.toHaveBeenCalled();
|
|
||||||
expect(warningSpy).not.toHaveBeenCalled();
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not save cache when there are no cache folders on the disk', async () => {
|
|
||||||
existsSpy.mockImplementation(() => false);
|
|
||||||
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(warningSpy).toHaveBeenCalledWith(
|
|
||||||
'There are no cache folders on the disk'
|
|
||||||
);
|
|
||||||
expect(saveCacheSpy).not.toHaveBeenCalled();
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not save cache when the primary key was not generated', async () => {
|
|
||||||
primaryKeyValue = '';
|
|
||||||
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
|
||||||
'Primary key was not generated. Please check the log messages above for more errors or information'
|
|
||||||
);
|
|
||||||
expect(saveCacheSpy).not.toHaveBeenCalled();
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not save cache when a cache hit occurred on the primary key', async () => {
|
|
||||||
matchedKeyValue = primaryKey;
|
|
||||||
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
|
||||||
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
|
|
||||||
);
|
|
||||||
expect(saveCacheSpy).not.toHaveBeenCalled();
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('saves cache when the primary key differs from the matched key', async () => {
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(saveCacheSpy).toHaveBeenCalled();
|
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
|
||||||
`Cache saved with the key: ${primaryKey}`
|
|
||||||
);
|
|
||||||
expect(warningSpy).not.toHaveBeenCalled();
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('save with -1 cacheId , should not fail workflow', async () => {
|
|
||||||
saveCacheSpy.mockImplementation(() => Promise.resolve(-1));
|
|
||||||
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(saveCacheSpy).toHaveBeenCalled();
|
|
||||||
expect(debugSpy).toHaveBeenCalledWith(
|
|
||||||
`Cache was not saved for the key: ${primaryKey}`
|
|
||||||
);
|
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
|
||||||
`Cache saved with the key: ${primaryKey}`
|
|
||||||
);
|
|
||||||
expect(warningSpy).not.toHaveBeenCalled();
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('saves with error from toolkit, should not fail workflow', async () => {
|
|
||||||
saveCacheSpy.mockImplementation(() =>
|
|
||||||
Promise.reject(new Error('Unable to reach the service'))
|
|
||||||
);
|
|
||||||
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(saveCacheSpy).toHaveBeenCalled();
|
|
||||||
expect(warningSpy).toHaveBeenCalledWith('Unable to reach the service');
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -47,7 +47,7 @@ describe('getPackageManagerInfo', () => {
|
|||||||
//Arrange
|
//Arrange
|
||||||
const packageManagerName = 'default';
|
const packageManagerName = 'default';
|
||||||
const expectedResult = {
|
const expectedResult = {
|
||||||
dependencyFilePattern: 'go.mod',
|
dependencyFilePattern: 'go.sum',
|
||||||
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
|
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ describe('getCacheDirectoryPath', () => {
|
|||||||
const getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
const getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
||||||
|
|
||||||
const validPackageManager: PackageManagerInfo = {
|
const validPackageManager: PackageManagerInfo = {
|
||||||
dependencyFilePattern: 'go.mod',
|
dependencyFilePattern: 'go.sum',
|
||||||
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
|
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
1.22.4
|
|
||||||
@ -1 +0,0 @@
|
|||||||
golang 1.23.2
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user