Skip to content

Commit

Permalink
fix: Use tar.gz file (#148)
Browse files Browse the repository at this point in the history
* fix: Use tar.gz file

* Done build

* fix platform

* build

* Update test
  • Loading branch information
jcs090218 authored Feb 9, 2024
1 parent 04e2fac commit 2bb9d7d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
eask_version: [0.6.43, snapshot]
eask_version: [0.9.4, snapshot]

steps:
- uses: actions/checkout@v4
Expand Down
25 changes: 17 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3269,6 +3269,14 @@ function getPlatform() {
}
return 'linux'; /* Default: linux */
}
function getExt() {
switch (process.platform) {
case 'linux':
case 'darwin': return 'tar.gz';
case 'win32': return 'zip';
}
return 'tar.gz'; /* Default: linux */
}
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
Expand All @@ -3278,7 +3286,8 @@ function run() {
const version = core.getInput("version");
const architecture = core.getInput("architecture");
const platform = getPlatform();
const archiveSuffix = `${platform}-${architecture}.zip`; // win-x64.zip
const ext = getExt();
const archiveSuffix = `${platform}-${architecture}.${ext}`; // win-x64.zip
const archiveName = `eask_${version}_${archiveSuffix}`; // eask_0.7.10_win-x64.zip
core.startGroup("Fetch Eask");
{
Expand All @@ -3293,18 +3302,18 @@ function run() {
`${tmp}/${archiveName}`
]);
fs_1.default.mkdirSync(`${tmp}/eask-${version}`);
yield exec.exec('unzip', [`${tmp}/${archiveName}`, '-d', `${tmp}/eask-${version}`]);
/* Extraction */
{
if (platform === 'win')
yield exec.exec('unzip', [`${tmp}/${archiveName}`, '-d', `${tmp}/eask-${version}`]);
else
yield exec.exec('tar', ['-xvzf', `${tmp}/${archiveName}`, '-C', `${tmp}/eask-${version}`]);
}
const options = { recursive: true, force: false };
yield io.mv(`${tmp}/eask-${version}`, `${home}/eask-${version}`, options);
core.addPath(`${home}/eask-${version}`);
}
core.endGroup();
/* Chmod so let the operating system know it's executable! */
if (platform != 'win') {
core.startGroup("Chmod if necessary");
yield exec.exec(`chmod -R 777 ${home}/eask-${version}`);
core.endGroup();
}
// show Eask version
yield exec.exec('eask', ['--version']);
}
Expand Down
29 changes: 19 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ function getPlatform(): string {
return 'linux'; /* Default: linux */
}

function getExt(): string {
switch (process.platform) {
case 'linux':
case 'darwin': return 'tar.gz';
case 'win32': return 'zip';
}
return 'tar.gz'; /* Default: linux */
}

async function run(): Promise<void> {
try {
const PATH = process.env.PATH;
Expand All @@ -26,8 +35,9 @@ async function run(): Promise<void> {
const architecture = core.getInput("architecture");
const platform = getPlatform();

const archiveSuffix = `${platform}-${architecture}.zip`; // win-x64.zip
const archiveName = `eask_${version}_${archiveSuffix}`; // eask_0.7.10_win-x64.zip
const ext = getExt();
const archiveSuffix = `${platform}-${architecture}.${ext}`; // win-x64.zip
const archiveName = `eask_${version}_${archiveSuffix}`; // eask_0.7.10_win-x64.zip

core.startGroup("Fetch Eask");
{
Expand All @@ -44,20 +54,19 @@ async function run(): Promise<void> {
]);

fs.mkdirSync(`${tmp}/eask-${version}`);
await exec.exec('unzip', [`${tmp}/${archiveName}`, '-d', `${tmp}/eask-${version}`]);
/* Extraction */
{
if (platform === 'win')
await exec.exec('unzip', [`${tmp}/${archiveName}`, '-d', `${tmp}/eask-${version}`]);
else
await exec.exec('tar', ['-xvzf', `${tmp}/${archiveName}`, '-C', `${tmp}/eask-${version}`]);
}
const options = { recursive: true, force: false };
await io.mv(`${tmp}/eask-${version}`, `${home}/eask-${version}`, options);
core.addPath(`${home}/eask-${version}`);
}
core.endGroup();

/* Chmod so let the operating system know it's executable! */
if (platform != 'win') {
core.startGroup("Chmod if necessary");
await exec.exec(`chmod -R 777 ${home}/eask-${version}`);
core.endGroup();
}

// show Eask version
await exec.exec('eask', ['--version']);
} catch (error) {
Expand Down

0 comments on commit 2bb9d7d

Please sign in to comment.