mirror of
https://github.com/actions/setup-go.git
synced 2025-04-23 17:40:50 +00:00
Merge branch 'modules-caching' into modules-caching-tests
This commit is contained in:
commit
1a1c412f7e
17 changed files with 212 additions and 453 deletions
4
.github/workflows/check-dist.yml
vendored
4
.github/workflows/check-dist.yml
vendored
|
@ -23,10 +23,10 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set Node.js 12.x
|
- name: Set Node.js 16.x
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 12.x
|
node-version: 16.x
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
6
.github/workflows/licensed.yml
vendored
6
.github/workflows/licensed.yml
vendored
|
@ -14,11 +14,15 @@ jobs:
|
||||||
name: Check licenses
|
name: Check licenses
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set Node.js 16.x
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 16.x
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- name: Install licensed
|
- name: Install licensed
|
||||||
run: |
|
run: |
|
||||||
cd $RUNNER_TEMP
|
cd $RUNNER_TEMP
|
||||||
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.3.1/licensed-3.3.1-linux-x64.tar.gz
|
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.4.4/licensed-3.4.4-linux-x64.tar.gz
|
||||||
sudo tar -xzf licensed.tar.gz
|
sudo tar -xzf licensed.tar.gz
|
||||||
sudo mv licensed /usr/local/bin/licensed
|
sudo mv licensed /usr/local/bin/licensed
|
||||||
- run: licensed status
|
- run: licensed status
|
||||||
|
|
2
.github/workflows/versions.yml
vendored
2
.github/workflows/versions.yml
vendored
|
@ -78,7 +78,7 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
go: [1.7, 1.8.6]
|
go: [1.9, 1.8.6]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
4
.github/workflows/workflow.yml
vendored
4
.github/workflows/workflow.yml
vendored
|
@ -19,10 +19,10 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Setup node 12
|
- name: Setup node 16
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 12
|
node-version: 16
|
||||||
cache: npm
|
cache: npm
|
||||||
|
|
||||||
- name: npm ci
|
- name: npm ci
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
* @actions/spark
|
* @actions/actions-service
|
||||||
|
|
50
README.md
50
README.md
|
@ -11,12 +11,11 @@ This action sets up a go environment for use in actions by:
|
||||||
- optionally downloading and caching a version of Go by version and adding to PATH
|
- optionally downloading and caching a version of Go by version and adding to PATH
|
||||||
- registering problem matchers for error output
|
- registering problem matchers for error output
|
||||||
|
|
||||||
# V2
|
# V3
|
||||||
|
|
||||||
The V2 offers:
|
The V3 offers:
|
||||||
- Adds GOBIN to the PATH
|
- Adds GOBIN to the PATH
|
||||||
- Proxy Support
|
- Proxy Support
|
||||||
- `stable` input
|
|
||||||
- Check latest version
|
- Check latest version
|
||||||
- Bug Fixes (including issues around version matching and semver)
|
- Bug Fixes (including issues around version matching and semver)
|
||||||
|
|
||||||
|
@ -25,21 +24,38 @@ The action will first check the local cache for a version match. If a version is
|
||||||
Matching by [semver spec](https://github.com/npm/node-semver):
|
Matching by [semver spec](https://github.com/npm/node-semver):
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '^1.13.1' # 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 version
|
- run: go version
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '>=1.17.0'
|
||||||
|
- run: go version
|
||||||
|
```
|
||||||
|
|
||||||
Matching an unstable pre-release:
|
Matching an unstable pre-release:
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
stable: 'false'
|
go-version: '1.18.0-rc.1' # The Go version to download (if necessary) and use.
|
||||||
go-version: '1.14.0-rc1' # The Go version to download (if necessary) and use.
|
- run: go version
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '1.16.0-beta.1' # The Go version to download (if necessary) and use.
|
||||||
- run: go version
|
- run: go version
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -50,8 +66,8 @@ See [action.yml](action.yml)
|
||||||
## Basic:
|
## Basic:
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '1.16.1' # The Go version to download (if necessary) and use.
|
go-version: '1.16.1' # The Go version to download (if necessary) and use.
|
||||||
- run: go run hello.go
|
- run: go run hello.go
|
||||||
|
@ -68,8 +84,8 @@ If `check-latest` is set to `true`, the action first checks if the cached versio
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '1.14'
|
go-version: '1.14'
|
||||||
check-latest: true
|
check-latest: true
|
||||||
|
@ -86,9 +102,9 @@ jobs:
|
||||||
go: [ '1.14', '1.13' ]
|
go: [ '1.14', '1.13' ]
|
||||||
name: Go ${{ matrix.go }} sample
|
name: Go ${{ matrix.go }} sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Setup go
|
- name: Setup go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
- run: go run hello.go
|
- run: go run hello.go
|
||||||
|
@ -97,8 +113,8 @@ jobs:
|
||||||
### Supported version syntax
|
### Supported version syntax
|
||||||
The `go-version` input supports the following syntax:
|
The `go-version` input supports the following syntax:
|
||||||
|
|
||||||
Specific versions: `1.15`, `1.16.1`, `1.17.0-rc2`, `1.16.0-beta1`
|
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`
|
SemVer's version range syntax: `^1.13.1`, `>=1.18.0-rc.1`
|
||||||
For more information about semantic versioning please refer [semver](https://github.com/npm/node-semver) documentation
|
For more information about semantic versioning please refer [semver](https://github.com/npm/node-semver) documentation
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
|
@ -20,6 +20,7 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
let inSpy: jest.SpyInstance;
|
let inSpy: jest.SpyInstance;
|
||||||
let getBooleanInputSpy: jest.SpyInstance;
|
let getBooleanInputSpy: jest.SpyInstance;
|
||||||
|
let exportVarSpy: jest.SpyInstance;
|
||||||
let findSpy: jest.SpyInstance;
|
let findSpy: jest.SpyInstance;
|
||||||
let cnSpy: jest.SpyInstance;
|
let cnSpy: jest.SpyInstance;
|
||||||
let logSpy: jest.SpyInstance;
|
let logSpy: jest.SpyInstance;
|
||||||
|
@ -27,7 +28,7 @@ describe('setup-go', () => {
|
||||||
let platSpy: jest.SpyInstance;
|
let platSpy: jest.SpyInstance;
|
||||||
let archSpy: jest.SpyInstance;
|
let archSpy: jest.SpyInstance;
|
||||||
let dlSpy: jest.SpyInstance;
|
let dlSpy: jest.SpyInstance;
|
||||||
let exSpy: jest.SpyInstance;
|
let extractTarSpy: jest.SpyInstance;
|
||||||
let cacheSpy: jest.SpyInstance;
|
let cacheSpy: jest.SpyInstance;
|
||||||
let dbgSpy: jest.SpyInstance;
|
let dbgSpy: jest.SpyInstance;
|
||||||
let whichSpy: jest.SpyInstance;
|
let whichSpy: jest.SpyInstance;
|
||||||
|
@ -49,6 +50,7 @@ describe('setup-go', () => {
|
||||||
inSpy.mockImplementation(name => inputs[name]);
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
|
getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
|
||||||
getBooleanInputSpy.mockImplementation(name => inputs[name]);
|
getBooleanInputSpy.mockImplementation(name => inputs[name]);
|
||||||
|
exportVarSpy = jest.spyOn(core, 'exportVariable');
|
||||||
|
|
||||||
// node
|
// node
|
||||||
os = {};
|
os = {};
|
||||||
|
@ -61,7 +63,7 @@ describe('setup-go', () => {
|
||||||
// @actions/tool-cache
|
// @actions/tool-cache
|
||||||
findSpy = jest.spyOn(tc, 'find');
|
findSpy = jest.spyOn(tc, 'find');
|
||||||
dlSpy = jest.spyOn(tc, 'downloadTool');
|
dlSpy = jest.spyOn(tc, 'downloadTool');
|
||||||
exSpy = jest.spyOn(tc, 'extractTar');
|
extractTarSpy = jest.spyOn(tc, 'extractTar');
|
||||||
cacheSpy = jest.spyOn(tc, 'cacheDir');
|
cacheSpy = jest.spyOn(tc, 'cacheDir');
|
||||||
getSpy = jest.spyOn(im, 'getVersionsDist');
|
getSpy = jest.spyOn(im, 'getVersionsDist');
|
||||||
getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
|
getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
|
||||||
|
@ -147,7 +149,7 @@ describe('setup-go', () => {
|
||||||
os.arch = 'x64';
|
os.arch = 'x64';
|
||||||
|
|
||||||
// spec: 1.13.0 => 1.13
|
// spec: 1.13.0 => 1.13
|
||||||
let match: im.IGoVersion | undefined = await im.findMatch('1.13.0', true);
|
let match: im.IGoVersion | undefined = await im.findMatch('1.13.0');
|
||||||
expect(match).toBeDefined();
|
expect(match).toBeDefined();
|
||||||
let version: string = match ? match.version : '';
|
let version: string = match ? match.version : '';
|
||||||
expect(version).toBe('go1.13');
|
expect(version).toBe('go1.13');
|
||||||
|
@ -160,7 +162,7 @@ describe('setup-go', () => {
|
||||||
os.arch = 'x64';
|
os.arch = 'x64';
|
||||||
|
|
||||||
// spec: 1.13 => 1.13.7 (latest)
|
// spec: 1.13 => 1.13.7 (latest)
|
||||||
let match: im.IGoVersion | undefined = await im.findMatch('1.13', true);
|
let match: im.IGoVersion | undefined = await im.findMatch('1.13');
|
||||||
expect(match).toBeDefined();
|
expect(match).toBeDefined();
|
||||||
let version: string = match ? match.version : '';
|
let version: string = match ? match.version : '';
|
||||||
expect(version).toBe('go1.13.7');
|
expect(version).toBe('go1.13.7');
|
||||||
|
@ -173,7 +175,7 @@ describe('setup-go', () => {
|
||||||
os.arch = 'x64';
|
os.arch = 'x64';
|
||||||
|
|
||||||
// spec: ^1.13.6 => 1.13.7
|
// spec: ^1.13.6 => 1.13.7
|
||||||
let match: im.IGoVersion | undefined = await im.findMatch('^1.13.6', true);
|
let match: im.IGoVersion | undefined = await im.findMatch('^1.13.6');
|
||||||
expect(match).toBeDefined();
|
expect(match).toBeDefined();
|
||||||
let version: string = match ? match.version : '';
|
let version: string = match ? match.version : '';
|
||||||
expect(version).toBe('go1.13.7');
|
expect(version).toBe('go1.13.7');
|
||||||
|
@ -186,7 +188,7 @@ describe('setup-go', () => {
|
||||||
os.arch = 'x32';
|
os.arch = 'x32';
|
||||||
|
|
||||||
// spec: 1 => 1.13.7 (latest)
|
// spec: 1 => 1.13.7 (latest)
|
||||||
let match: im.IGoVersion | undefined = await im.findMatch('1', true);
|
let match: im.IGoVersion | undefined = await im.findMatch('1');
|
||||||
expect(match).toBeDefined();
|
expect(match).toBeDefined();
|
||||||
let version: string = match ? match.version : '';
|
let version: string = match ? match.version : '';
|
||||||
expect(version).toBe('go1.13.7');
|
expect(version).toBe('go1.13.7');
|
||||||
|
@ -199,10 +201,7 @@ describe('setup-go', () => {
|
||||||
os.arch = 'x64';
|
os.arch = 'x64';
|
||||||
|
|
||||||
// spec: 1.14, stable=false => go1.14rc1
|
// spec: 1.14, stable=false => go1.14rc1
|
||||||
let match: im.IGoVersion | undefined = await im.findMatch(
|
let match: im.IGoVersion | undefined = await im.findMatch('1.14.0-rc.1');
|
||||||
'1.14.0-rc1',
|
|
||||||
false
|
|
||||||
);
|
|
||||||
expect(match).toBeDefined();
|
expect(match).toBeDefined();
|
||||||
let version: string = match ? match.version : '';
|
let version: string = match ? match.version : '';
|
||||||
expect(version).toBe('go1.14rc1');
|
expect(version).toBe('go1.14rc1');
|
||||||
|
@ -218,7 +217,7 @@ describe('setup-go', () => {
|
||||||
findSpy.mockImplementation(() => toolPath);
|
findSpy.mockImplementation(() => toolPath);
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(`Setup go stable version spec 1.13.0`);
|
expect(logSpy).toHaveBeenCalledWith(`Setup go version spec 1.13.0`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('evaluates to stable with no input', async () => {
|
it('evaluates to stable with no input', async () => {
|
||||||
|
@ -230,7 +229,41 @@ describe('setup-go', () => {
|
||||||
findSpy.mockImplementation(() => toolPath);
|
findSpy.mockImplementation(() => toolPath);
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(`Setup go stable version spec 1.13.0`);
|
expect(logSpy).toHaveBeenCalledWith(`Setup go version spec 1.13.0`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not export any variables for Go versions >=1.9', async () => {
|
||||||
|
inputs['go-version'] = '1.13.0';
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
let toolPath = path.normalize('/cache/go/1.13.0/x64');
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
|
||||||
|
let vars: {[key: string]: string} = {};
|
||||||
|
exportVarSpy.mockImplementation((name: string, val: string) => {
|
||||||
|
vars[name] = val;
|
||||||
|
});
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
expect(vars).toStrictEqual({});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('exports GOROOT for Go versions <1.9', async () => {
|
||||||
|
inputs['go-version'] = '1.8';
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
let toolPath = path.normalize('/cache/go/1.8.0/x64');
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
|
||||||
|
let vars: {[key: string]: string} = {};
|
||||||
|
exportVarSpy.mockImplementation((name: string, val: string) => {
|
||||||
|
vars[name] = val;
|
||||||
|
});
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
expect(vars).toStrictEqual({
|
||||||
|
GOROOT: toolPath
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('finds a version of go already in the cache', async () => {
|
it('finds a version of go already in the cache', async () => {
|
||||||
|
@ -274,14 +307,14 @@ describe('setup-go', () => {
|
||||||
findSpy.mockImplementation(() => '');
|
findSpy.mockImplementation(() => '');
|
||||||
dlSpy.mockImplementation(() => '/some/temp/path');
|
dlSpy.mockImplementation(() => '/some/temp/path');
|
||||||
let toolPath = path.normalize('/cache/go/1.13.0/x64');
|
let toolPath = path.normalize('/cache/go/1.13.0/x64');
|
||||||
exSpy.mockImplementation(() => '/some/other/temp/path');
|
extractTarSpy.mockImplementation(() => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(() => toolPath);
|
cacheSpy.mockImplementation(() => toolPath);
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
let expPath = path.join(toolPath, 'bin');
|
let expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
expect(dlSpy).toHaveBeenCalled();
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
expect(exSpy).toHaveBeenCalled();
|
expect(extractTarSpy).toHaveBeenCalled();
|
||||||
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -316,7 +349,7 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
let toolPath = path.normalize('/cache/go/1.12.16/x64');
|
let toolPath = path.normalize('/cache/go/1.12.16/x64');
|
||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
@ -324,7 +357,7 @@ describe('setup-go', () => {
|
||||||
let expPath = path.join(toolPath, 'bin');
|
let expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
expect(dlSpy).toHaveBeenCalled();
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
expect(exSpy).toHaveBeenCalled();
|
expect(extractTarSpy).toHaveBeenCalled();
|
||||||
expect(logSpy).not.toHaveBeenCalledWith(
|
expect(logSpy).not.toHaveBeenCalledWith(
|
||||||
'Not found in manifest. Falling back to download directly from Go'
|
'Not found in manifest. Falling back to download directly from Go'
|
||||||
);
|
);
|
||||||
|
@ -353,7 +386,7 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
let toolPath = path.normalize('/cache/go/1.12.17/x64');
|
let toolPath = path.normalize('/cache/go/1.12.17/x64');
|
||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
@ -361,7 +394,7 @@ describe('setup-go', () => {
|
||||||
let expPath = path.join(toolPath, 'bin');
|
let expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
expect(dlSpy).toHaveBeenCalled();
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
expect(exSpy).toHaveBeenCalled();
|
expect(extractTarSpy).toHaveBeenCalled();
|
||||||
expect(logSpy).not.toHaveBeenCalledWith(
|
expect(logSpy).not.toHaveBeenCalledWith(
|
||||||
'Not found in manifest. Falling back to download directly from Go'
|
'Not found in manifest. Falling back to download directly from Go'
|
||||||
);
|
);
|
||||||
|
@ -390,18 +423,18 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
let toolPath = path.normalize('/cache/go/1.12.14/x64');
|
let toolPath = path.normalize('/cache/go/1.12.14/x64');
|
||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
let expPath = path.join(toolPath, 'bin');
|
let expPath = path.join(toolPath, 'bin');
|
||||||
expect(logSpy).toHaveBeenCalledWith('Setup go stable version spec 1.12.14');
|
expect(logSpy).toHaveBeenCalledWith('Setup go version spec 1.12.14');
|
||||||
expect(findSpy).toHaveBeenCalled();
|
expect(findSpy).toHaveBeenCalled();
|
||||||
expect(logSpy).toHaveBeenCalledWith('Attempting to download 1.12.14...');
|
expect(logSpy).toHaveBeenCalledWith('Attempting to download 1.12.14...');
|
||||||
expect(dlSpy).toHaveBeenCalled();
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
expect(logSpy).toHaveBeenCalledWith('matching 1.12.14...');
|
expect(logSpy).toHaveBeenCalledWith('matching 1.12.14...');
|
||||||
expect(exSpy).toHaveBeenCalled();
|
expect(extractTarSpy).toHaveBeenCalled();
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
'Not found in manifest. Falling back to download directly from Go'
|
'Not found in manifest. Falling back to download directly from Go'
|
||||||
);
|
);
|
||||||
|
@ -560,11 +593,11 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
// 1.13.1 => 1.13.1
|
// 1.13.1 => 1.13.1
|
||||||
// 1.13 => 1.13.0
|
// 1.13 => 1.13.0
|
||||||
// 1.10beta1 => 1.10.0-beta1, 1.10rc1 => 1.10.0-rc1
|
// 1.10beta1 => 1.10.0-beta.1, 1.10rc1 => 1.10.0-rc.1
|
||||||
// 1.8.5beta1 => 1.8.5-beta1, 1.8.5rc1 => 1.8.5-rc1
|
// 1.8.5beta1 => 1.8.5-beta.1, 1.8.5rc1 => 1.8.5-rc.1
|
||||||
it('converts prerelease versions', async () => {
|
it('converts prerelease versions', async () => {
|
||||||
expect(im.makeSemver('1.10beta1')).toBe('1.10.0-beta1');
|
expect(im.makeSemver('1.10beta1')).toBe('1.10.0-beta.1');
|
||||||
expect(im.makeSemver('1.10rc1')).toBe('1.10.0-rc1');
|
expect(im.makeSemver('1.10rc1')).toBe('1.10.0-rc.1');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('converts dot zero versions', async () => {
|
it('converts dot zero versions', async () => {
|
||||||
|
@ -603,12 +636,12 @@ describe('setup-go', () => {
|
||||||
const toolPath = path.normalize('/cache/go/1.16.1/x64');
|
const toolPath = path.normalize('/cache/go/1.16.1/x64');
|
||||||
findSpy.mockReturnValue(toolPath);
|
findSpy.mockReturnValue(toolPath);
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
expect(logSpy).toHaveBeenCalledWith('Setup go stable version spec 1.16');
|
expect(logSpy).toHaveBeenCalledWith('Setup go version spec 1.16');
|
||||||
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -625,7 +658,7 @@ describe('setup-go', () => {
|
||||||
findSpy.mockImplementation(() => '');
|
findSpy.mockImplementation(() => '');
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
const toolPath = path.normalize('/cache/go/1.17.5/x64');
|
const toolPath = path.normalize('/cache/go/1.17.5/x64');
|
||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
const expectedUrl =
|
const expectedUrl =
|
||||||
'https://github.com/actions/go-versions/releases/download/1.17.6-1668090892/go-1.17.6-darwin-x64.tar.gz';
|
'https://github.com/actions/go-versions/releases/download/1.17.6-1668090892/go-1.17.6-darwin-x64.tar.gz';
|
||||||
|
@ -633,7 +666,7 @@ describe('setup-go', () => {
|
||||||
await main.run();
|
await main.run();
|
||||||
|
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
`Setup go stable version spec ${versionSpec}`
|
`Setup go version spec ${versionSpec}`
|
||||||
);
|
);
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
'Attempting to resolve the latest version from the manifest...'
|
'Attempting to resolve the latest version from the manifest...'
|
||||||
|
@ -666,7 +699,7 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
let toolPath = path.normalize('/cache/go/1.13.7/x64');
|
let toolPath = path.normalize('/cache/go/1.13.7/x64');
|
||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
@ -674,7 +707,7 @@ describe('setup-go', () => {
|
||||||
let expPath = path.join(toolPath, 'bin');
|
let expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
expect(dlSpy).toHaveBeenCalled();
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
expect(exSpy).toHaveBeenCalled();
|
expect(extractTarSpy).toHaveBeenCalled();
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
'Attempting to resolve the latest version from the manifest...'
|
'Attempting to resolve the latest version from the manifest...'
|
||||||
);
|
);
|
||||||
|
@ -708,7 +741,7 @@ describe('setup-go', () => {
|
||||||
|
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
let toolPath = path.normalize('/cache/go/1.13.7/x64');
|
let toolPath = path.normalize('/cache/go/1.13.7/x64');
|
||||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
cacheSpy.mockImplementation(async () => toolPath);
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
await main.run();
|
await main.run();
|
||||||
|
@ -719,7 +752,7 @@ describe('setup-go', () => {
|
||||||
`Failed to resolve version ${versionSpec} from manifest`
|
`Failed to resolve version ${versionSpec} from manifest`
|
||||||
);
|
);
|
||||||
expect(dlSpy).toHaveBeenCalled();
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
expect(exSpy).toHaveBeenCalled();
|
expect(extractTarSpy).toHaveBeenCalled();
|
||||||
expect(logSpy).toHaveBeenCalledWith(
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
'Attempting to resolve the latest version from the manifest...'
|
'Attempting to resolve the latest version from the manifest...'
|
||||||
);
|
);
|
||||||
|
|
10
action.yml
10
action.yml
|
@ -7,22 +7,16 @@ inputs:
|
||||||
check-latest:
|
check-latest:
|
||||||
description: 'Set this option to true if you want the action to always check for the latest available version that satisfies the version spec'
|
description: 'Set this option to true if you want the action to always check for the latest available version that satisfies the version spec'
|
||||||
default: false
|
default: false
|
||||||
stable:
|
|
||||||
description: 'Whether to download only stable versions'
|
|
||||||
default: 'true'
|
|
||||||
token:
|
token:
|
||||||
description: Used to pull node distributions from go-versions. Since there's a default, this is typically not supplied by the user.
|
description: Used to pull node distributions from go-versions. Since there's a default, this is typically not supplied by the user.
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
cache:
|
cache:
|
||||||
description: Used to specify whether go-modules caching is needed. Set to true, if you'd like to enable caching.
|
description: Used to specify whether go-modules caching is needed. Set to true, if you'd like to enable caching.
|
||||||
default: false
|
|
||||||
package-manager:
|
|
||||||
description: 'Used to specify non-default package manager'
|
|
||||||
default: 'default'
|
|
||||||
cache-dependency-path:
|
cache-dependency-path:
|
||||||
description: 'Used to specify the path to a dependency file: go.sum'
|
description: 'Used to specify the path to a dependency file: go.sum'
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node16'
|
||||||
main: 'dist/setup/index.js'
|
main: 'dist/setup/index.js'
|
||||||
post: 'dist/cache-save/index.js'
|
post: 'dist/cache-save/index.js'
|
||||||
post-if: success()
|
post-if: success()
|
||||||
|
|
||||||
|
|
10
dist/cache-save/index.js
vendored
10
dist/cache-save/index.js
vendored
|
@ -3944,7 +3944,8 @@ exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, vo
|
||||||
if (!package_managers_1.supportedPackageManagers[packageManager]) {
|
if (!package_managers_1.supportedPackageManagers[packageManager]) {
|
||||||
throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`);
|
throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`);
|
||||||
}
|
}
|
||||||
return package_managers_1.supportedPackageManagers[packageManager];
|
const obtainedPackageManager = package_managers_1.supportedPackageManagers[packageManager];
|
||||||
|
return obtainedPackageManager;
|
||||||
});
|
});
|
||||||
exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const stdout = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand);
|
const stdout = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand);
|
||||||
|
@ -46368,10 +46369,11 @@ function run() {
|
||||||
}
|
}
|
||||||
exports.run = run;
|
exports.run = run;
|
||||||
const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () {
|
const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const cachingFlag = core.getBooleanInput('cache');
|
const cacheInput = core.getInput('cache');
|
||||||
if (!cachingFlag)
|
if (!cacheInput) {
|
||||||
return;
|
return;
|
||||||
const packageManager = core.getInput('package-manager');
|
}
|
||||||
|
const packageManager = cacheInput.toUpperCase() === 'TRUE' ? 'default' : cacheInput;
|
||||||
const state = core.getState(constants_1.State.CacheMatchedKey);
|
const state = core.getState(constants_1.State.CacheMatchedKey);
|
||||||
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
|
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
|
||||||
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
|
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
|
||||||
|
|
63
dist/setup/index.js
vendored
63
dist/setup/index.js
vendored
|
@ -3702,16 +3702,13 @@ function run() {
|
||||||
// If not supplied then problem matchers will still be setup. Useful for self-hosted.
|
// If not supplied then problem matchers will still be setup. Useful for self-hosted.
|
||||||
//
|
//
|
||||||
let versionSpec = core.getInput('go-version');
|
let versionSpec = core.getInput('go-version');
|
||||||
// stable will be true unless false is the exact input
|
const cache = core.getInput('cache');
|
||||||
// since getting unstable versions should be explicit
|
core.info(`Setup go version spec ${versionSpec}`);
|
||||||
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
|
||||||
const cache = core.getBooleanInput('cache');
|
|
||||||
core.info(`Setup go ${stable ? 'stable' : ''} version spec ${versionSpec}`);
|
|
||||||
if (versionSpec) {
|
if (versionSpec) {
|
||||||
let token = core.getInput('token');
|
let token = core.getInput('token');
|
||||||
let auth = !token || isGhes() ? undefined : `token ${token}`;
|
let auth = !token || isGhes() ? undefined : `token ${token}`;
|
||||||
const checkLatest = core.getBooleanInput('check-latest');
|
const checkLatest = core.getBooleanInput('check-latest');
|
||||||
const installDir = yield installer.getGo(versionSpec, stable, checkLatest, auth);
|
const installDir = yield installer.getGo(versionSpec, checkLatest, auth);
|
||||||
core.exportVariable('GOROOT', installDir);
|
core.exportVariable('GOROOT', installDir);
|
||||||
core.addPath(path_1.default.join(installDir, 'bin'));
|
core.addPath(path_1.default.join(installDir, 'bin'));
|
||||||
core.info('Added go to the path');
|
core.info('Added go to the path');
|
||||||
|
@ -3723,7 +3720,7 @@ function run() {
|
||||||
if (isGhes()) {
|
if (isGhes()) {
|
||||||
throw new Error('Caching is not supported on GHES');
|
throw new Error('Caching is not supported on GHES');
|
||||||
}
|
}
|
||||||
const packageManager = core.getInput('package-manager');
|
const packageManager = cache.toUpperCase() === 'TRUE' ? 'default' : cache;
|
||||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||||
yield cache_restore_1.restoreCache(packageManager, cacheDependencyPath);
|
yield cache_restore_1.restoreCache(packageManager, cacheDependencyPath);
|
||||||
}
|
}
|
||||||
|
@ -4188,7 +4185,8 @@ exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, vo
|
||||||
if (!package_managers_1.supportedPackageManagers[packageManager]) {
|
if (!package_managers_1.supportedPackageManagers[packageManager]) {
|
||||||
throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`);
|
throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`);
|
||||||
}
|
}
|
||||||
return package_managers_1.supportedPackageManagers[packageManager];
|
const obtainedPackageManager = package_managers_1.supportedPackageManagers[packageManager];
|
||||||
|
return obtainedPackageManager;
|
||||||
});
|
});
|
||||||
exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const stdout = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand);
|
const stdout = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand);
|
||||||
|
@ -52460,7 +52458,7 @@ __exportStar(__webpack_require__(764), exports);
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getArch = exports.getPlatform = void 0;
|
exports.getArch = exports.getPlatform = void 0;
|
||||||
let os = __webpack_require__(87);
|
const os = __webpack_require__(87);
|
||||||
function getPlatform() {
|
function getPlatform() {
|
||||||
// darwin and linux match already
|
// darwin and linux match already
|
||||||
// freebsd not supported yet but future proofed.
|
// freebsd not supported yet but future proofed.
|
||||||
|
@ -52632,13 +52630,13 @@ const semver = __importStar(__webpack_require__(280));
|
||||||
const httpm = __importStar(__webpack_require__(539));
|
const httpm = __importStar(__webpack_require__(539));
|
||||||
const sys = __importStar(__webpack_require__(913));
|
const sys = __importStar(__webpack_require__(913));
|
||||||
const os_1 = __importDefault(__webpack_require__(87));
|
const os_1 = __importDefault(__webpack_require__(87));
|
||||||
function getGo(versionSpec, stable, checkLatest, auth) {
|
function getGo(versionSpec, checkLatest, auth) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let osPlat = os_1.default.platform();
|
let osPlat = os_1.default.platform();
|
||||||
let osArch = os_1.default.arch();
|
let osArch = os_1.default.arch();
|
||||||
if (checkLatest) {
|
if (checkLatest) {
|
||||||
core.info('Attempting to resolve the latest version from the manifest...');
|
core.info('Attempting to resolve the latest version from the manifest...');
|
||||||
const resolvedVersion = yield resolveVersionFromManifest(versionSpec, stable, auth);
|
const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth);
|
||||||
if (resolvedVersion) {
|
if (resolvedVersion) {
|
||||||
versionSpec = resolvedVersion;
|
versionSpec = resolvedVersion;
|
||||||
core.info(`Resolved as '${versionSpec}'`);
|
core.info(`Resolved as '${versionSpec}'`);
|
||||||
|
@ -52662,7 +52660,7 @@ function getGo(versionSpec, stable, checkLatest, auth) {
|
||||||
// Try download from internal distribution (popular versions only)
|
// Try download from internal distribution (popular versions only)
|
||||||
//
|
//
|
||||||
try {
|
try {
|
||||||
info = yield getInfoFromManifest(versionSpec, stable, auth);
|
info = yield getInfoFromManifest(versionSpec, true, auth);
|
||||||
if (info) {
|
if (info) {
|
||||||
downloadPath = yield installGoVersion(info, auth);
|
downloadPath = yield installGoVersion(info, auth);
|
||||||
}
|
}
|
||||||
|
@ -52685,7 +52683,7 @@ function getGo(versionSpec, stable, checkLatest, auth) {
|
||||||
// Download from storage.googleapis.com
|
// Download from storage.googleapis.com
|
||||||
//
|
//
|
||||||
if (!downloadPath) {
|
if (!downloadPath) {
|
||||||
info = yield getInfoFromDist(versionSpec, stable);
|
info = yield getInfoFromDist(versionSpec);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
|
throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
|
||||||
}
|
}
|
||||||
|
@ -52760,10 +52758,10 @@ function getInfoFromManifest(versionSpec, stable, auth) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getInfoFromManifest = getInfoFromManifest;
|
exports.getInfoFromManifest = getInfoFromManifest;
|
||||||
function getInfoFromDist(versionSpec, stable) {
|
function getInfoFromDist(versionSpec) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let version;
|
let version;
|
||||||
version = yield findMatch(versionSpec, stable);
|
version = yield findMatch(versionSpec);
|
||||||
if (!version) {
|
if (!version) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -52776,7 +52774,7 @@ function getInfoFromDist(versionSpec, stable) {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function findMatch(versionSpec, stable) {
|
function findMatch(versionSpec) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let archFilter = sys.getArch();
|
let archFilter = sys.getArch();
|
||||||
let platFilter = sys.getPlatform();
|
let platFilter = sys.getPlatform();
|
||||||
|
@ -52791,15 +52789,8 @@ function findMatch(versionSpec, stable) {
|
||||||
for (let i = 0; i < candidates.length; i++) {
|
for (let i = 0; i < candidates.length; i++) {
|
||||||
let candidate = candidates[i];
|
let candidate = candidates[i];
|
||||||
let version = makeSemver(candidate.version);
|
let version = makeSemver(candidate.version);
|
||||||
// 1.13.0 is advertised as 1.13 preventing being able to match exactly 1.13.0
|
|
||||||
// since a semver of 1.13 would match latest 1.13
|
|
||||||
let parts = version.split('.');
|
|
||||||
if (parts.length == 2) {
|
|
||||||
version = version + '.0';
|
|
||||||
}
|
|
||||||
core.debug(`check ${version} satisfies ${versionSpec}`);
|
core.debug(`check ${version} satisfies ${versionSpec}`);
|
||||||
if (semver.satisfies(version, versionSpec) &&
|
if (semver.satisfies(version, versionSpec)) {
|
||||||
(!stable || candidate.stable === stable)) {
|
|
||||||
goFile = candidate.files.find(file => {
|
goFile = candidate.files.find(file => {
|
||||||
core.debug(`${file.arch}===${archFilter} && ${file.os}===${platFilter}`);
|
core.debug(`${file.arch}===${archFilter} && ${file.os}===${platFilter}`);
|
||||||
return file.arch === archFilter && file.os === platFilter;
|
return file.arch === archFilter && file.os === platFilter;
|
||||||
|
@ -52835,19 +52826,25 @@ exports.getVersionsDist = getVersionsDist;
|
||||||
// Convert the go version syntax into semver for semver matching
|
// Convert the go version syntax into semver for semver matching
|
||||||
// 1.13.1 => 1.13.1
|
// 1.13.1 => 1.13.1
|
||||||
// 1.13 => 1.13.0
|
// 1.13 => 1.13.0
|
||||||
// 1.10beta1 => 1.10.0-beta1, 1.10rc1 => 1.10.0-rc1
|
// 1.10beta1 => 1.10.0-beta.1, 1.10rc1 => 1.10.0-rc.1
|
||||||
// 1.8.5beta1 => 1.8.5-beta1, 1.8.5rc1 => 1.8.5-rc1
|
// 1.8.5beta1 => 1.8.5-beta.1, 1.8.5rc1 => 1.8.5-rc.1
|
||||||
function makeSemver(version) {
|
function makeSemver(version) {
|
||||||
|
var _a;
|
||||||
version = version.replace('go', '');
|
version = version.replace('go', '');
|
||||||
version = version.replace('beta', '-beta').replace('rc', '-rc');
|
version = version.replace('beta', '-beta.').replace('rc', '-rc.');
|
||||||
let parts = version.split('-');
|
let parts = version.split('-');
|
||||||
let verPart = parts[0];
|
let semVersion = (_a = semver.coerce(parts[0])) === null || _a === void 0 ? void 0 : _a.version;
|
||||||
let prereleasePart = parts.length > 1 ? `-${parts[1]}` : '';
|
if (!semVersion) {
|
||||||
let verParts = verPart.split('.');
|
throw new Error(`The version: ${version} can't be changed to SemVer notation`);
|
||||||
if (verParts.length == 2) {
|
|
||||||
verPart += '.0';
|
|
||||||
}
|
}
|
||||||
return `${verPart}${prereleasePart}`;
|
if (!parts[1]) {
|
||||||
|
return semVersion;
|
||||||
|
}
|
||||||
|
const fullVersion = semver.valid(`${semVersion}-${parts[1]}`);
|
||||||
|
if (!fullVersion) {
|
||||||
|
throw new Error(`The version: ${version} can't be changed to SemVer notation`);
|
||||||
|
}
|
||||||
|
return fullVersion;
|
||||||
}
|
}
|
||||||
exports.makeSemver = makeSemver;
|
exports.makeSemver = makeSemver;
|
||||||
|
|
||||||
|
|
312
package-lock.json
generated
312
package-lock.json
generated
|
@ -20,7 +20,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^27.0.2",
|
"@types/jest": "^27.0.2",
|
||||||
"@types/node": "^12.0.4",
|
"@types/node": "^16.11.25",
|
||||||
"@types/semver": "^6.0.0",
|
"@types/semver": "^6.0.0",
|
||||||
"@zeit/ncc": "^0.21.0",
|
"@zeit/ncc": "^0.21.0",
|
||||||
"jest": "^27.2.5",
|
"jest": "^27.2.5",
|
||||||
|
@ -1303,9 +1303,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "12.12.47",
|
"version": "16.11.25",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.47.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.25.tgz",
|
||||||
"integrity": "sha512-yzBInQFhdY8kaZmqoL2+3U5dSTMrKaYcb561VU+lDzAYvqt+2lojvBEy+hmpSNuXnPTx7m9+04CzWYOUqWME2A=="
|
"integrity": "sha512-NrTwfD7L1RTc2qrHQD4RTTy4p0CO2LatKBEKEds3CaVuhoM/+DJzmWZl5f+ikR8cm8F5mfJxK+9rQq07gRiSjQ=="
|
||||||
},
|
},
|
||||||
"node_modules/@types/node-fetch": {
|
"node_modules/@types/node-fetch": {
|
||||||
"version": "2.6.1",
|
"version": "2.6.1",
|
||||||
|
@ -3647,9 +3647,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/minimist": {
|
"node_modules/minimist": {
|
||||||
"version": "1.2.5",
|
"version": "1.2.6",
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
|
||||||
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
|
"integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/mkdirp": {
|
"node_modules/mkdirp": {
|
||||||
|
@ -4554,145 +4554,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ts-jest/node_modules/@jest/types": {
|
|
||||||
"version": "27.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@jest/types/-/types-27.1.0.tgz",
|
|
||||||
"integrity": "sha512-pRP5cLIzN7I7Vp6mHKRSaZD7YpBTK7hawx5si8trMKqk4+WOdK8NEKOTO2G8PKWD1HbKMVckVB6/XHh/olhf2g==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@types/istanbul-lib-coverage": "^2.0.0",
|
|
||||||
"@types/istanbul-reports": "^3.0.0",
|
|
||||||
"@types/node": "*",
|
|
||||||
"@types/yargs": "^16.0.0",
|
|
||||||
"chalk": "^4.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ts-jest/node_modules/@types/istanbul-reports": {
|
|
||||||
"version": "3.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz",
|
|
||||||
"integrity": "sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@types/istanbul-lib-report": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ts-jest/node_modules/@types/yargs": {
|
|
||||||
"version": "16.0.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.4.tgz",
|
|
||||||
"integrity": "sha512-T8Yc9wt/5LbJyCaLiHPReJa0kApcIgJ7Bn735GjItUfh08Z1pJvu8QZqb9s+mMvKV6WUQRV7K2R46YbjMXTTJw==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@types/yargs-parser": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ts-jest/node_modules/ansi-styles": {
|
|
||||||
"version": "4.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
|
||||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"color-convert": "^2.0.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ts-jest/node_modules/chalk": {
|
|
||||||
"version": "4.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
|
||||||
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"ansi-styles": "^4.1.0",
|
|
||||||
"supports-color": "^7.1.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ts-jest/node_modules/ci-info": {
|
|
||||||
"version": "3.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.2.0.tgz",
|
|
||||||
"integrity": "sha512-dVqRX7fLUm8J6FgHJ418XuIgDLZDkYcDFTeL6TA2gt5WlIZUQrrH6EZrNClwT/H0FateUsZkGIOPRrLbP+PR9A==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/ts-jest/node_modules/color-convert": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"color-name": "~1.1.4"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=7.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ts-jest/node_modules/color-name": {
|
|
||||||
"version": "1.1.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
|
||||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/ts-jest/node_modules/has-flag": {
|
|
||||||
"version": "4.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
|
||||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ts-jest/node_modules/is-ci": {
|
|
||||||
"version": "3.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-ci/-/is-ci-3.0.0.tgz",
|
|
||||||
"integrity": "sha512-kDXyttuLeslKAHYL/K28F2YkM3x5jvFPEw3yXbRptXydjD9rpLEz+C5K5iutY9ZiUu6AP41JdvRQwF4Iqs4ZCQ==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"ci-info": "^3.1.1"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"is-ci": "bin.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ts-jest/node_modules/jest-util": {
|
|
||||||
"version": "27.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/jest-util/-/jest-util-27.1.0.tgz",
|
|
||||||
"integrity": "sha512-edSLD2OneYDKC6gZM1yc+wY/877s/fuJNoM1k3sOEpzFyeptSmke3SLnk1dDHk9CgTA+58mnfx3ew3J11Kes/w==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@jest/types": "^27.1.0",
|
|
||||||
"@types/node": "*",
|
|
||||||
"chalk": "^4.0.0",
|
|
||||||
"graceful-fs": "^4.2.4",
|
|
||||||
"is-ci": "^3.0.0",
|
|
||||||
"picomatch": "^2.2.3"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ts-jest/node_modules/picomatch": {
|
|
||||||
"version": "2.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz",
|
|
||||||
"integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==",
|
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8.6"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/jonschlinkert"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ts-jest/node_modules/semver": {
|
"node_modules/ts-jest/node_modules/semver": {
|
||||||
"version": "7.3.5",
|
"version": "7.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
|
||||||
|
@ -4708,32 +4569,6 @@
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ts-jest/node_modules/supports-color": {
|
|
||||||
"version": "7.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
|
||||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"has-flag": "^4.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ts-jest/node_modules/yargs-parser": {
|
|
||||||
"version": "20.2.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz",
|
|
||||||
"integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==",
|
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/tslib": {
|
|
||||||
"version": "1.14.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
|
||||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
|
|
||||||
},
|
|
||||||
"node_modules/tunnel": {
|
"node_modules/tunnel": {
|
||||||
"version": "0.0.6",
|
"version": "0.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
||||||
|
@ -6111,9 +5946,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "12.12.47",
|
"version": "16.11.25",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.47.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.25.tgz",
|
||||||
"integrity": "sha512-yzBInQFhdY8kaZmqoL2+3U5dSTMrKaYcb561VU+lDzAYvqt+2lojvBEy+hmpSNuXnPTx7m9+04CzWYOUqWME2A=="
|
"integrity": "sha512-NrTwfD7L1RTc2qrHQD4RTTy4p0CO2LatKBEKEds3CaVuhoM/+DJzmWZl5f+ikR8cm8F5mfJxK+9rQq07gRiSjQ=="
|
||||||
},
|
},
|
||||||
"@types/node-fetch": {
|
"@types/node-fetch": {
|
||||||
"version": "2.6.1",
|
"version": "2.6.1",
|
||||||
|
@ -7895,9 +7730,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "1.2.5",
|
"version": "1.2.6",
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
|
||||||
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
|
"integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"mkdirp": {
|
"mkdirp": {
|
||||||
|
@ -8568,112 +8403,6 @@
|
||||||
"yargs-parser": "20.x"
|
"yargs-parser": "20.x"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jest/types": {
|
|
||||||
"version": "27.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@jest/types/-/types-27.1.0.tgz",
|
|
||||||
"integrity": "sha512-pRP5cLIzN7I7Vp6mHKRSaZD7YpBTK7hawx5si8trMKqk4+WOdK8NEKOTO2G8PKWD1HbKMVckVB6/XHh/olhf2g==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"@types/istanbul-lib-coverage": "^2.0.0",
|
|
||||||
"@types/istanbul-reports": "^3.0.0",
|
|
||||||
"@types/node": "*",
|
|
||||||
"@types/yargs": "^16.0.0",
|
|
||||||
"chalk": "^4.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@types/istanbul-reports": {
|
|
||||||
"version": "3.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz",
|
|
||||||
"integrity": "sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"@types/istanbul-lib-report": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@types/yargs": {
|
|
||||||
"version": "16.0.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.4.tgz",
|
|
||||||
"integrity": "sha512-T8Yc9wt/5LbJyCaLiHPReJa0kApcIgJ7Bn735GjItUfh08Z1pJvu8QZqb9s+mMvKV6WUQRV7K2R46YbjMXTTJw==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"@types/yargs-parser": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ansi-styles": {
|
|
||||||
"version": "4.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
|
||||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"color-convert": "^2.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"chalk": {
|
|
||||||
"version": "4.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
|
||||||
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"ansi-styles": "^4.1.0",
|
|
||||||
"supports-color": "^7.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ci-info": {
|
|
||||||
"version": "3.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.2.0.tgz",
|
|
||||||
"integrity": "sha512-dVqRX7fLUm8J6FgHJ418XuIgDLZDkYcDFTeL6TA2gt5WlIZUQrrH6EZrNClwT/H0FateUsZkGIOPRrLbP+PR9A==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"color-convert": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"color-name": "~1.1.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"color-name": {
|
|
||||||
"version": "1.1.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
|
||||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"has-flag": {
|
|
||||||
"version": "4.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
|
||||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"is-ci": {
|
|
||||||
"version": "3.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-ci/-/is-ci-3.0.0.tgz",
|
|
||||||
"integrity": "sha512-kDXyttuLeslKAHYL/K28F2YkM3x5jvFPEw3yXbRptXydjD9rpLEz+C5K5iutY9ZiUu6AP41JdvRQwF4Iqs4ZCQ==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"ci-info": "^3.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"jest-util": {
|
|
||||||
"version": "27.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/jest-util/-/jest-util-27.1.0.tgz",
|
|
||||||
"integrity": "sha512-edSLD2OneYDKC6gZM1yc+wY/877s/fuJNoM1k3sOEpzFyeptSmke3SLnk1dDHk9CgTA+58mnfx3ew3J11Kes/w==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"@jest/types": "^27.1.0",
|
|
||||||
"@types/node": "*",
|
|
||||||
"chalk": "^4.0.0",
|
|
||||||
"graceful-fs": "^4.2.4",
|
|
||||||
"is-ci": "^3.0.0",
|
|
||||||
"picomatch": "^2.2.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"picomatch": {
|
|
||||||
"version": "2.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz",
|
|
||||||
"integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"semver": {
|
"semver": {
|
||||||
"version": "7.3.5",
|
"version": "7.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
|
||||||
|
@ -8682,21 +8411,6 @@
|
||||||
"requires": {
|
"requires": {
|
||||||
"lru-cache": "^6.0.0"
|
"lru-cache": "^6.0.0"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"supports-color": {
|
|
||||||
"version": "7.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
|
||||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"has-flag": "^4.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"yargs-parser": {
|
|
||||||
"version": "20.2.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz",
|
|
||||||
"integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==",
|
|
||||||
"dev": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^27.0.2",
|
"@types/jest": "^27.0.2",
|
||||||
"@types/node": "^12.0.4",
|
"@types/node": "^16.11.25",
|
||||||
"@types/semver": "^6.0.0",
|
"@types/semver": "^6.0.0",
|
||||||
"@zeit/ncc": "^0.21.0",
|
"@zeit/ncc": "^0.21.0",
|
||||||
"jest": "^27.2.5",
|
"jest": "^27.2.5",
|
||||||
|
|
|
@ -21,10 +21,13 @@ export async function run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const cachePackages = async () => {
|
const cachePackages = async () => {
|
||||||
const cachingFlag = core.getBooleanInput('cache');
|
const cacheInput = core.getInput('cache');
|
||||||
if (!cachingFlag) return;
|
if (!cacheInput) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const packageManager = core.getInput('package-manager');
|
const packageManager =
|
||||||
|
cacheInput.toUpperCase() === 'TRUE' ? 'default' : cacheInput;
|
||||||
|
|
||||||
const state = core.getState(State.CacheMatchedKey);
|
const state = core.getState(State.CacheMatchedKey);
|
||||||
const primaryKey = core.getState(State.CachePrimaryKey);
|
const primaryKey = core.getState(State.CachePrimaryKey);
|
||||||
|
|
|
@ -25,8 +25,9 @@ export const getPackageManagerInfo = async (packageManager: string) => {
|
||||||
`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`
|
`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const obtainedPackageManager = supportedPackageManagers[packageManager];
|
||||||
|
|
||||||
return supportedPackageManagers[packageManager];
|
return obtainedPackageManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getCacheDirectoryPath = async (
|
export const getCacheDirectoryPath = async (
|
||||||
|
|
|
@ -30,7 +30,6 @@ export interface IGoVersionInfo {
|
||||||
|
|
||||||
export async function getGo(
|
export async function getGo(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
stable: boolean,
|
|
||||||
checkLatest: boolean,
|
checkLatest: boolean,
|
||||||
auth: string | undefined
|
auth: string | undefined
|
||||||
) {
|
) {
|
||||||
|
@ -41,7 +40,7 @@ export async function getGo(
|
||||||
core.info('Attempting to resolve the latest version from the manifest...');
|
core.info('Attempting to resolve the latest version from the manifest...');
|
||||||
const resolvedVersion = await resolveVersionFromManifest(
|
const resolvedVersion = await resolveVersionFromManifest(
|
||||||
versionSpec,
|
versionSpec,
|
||||||
stable,
|
true,
|
||||||
auth
|
auth
|
||||||
);
|
);
|
||||||
if (resolvedVersion) {
|
if (resolvedVersion) {
|
||||||
|
@ -68,7 +67,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, stable, auth);
|
info = await getInfoFromManifest(versionSpec, true, auth);
|
||||||
if (info) {
|
if (info) {
|
||||||
downloadPath = await installGoVersion(info, auth);
|
downloadPath = await installGoVersion(info, auth);
|
||||||
} else {
|
} else {
|
||||||
|
@ -95,7 +94,7 @@ export async function getGo(
|
||||||
// Download from storage.googleapis.com
|
// Download from storage.googleapis.com
|
||||||
//
|
//
|
||||||
if (!downloadPath) {
|
if (!downloadPath) {
|
||||||
info = await getInfoFromDist(versionSpec, stable);
|
info = await getInfoFromDist(versionSpec);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`
|
`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`
|
||||||
|
@ -191,11 +190,10 @@ export async function getInfoFromManifest(
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getInfoFromDist(
|
async function getInfoFromDist(
|
||||||
versionSpec: string,
|
versionSpec: string
|
||||||
stable: boolean
|
|
||||||
): Promise<IGoVersionInfo | null> {
|
): Promise<IGoVersionInfo | null> {
|
||||||
let version: IGoVersion | undefined;
|
let version: IGoVersion | undefined;
|
||||||
version = await findMatch(versionSpec, stable);
|
version = await findMatch(versionSpec);
|
||||||
if (!version) {
|
if (!version) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -211,8 +209,7 @@ async function getInfoFromDist(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function findMatch(
|
export async function findMatch(
|
||||||
versionSpec: string,
|
versionSpec: string
|
||||||
stable: boolean
|
|
||||||
): Promise<IGoVersion | undefined> {
|
): Promise<IGoVersion | undefined> {
|
||||||
let archFilter = sys.getArch();
|
let archFilter = sys.getArch();
|
||||||
let platFilter = sys.getPlatform();
|
let platFilter = sys.getPlatform();
|
||||||
|
@ -233,18 +230,8 @@ export async function findMatch(
|
||||||
let candidate: IGoVersion = candidates[i];
|
let candidate: IGoVersion = candidates[i];
|
||||||
let version = makeSemver(candidate.version);
|
let version = makeSemver(candidate.version);
|
||||||
|
|
||||||
// 1.13.0 is advertised as 1.13 preventing being able to match exactly 1.13.0
|
|
||||||
// since a semver of 1.13 would match latest 1.13
|
|
||||||
let parts: string[] = version.split('.');
|
|
||||||
if (parts.length == 2) {
|
|
||||||
version = version + '.0';
|
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(`check ${version} satisfies ${versionSpec}`);
|
core.debug(`check ${version} satisfies ${versionSpec}`);
|
||||||
if (
|
if (semver.satisfies(version, versionSpec)) {
|
||||||
semver.satisfies(version, versionSpec) &&
|
|
||||||
(!stable || candidate.stable === stable)
|
|
||||||
) {
|
|
||||||
goFile = candidate.files.find(file => {
|
goFile = candidate.files.find(file => {
|
||||||
core.debug(
|
core.debug(
|
||||||
`${file.arch}===${archFilter} && ${file.os}===${platFilter}`
|
`${file.arch}===${archFilter} && ${file.os}===${platFilter}`
|
||||||
|
@ -284,20 +271,30 @@ export async function getVersionsDist(
|
||||||
// Convert the go version syntax into semver for semver matching
|
// Convert the go version syntax into semver for semver matching
|
||||||
// 1.13.1 => 1.13.1
|
// 1.13.1 => 1.13.1
|
||||||
// 1.13 => 1.13.0
|
// 1.13 => 1.13.0
|
||||||
// 1.10beta1 => 1.10.0-beta1, 1.10rc1 => 1.10.0-rc1
|
// 1.10beta1 => 1.10.0-beta.1, 1.10rc1 => 1.10.0-rc.1
|
||||||
// 1.8.5beta1 => 1.8.5-beta1, 1.8.5rc1 => 1.8.5-rc1
|
// 1.8.5beta1 => 1.8.5-beta.1, 1.8.5rc1 => 1.8.5-rc.1
|
||||||
export function makeSemver(version: string): string {
|
export function makeSemver(version: string): string {
|
||||||
version = version.replace('go', '');
|
version = version.replace('go', '');
|
||||||
version = version.replace('beta', '-beta').replace('rc', '-rc');
|
version = version.replace('beta', '-beta.').replace('rc', '-rc.');
|
||||||
let parts = version.split('-');
|
let parts = version.split('-');
|
||||||
|
|
||||||
let verPart: string = parts[0];
|
let semVersion = semver.coerce(parts[0])?.version;
|
||||||
let prereleasePart = parts.length > 1 ? `-${parts[1]}` : '';
|
if (!semVersion) {
|
||||||
|
throw new Error(
|
||||||
let verParts: string[] = verPart.split('.');
|
`The version: ${version} can't be changed to SemVer notation`
|
||||||
if (verParts.length == 2) {
|
);
|
||||||
verPart += '.0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${verPart}${prereleasePart}`;
|
if (!parts[1]) {
|
||||||
|
return semVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fullVersion = semver.valid(`${semVersion}-${parts[1]}`);
|
||||||
|
|
||||||
|
if (!fullVersion) {
|
||||||
|
throw new Error(
|
||||||
|
`The version: ${version} can't be changed to SemVer notation`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return fullVersion;
|
||||||
}
|
}
|
||||||
|
|
30
src/main.ts
30
src/main.ts
|
@ -1,6 +1,7 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import * as installer from './installer';
|
import * as installer from './installer';
|
||||||
|
import * as semver from 'semver';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {restoreCache} from './cache-restore';
|
import {restoreCache} from './cache-restore';
|
||||||
import cp from 'child_process';
|
import cp from 'child_process';
|
||||||
|
@ -15,29 +16,26 @@ export async function run() {
|
||||||
//
|
//
|
||||||
let versionSpec = core.getInput('go-version');
|
let versionSpec = core.getInput('go-version');
|
||||||
|
|
||||||
// stable will be true unless false is the exact input
|
const cache = core.getInput('cache');
|
||||||
// since getting unstable versions should be explicit
|
core.info(`Setup go version spec ${versionSpec}`);
|
||||||
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
|
||||||
const cache = core.getBooleanInput('cache');
|
|
||||||
|
|
||||||
core.info(`Setup go ${stable ? 'stable' : ''} version spec ${versionSpec}`);
|
|
||||||
|
|
||||||
if (versionSpec) {
|
if (versionSpec) {
|
||||||
let token = core.getInput('token');
|
let token = core.getInput('token');
|
||||||
let auth = !token || isGhes() ? undefined : `token ${token}`;
|
let auth = !token || isGhes() ? undefined : `token ${token}`;
|
||||||
|
|
||||||
const checkLatest = core.getBooleanInput('check-latest');
|
const checkLatest = core.getBooleanInput('check-latest');
|
||||||
const installDir = await installer.getGo(
|
const installDir = await installer.getGo(versionSpec, checkLatest, auth);
|
||||||
versionSpec,
|
|
||||||
stable,
|
|
||||||
checkLatest,
|
|
||||||
auth
|
|
||||||
);
|
|
||||||
|
|
||||||
core.exportVariable('GOROOT', installDir);
|
|
||||||
core.addPath(path.join(installDir, 'bin'));
|
core.addPath(path.join(installDir, 'bin'));
|
||||||
core.info('Added go to the path');
|
core.info('Added go to the path');
|
||||||
|
|
||||||
|
const version = installer.makeSemver(versionSpec);
|
||||||
|
// Go versions less than 1.9 require GOROOT to be set
|
||||||
|
if (semver.lt(version, '1.9.0')) {
|
||||||
|
core.info('Setting GOROOT for Go version < 1.9');
|
||||||
|
core.exportVariable('GOROOT', installDir);
|
||||||
|
}
|
||||||
|
|
||||||
let added = await addBinToPath();
|
let added = await addBinToPath();
|
||||||
core.debug(`add bin ${added}`);
|
core.debug(`add bin ${added}`);
|
||||||
core.info(`Successfully setup go version ${versionSpec}`);
|
core.info(`Successfully setup go version ${versionSpec}`);
|
||||||
|
@ -47,7 +45,7 @@ export async function run() {
|
||||||
if (isGhes()) {
|
if (isGhes()) {
|
||||||
throw new Error('Caching is not supported on GHES');
|
throw new Error('Caching is not supported on GHES');
|
||||||
}
|
}
|
||||||
const packageManager = core.getInput('package-manager');
|
const packageManager = cache.toUpperCase() === 'TRUE' ? 'default' : cache;
|
||||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||||
await restoreCache(packageManager, cacheDependencyPath);
|
await restoreCache(packageManager, cacheDependencyPath);
|
||||||
}
|
}
|
||||||
|
@ -86,13 +84,13 @@ export async function addBinToPath(): Promise<boolean> {
|
||||||
if (!fs.existsSync(gp)) {
|
if (!fs.existsSync(gp)) {
|
||||||
// some of the hosted images have go install but not profile dir
|
// some of the hosted images have go install but not profile dir
|
||||||
core.debug(`creating ${gp}`);
|
core.debug(`creating ${gp}`);
|
||||||
io.mkdirP(gp);
|
await io.mkdirP(gp);
|
||||||
}
|
}
|
||||||
|
|
||||||
let bp = path.join(gp, 'bin');
|
let bp = path.join(gp, 'bin');
|
||||||
if (!fs.existsSync(bp)) {
|
if (!fs.existsSync(bp)) {
|
||||||
core.debug(`creating ${bp}`);
|
core.debug(`creating ${bp}`);
|
||||||
io.mkdirP(bp);
|
await io.mkdirP(bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
core.addPath(bp);
|
core.addPath(bp);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
let os = require('os');
|
const os = require('os');
|
||||||
|
|
||||||
export function getPlatform(): string {
|
export function getPlatform(): string {
|
||||||
// darwin and linux match already
|
// darwin and linux match already
|
||||||
|
|
Loading…
Add table
Reference in a new issue