Compare commits
11 Commits
89a192af9d
...
internal
Author | SHA1 | Date | |
---|---|---|---|
aef5ea64d0 | |||
|
bfd2fb341f | ||
|
3d65fa57fc | ||
|
8a505c9cf2 | ||
|
883490dfd0 | ||
|
d45ebba0ce | ||
|
317c6617fa | ||
|
f90673ad64 | ||
|
8018234347 | ||
|
d085b4fe57 | ||
|
48ac8fd236 |
20
.github/workflows/versions.yml
vendored
20
.github/workflows/versions.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Go Stable
|
||||
uses: ./
|
||||
with:
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Go oldStable
|
||||
uses: ./
|
||||
with:
|
||||
@@ -55,7 +55,7 @@ jobs:
|
||||
- os: macos-latest
|
||||
architecture: x32
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }}
|
||||
uses: ./
|
||||
with:
|
||||
@@ -74,7 +74,7 @@ jobs:
|
||||
go: [1.17, 1.18, 1.19]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: setup-go ${{ matrix.go }}
|
||||
uses: ./
|
||||
@@ -93,7 +93,7 @@ jobs:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
go-version: [1.16, 1.17]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Go and check latest
|
||||
uses: ./
|
||||
with:
|
||||
@@ -109,7 +109,7 @@ jobs:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Go and check latest
|
||||
uses: ./
|
||||
with:
|
||||
@@ -125,7 +125,7 @@ jobs:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Go and check latest
|
||||
uses: ./
|
||||
with:
|
||||
@@ -144,7 +144,7 @@ jobs:
|
||||
go: [1.12.16, 1.13.11, 1.14.3]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: setup-go ${{ matrix.go }}
|
||||
uses: ./
|
||||
@@ -165,7 +165,7 @@ jobs:
|
||||
go: [1.9, 1.8.6]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: setup-go ${{ matrix.go }}
|
||||
uses: ./
|
||||
@@ -184,7 +184,7 @@ jobs:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
go-version: [1.16, 1.17]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Go and check latest
|
||||
uses: ./
|
||||
with:
|
||||
|
9
.github/workflows/windows-validation.yml
vendored
9
.github/workflows/windows-validation.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
cache: [false, true]
|
||||
go: [1.20.1]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: 'Setup ${{ matrix.cache }}, cache: ${{ matrix.go }}'
|
||||
uses: ./
|
||||
@@ -88,7 +88,7 @@ jobs:
|
||||
matrix:
|
||||
cache: [false, true]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: 'Setup default go, cache: ${{ matrix.cache }}'
|
||||
uses: ./
|
||||
@@ -121,7 +121,7 @@ jobs:
|
||||
cache: [false]
|
||||
go: [1.20.1]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}'
|
||||
uses: ./
|
||||
@@ -134,6 +134,3 @@ jobs:
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
cache: ${{ matrix.cache }}
|
||||
|
||||
|
||||
|
||||
|
30
README.md
30
README.md
@@ -42,7 +42,7 @@ Matching by [semver spec](https://github.com/npm/node-semver):
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '^1.13.1' # The Go version to download (if necessary) and use.
|
||||
@@ -51,7 +51,7 @@ steps:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '>=1.17.0'
|
||||
@@ -69,7 +69,7 @@ Matching an unstable pre-release:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.18.0-rc.1' # The Go version to download (if necessary) and use.
|
||||
@@ -78,7 +78,7 @@ steps:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.16.0-beta.1' # The Go version to download (if necessary) and use.
|
||||
@@ -93,7 +93,7 @@ See [action.yml](action.yml)
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.16.1' # The Go version to download (if necessary) and use.
|
||||
@@ -114,7 +114,7 @@ want the most up-to-date Go version to always be used.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.14'
|
||||
@@ -135,7 +135,7 @@ set to `true`
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: 'stable'
|
||||
@@ -144,7 +144,7 @@ steps:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: 'oldstable'
|
||||
@@ -159,7 +159,7 @@ 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.
|
||||
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.
|
||||
|
||||
@@ -167,12 +167,16 @@ If some problem that prevents success caching happens then the action issues the
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.17'
|
||||
check-latest: true
|
||||
cache-dependency-path: subdir/go.sum
|
||||
cache-dependency-path: |
|
||||
subdir/go.sum
|
||||
tools/go.sum
|
||||
# cache-dependency-path: "**/*.sum"
|
||||
|
||||
- run: go run hello.go
|
||||
```
|
||||
|
||||
@@ -189,7 +193,7 @@ If both the `go-version` and the `go-version-file` inputs are provided then the
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version-file: 'path/to/go.mod'
|
||||
@@ -207,7 +211,7 @@ jobs:
|
||||
go: [ '1.14', '1.13' ]
|
||||
name: Go ${{ matrix.go }} sample
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
|
@@ -142,7 +142,7 @@ describe('setup-go', () => {
|
||||
os.platform = 'darwin';
|
||||
os.arch = 'x64';
|
||||
|
||||
const match = await im.getInfoFromManifest('1.9.7', true, 'mocktoken');
|
||||
const match = await im.getInfoFromManifest('1.21', true, 'mocktoken');
|
||||
expect(match).toBeDefined();
|
||||
expect(match!.resolvedVersion).toBe('1.9.7');
|
||||
expect(match!.type).toBe('manifest');
|
||||
|
@@ -25,7 +25,7 @@ outputs:
|
||||
cache-hit:
|
||||
description: 'A boolean value to indicate if a cache was hit'
|
||||
runs:
|
||||
using: 'node16'
|
||||
using: 'node20'
|
||||
main: 'dist/setup/index.js'
|
||||
post: 'dist/cache-save/index.js'
|
||||
post-if: success()
|
||||
|
43
dist/setup/index.js
vendored
43
dist/setup/index.js
vendored
@@ -61385,7 +61385,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.resolveStableVersionInput = exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getManifest = exports.extractGoArchive = exports.getGo = void 0;
|
||||
exports.resolveStableVersionInput = exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getManifestFromRepo = exports.getManifest = exports.extractGoArchive = exports.getGo = void 0;
|
||||
const tc = __importStar(__nccwpck_require__(7784));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const path = __importStar(__nccwpck_require__(1017));
|
||||
@@ -61568,10 +61568,49 @@ function extractGoArchive(archivePath) {
|
||||
exports.extractGoArchive = extractGoArchive;
|
||||
function getManifest(auth) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return tc.getManifestFromRepo('actions', 'go-versions', auth, 'main');
|
||||
return getManifestFromRepo('actions', 'go-versions', auth, 'main');
|
||||
});
|
||||
}
|
||||
exports.getManifest = getManifest;
|
||||
function getManifestFromRepo(owner, repo, auth, branch = 'master') {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let releases = [];
|
||||
const treeUrl = `https://gitea.icodef.com/api/v1/repos/${owner}/${repo}/git/trees/${branch}`;
|
||||
const http = new httpm.HttpClient('tool-cache');
|
||||
const headers = {};
|
||||
if (auth) {
|
||||
core.debug('set auth');
|
||||
headers.authorization = auth;
|
||||
}
|
||||
const response = yield http.getJson(treeUrl, headers);
|
||||
if (!response.result) {
|
||||
return releases;
|
||||
}
|
||||
let manifestUrl = '';
|
||||
for (const item of response.result.tree) {
|
||||
if (item.path === 'versions-manifest.json') {
|
||||
manifestUrl = item.url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
headers['accept'] = 'application/vnd.github.VERSION.raw';
|
||||
const versionsRaw = yield (yield http.get(manifestUrl, headers)).readBody();
|
||||
const base64 = JSON.parse(versionsRaw);
|
||||
let tmp = Buffer.from(base64['content'], 'base64').toString('ascii');
|
||||
if (tmp) {
|
||||
// shouldn't be needed but protects against invalid json saved with BOM
|
||||
tmp = tmp.replace(/^\uFEFF/, '');
|
||||
try {
|
||||
releases = JSON.parse(tmp);
|
||||
}
|
||||
catch (_a) {
|
||||
core.debug('Invalid json');
|
||||
}
|
||||
}
|
||||
return releases;
|
||||
});
|
||||
}
|
||||
exports.getManifestFromRepo = getManifestFromRepo;
|
||||
function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch(), manifest) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let info = null;
|
||||
|
@@ -32,7 +32,7 @@ We don't pursue the goal to provide wide customization of caching in scope of `a
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '18'
|
||||
@@ -43,7 +43,7 @@ steps:
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '18'
|
||||
@@ -53,7 +53,7 @@ steps:
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '18'
|
||||
|
@@ -7,6 +7,8 @@ import * as sys from './system';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import {StableReleaseAlias} from './utils';
|
||||
import {IToolRelease} from '@actions/tool-cache';
|
||||
import {OutgoingHttpHeaders} from 'http';
|
||||
|
||||
type InstallationType = 'dist' | 'manifest';
|
||||
|
||||
@@ -205,8 +207,14 @@ async function cacheWindowsDir(
|
||||
|
||||
const actualToolCacheCompleteFile = `${actualToolCacheDir}.complete`;
|
||||
const defaultToolCacheCompleteFile = `${defaultToolCacheDir}.complete`;
|
||||
fs.symlinkSync(actualToolCacheCompleteFile, defaultToolCacheCompleteFile, 'file');
|
||||
core.info(`Created link ${defaultToolCacheCompleteFile} => ${actualToolCacheCompleteFile}`);
|
||||
fs.symlinkSync(
|
||||
actualToolCacheCompleteFile,
|
||||
defaultToolCacheCompleteFile,
|
||||
'file'
|
||||
);
|
||||
core.info(
|
||||
`Created link ${defaultToolCacheCompleteFile} => ${actualToolCacheCompleteFile}`
|
||||
);
|
||||
|
||||
// make outer code to continue using toolcache as if it were installed on c:
|
||||
// restore toolcache root to default drive c:
|
||||
@@ -269,7 +277,67 @@ export async function extractGoArchive(archivePath: string): Promise<string> {
|
||||
}
|
||||
|
||||
export async function getManifest(auth: string | undefined) {
|
||||
return tc.getManifestFromRepo('actions', 'go-versions', auth, 'main');
|
||||
return getManifestFromRepo('actions', 'go-versions', auth, 'main');
|
||||
}
|
||||
|
||||
interface GitHubTreeItem {
|
||||
path: string;
|
||||
size: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface GitHubTree {
|
||||
tree: GitHubTreeItem[];
|
||||
truncated: boolean;
|
||||
}
|
||||
|
||||
export async function getManifestFromRepo(
|
||||
owner: string,
|
||||
repo: string,
|
||||
auth?: string,
|
||||
branch = 'master'
|
||||
): Promise<IToolRelease[]> {
|
||||
let releases: IToolRelease[] = [];
|
||||
const treeUrl = `https://gitea.icodef.com/api/v1/repos/${owner}/${repo}/git/trees/${branch}`;
|
||||
|
||||
const http: httpm.HttpClient = new httpm.HttpClient('tool-cache');
|
||||
const headers: OutgoingHttpHeaders = {};
|
||||
if (auth) {
|
||||
core.debug('set auth');
|
||||
headers.authorization = auth;
|
||||
}
|
||||
|
||||
const response = await http.getJson<GitHubTree>(treeUrl, headers);
|
||||
if (!response.result) {
|
||||
return releases;
|
||||
}
|
||||
|
||||
let manifestUrl = '';
|
||||
for (const item of response.result.tree) {
|
||||
if (item.path === 'versions-manifest.json') {
|
||||
manifestUrl = item.url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
headers['accept'] = 'application/vnd.github.VERSION.raw';
|
||||
const versionsRaw = await (await http.get(manifestUrl, headers)).readBody();
|
||||
|
||||
const base64 = JSON.parse(versionsRaw);
|
||||
|
||||
let tmp = Buffer.from(base64['content'], 'base64').toString('ascii');
|
||||
|
||||
if (tmp) {
|
||||
// shouldn't be needed but protects against invalid json saved with BOM
|
||||
tmp = tmp.replace(/^\uFEFF/, '');
|
||||
try {
|
||||
releases = JSON.parse(tmp);
|
||||
} catch {
|
||||
core.debug('Invalid json');
|
||||
}
|
||||
}
|
||||
|
||||
return releases;
|
||||
}
|
||||
|
||||
export async function getInfoFromManifest(
|
||||
|
Reference in New Issue
Block a user