mirror of https://github.com/actions/setup-go.git
Merge 74a1f88c58 into 4dc6199c7b
This commit is contained in:
commit
d7172599ac
72
README.md
72
README.md
|
|
@ -381,8 +381,80 @@ For more information about semantic versioning, see the [semver documentation](h
|
||||||
|
|
||||||
# Architecture to install (auto-detected if not specified)
|
# Architecture to install (auto-detected if not specified)
|
||||||
architecture: 'x64'
|
architecture: 'x64'
|
||||||
|
|
||||||
|
# Base URL for downloading Go distributions (default: https://github.com)
|
||||||
|
go-download-site: 'https://github.com'
|
||||||
|
|
||||||
|
## Using Custom Download Sites
|
||||||
|
|
||||||
|
For environments with restricted internet access or when using internal mirrors/proxies, you can configure the action to download Go distributions from a custom location using the `go-download-site` input.
|
||||||
|
|
||||||
|
### Use Cases
|
||||||
|
|
||||||
|
- **GitHub Enterprise Server** - Access Go distributions through your internal server
|
||||||
|
- **Corporate Proxies** - Route downloads through approved proxy servers
|
||||||
|
- **Artifact Repositories** - Use internal artifact management systems (Artifactory, Nexus, etc.)
|
||||||
|
- **Air-Gapped Environments** - Download from pre-populated internal mirrors
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version: '1.21'
|
||||||
|
go-download-site: 'https://internal-artifactory.company.com/github-proxy'
|
||||||
|
- run: go version
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**How it works:**
|
||||||
|
|
||||||
|
The action will replace the default `https://github.com` base URL with your custom download site. For example:
|
||||||
|
|
||||||
|
- **Default URL:**
|
||||||
|
```
|
||||||
|
https://github.com/actions/go-versions/releases/download/1.21.13-10277905115/go-1.21.13-linux-x64.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Custom URL (with `go-download-site: 'https://internal-artifactory.company.com/github-proxy'`):**
|
||||||
|
```
|
||||||
|
https://internal-artifactory.company.com/github-proxy/actions/go-versions/releases/download/1.21.13-10277905115/go-1.21.13-linux-x64.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
### Requirements
|
||||||
|
|
||||||
|
Your custom download site must:
|
||||||
|
1. Mirror the same directory structure as GitHub's go-versions repository
|
||||||
|
2. Host the pre-built Go distribution archives
|
||||||
|
3. Be accessible from your runners
|
||||||
|
|
||||||
|
### Example: Using with JFrog Artifactory
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version: '1.23'
|
||||||
|
go-download-site: 'https://artifactory.internal.company.com/artifactory/github-mirror'
|
||||||
|
- run: go version
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example: Using with GitHub Enterprise Server Proxy
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version: '1.22'
|
||||||
|
go-download-site: 'https://ghes.company.com/github-com-proxy'
|
||||||
|
- run: go version
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note:** The `go-download-site` parameter only affects downloads from the go-versions repository. Direct downloads from go.dev (fallback mechanism) are not affected by this setting.
|
||||||
|
|
||||||
## Using setup-go on GHES
|
## Using setup-go on GHES
|
||||||
|
|
||||||
setup-go comes pre-installed on GHES when Actions is enabled. For dynamic Go version downloads, the action fetches distributions from the [go-versions repository](https://github.com/actions/go-versions/) on github.com (external to your appliance).
|
setup-go comes pre-installed on GHES when Actions is enabled. For dynamic Go version downloads, the action fetches distributions from the [go-versions repository](https://github.com/actions/go-versions/) on github.com (external to your appliance).
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,9 @@ inputs:
|
||||||
description: 'Used to specify the path to a dependency file - go.sum'
|
description: 'Used to specify the path to a dependency file - go.sum'
|
||||||
architecture:
|
architecture:
|
||||||
description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.'
|
description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.'
|
||||||
|
go-download-site:
|
||||||
|
description: 'Base URL for downloading Go distributions. Useful for GitHub Enterprise or when using a proxy/mirror. Defaults to https://github.com'
|
||||||
|
default: 'https://github.com'
|
||||||
outputs:
|
outputs:
|
||||||
go-version:
|
go-version:
|
||||||
description: 'The installed Go version. Useful when given a version range as input.'
|
description: 'The installed Go version. Useful when given a version range as input.'
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,8 @@ export async function getGo(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
checkLatest: boolean,
|
checkLatest: boolean,
|
||||||
auth: string | undefined,
|
auth: string | undefined,
|
||||||
arch: Architecture = os.arch() as Architecture
|
arch: Architecture = os.arch() as Architecture,
|
||||||
|
goDownloadSite: string = 'https://github.com'
|
||||||
) {
|
) {
|
||||||
let manifest: tc.IToolRelease[] | undefined;
|
let manifest: tc.IToolRelease[] | undefined;
|
||||||
const osPlat: string = os.platform();
|
const osPlat: string = os.platform();
|
||||||
|
|
@ -80,7 +81,8 @@ export async function getGo(
|
||||||
true,
|
true,
|
||||||
auth,
|
auth,
|
||||||
arch,
|
arch,
|
||||||
manifest
|
manifest,
|
||||||
|
goDownloadSite
|
||||||
);
|
);
|
||||||
if (resolvedVersion) {
|
if (resolvedVersion) {
|
||||||
versionSpec = resolvedVersion;
|
versionSpec = resolvedVersion;
|
||||||
|
|
@ -105,7 +107,7 @@ export async function getGo(
|
||||||
// Try download from internal distribution (popular versions only)
|
// Try download from internal distribution (popular versions only)
|
||||||
//
|
//
|
||||||
try {
|
try {
|
||||||
info = await getInfoFromManifest(versionSpec, true, auth, arch, manifest);
|
info = await getInfoFromManifest(versionSpec, true, auth, arch, manifest, goDownloadSite);
|
||||||
if (info) {
|
if (info) {
|
||||||
downloadPath = await installGoVersion(info, auth, arch);
|
downloadPath = await installGoVersion(info, auth, arch);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -155,7 +157,8 @@ async function resolveVersionFromManifest(
|
||||||
stable: boolean,
|
stable: boolean,
|
||||||
auth: string | undefined,
|
auth: string | undefined,
|
||||||
arch: Architecture,
|
arch: Architecture,
|
||||||
manifest: tc.IToolRelease[] | undefined
|
manifest: tc.IToolRelease[] | undefined,
|
||||||
|
goDownloadSite: string = 'https://github.com'
|
||||||
): Promise<string | undefined> {
|
): Promise<string | undefined> {
|
||||||
try {
|
try {
|
||||||
const info = await getInfoFromManifest(
|
const info = await getInfoFromManifest(
|
||||||
|
|
@ -163,7 +166,8 @@ async function resolveVersionFromManifest(
|
||||||
stable,
|
stable,
|
||||||
auth,
|
auth,
|
||||||
arch,
|
arch,
|
||||||
manifest
|
manifest,
|
||||||
|
goDownloadSite
|
||||||
);
|
);
|
||||||
return info?.resolvedVersion;
|
return info?.resolvedVersion;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
@ -357,7 +361,8 @@ export async function getInfoFromManifest(
|
||||||
stable: boolean,
|
stable: boolean,
|
||||||
auth: string | undefined,
|
auth: string | undefined,
|
||||||
arch: Architecture = os.arch() as Architecture,
|
arch: Architecture = os.arch() as Architecture,
|
||||||
manifest?: tc.IToolRelease[] | undefined
|
manifest?: tc.IToolRelease[] | undefined,
|
||||||
|
goDownloadSite: string = 'https://github.com'
|
||||||
): Promise<IGoVersionInfo | null> {
|
): Promise<IGoVersionInfo | null> {
|
||||||
let info: IGoVersionInfo | null = null;
|
let info: IGoVersionInfo | null = null;
|
||||||
if (!manifest) {
|
if (!manifest) {
|
||||||
|
|
@ -373,7 +378,8 @@ export async function getInfoFromManifest(
|
||||||
info = <IGoVersionInfo>{};
|
info = <IGoVersionInfo>{};
|
||||||
info.type = 'manifest';
|
info.type = 'manifest';
|
||||||
info.resolvedVersion = rel.version;
|
info.resolvedVersion = rel.version;
|
||||||
info.downloadUrl = rel.files[0].download_url;
|
// Replace the default github.com URL with the custom download site
|
||||||
|
info.downloadUrl = rel.files[0].download_url.replace('https://github.com', goDownloadSite);
|
||||||
info.fileName = rel.files[0].filename;
|
info.fileName = rel.files[0].filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,14 @@ export async function run() {
|
||||||
const auth = !token ? undefined : `token ${token}`;
|
const auth = !token ? undefined : `token ${token}`;
|
||||||
|
|
||||||
const checkLatest = core.getBooleanInput('check-latest');
|
const checkLatest = core.getBooleanInput('check-latest');
|
||||||
|
const goDownloadSite = core.getInput('go-download-site') || 'https://github.com';
|
||||||
|
|
||||||
const installDir = await installer.getGo(
|
const installDir = await installer.getGo(
|
||||||
versionSpec,
|
versionSpec,
|
||||||
checkLatest,
|
checkLatest,
|
||||||
auth,
|
auth,
|
||||||
arch
|
arch,
|
||||||
|
goDownloadSite
|
||||||
);
|
);
|
||||||
|
|
||||||
const installDirVersion = path.basename(path.dirname(installDir));
|
const installDirVersion = path.basename(path.dirname(installDir));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue