Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix install #258

Merged
merged 1 commit into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions dist/licenses.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/http-client": "^2.0.1",
"@actions/tool-cache": "^2.0.1"
"@actions/tool-cache": "^2.0.1",
"semver": "^7.3.7"
},
"devDependencies": {
"@types/node": "^16.11.26",
Expand Down
15 changes: 8 additions & 7 deletions src/installer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
import * as semver from 'semver';
import * as util from 'util';
import * as github from './github';
import * as core from '@actions/core';
Expand All @@ -19,10 +20,10 @@ export async function getXgo(version: string): Promise<Xgo> {
if (!release) {
throw new Error(`Cannot find xgo ${version} release`);
}
const semver: string = release.tag_name.replace(/^v/, '');
const fullversion: string = release.tag_name.replace(/^v/, '');
core.debug(`Release found: ${release.tag_name}`);

const filename = getFilename(semver);
const filename = getFilename(fullversion);
const downloadUrl: string = util.format('https://github.com/crazy-max/xgo/releases/download/%s/%s', release.tag_name, filename);

core.info(`Downloading ${downloadUrl}`);
Expand All @@ -37,7 +38,7 @@ export async function getXgo(version: string): Promise<Xgo> {
}
core.debug(`Extracted to ${extPath}`);

const cachePath: string = await tc.cacheDir(extPath, 'ghaction-xgo', semver);
const cachePath: string = await tc.cacheDir(extPath, 'ghaction-xgo', fullversion);
core.debug(`Cached to ${cachePath}`);

const exePath: string = path.join(cachePath, osPlat == 'win32' ? 'xgo.exe' : 'xgo');
Expand All @@ -52,7 +53,7 @@ export async function getXgo(version: string): Promise<Xgo> {
};
}

const getFilename = (semver: string): string => {
const getFilename = (version: string): string => {
let platform, arch: string;
switch (osPlat) {
case 'win32': {
Expand All @@ -66,11 +67,11 @@ const getFilename = (semver: string): string => {
}
switch (osArch) {
case 'x64': {
arch = 'x86_64';
arch = semver.satisfies(version, '>=0.24.0') ? 'amd64' : 'x86_64';
break;
}
case 'x32': {
arch = 'i386';
arch = semver.satisfies(version, '>=0.24.0') ? '386' : 'i386';
break;
}
case 'arm': {
Expand All @@ -84,5 +85,5 @@ const getFilename = (semver: string): string => {
}
}
const ext: string = osPlat == 'win32' ? '.zip' : '.tar.gz';
return util.format('xgo_%s_%s_%s%s', semver, platform, arch, ext);
return util.format('xgo_%s_%s_%s%s', version, platform, arch, ext);
};
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3048,6 +3048,13 @@ semver@^6.0.0, semver@^6.1.0, semver@^6.3.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

semver@^7.3.7:
version "7.3.8"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798"
integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==
dependencies:
lru-cache "^6.0.0"

shebang-command@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"
Expand Down