mirror of
https://github.com/actions/setup-go.git
synced 2026-03-18 17:01:43 +08:00
* feat: add go-download-base-url input for custom Go distributions
Add support for downloading Go from custom sources such as Microsoft Go
(aka.ms). Users can specify a custom download base URL via the
`go-download-base-url` input or the `GO_DOWNLOAD_BASE_URL` environment
variable (input takes precedence).
When a custom URL is provided, the action skips the GitHub-hosted
manifest and attempts to resolve versions from the custom URL's JSON
listing. If the listing is unavailable (as with aka.ms redirect links),
it falls back to constructing the download URL directly from the
version, platform, and architecture.
Usage:
- uses: actions/setup-go@v6
with:
go-version: '1.25'
go-download-base-url: 'https://aka.ms/golang/release/latest'
Changes:
- action.yml: add go-download-base-url optional input
- installer.ts: add getInfoFromDirectDownload() for URL construction
fallback, thread custom URL through getGo/getInfoFromDist/findMatch
- main.ts: read new input and GO_DOWNLOAD_BASE_URL env var
- setup-go.test.ts: add 12 unit tests for custom URL behavior
- microsoft-validation.yml: add E2E workflow testing Microsoft build of Go
across ubuntu/windows/macos with versions 1.24 and 1.25
- README.md: document new input with Microsoft build of Go examples
* run prettier
* fixup PR review
* revert cache-save
* fixup
* handle distinct cache
* skip json for known URL
* fix bug in JSON with custom URL
144 lines
3.7 KiB
YAML
144 lines
3.7 KiB
YAML
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
|