mirror of
https://github.com/DeterminateSystems/nix-installer-action.git
synced 2024-12-23 13:32:06 +01:00
Merge pull request #53 from DeterminateSystems/use-github-tool-cache-and-exec
Use Github Actions provided tool cache and exec
This commit is contained in:
commit
5620eb4af6
6 changed files with 4121 additions and 407 deletions
4184
dist/index.js
vendored
4184
dist/index.js
vendored
File diff suppressed because it is too large
Load diff
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
80
dist/licenses.txt
vendored
80
dist/licenses.txt
vendored
|
@ -10,6 +10,18 @@ The above copyright notice and this permission notice shall be included in all c
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
@actions/exec
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright 2019 GitHub
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
@actions/github
|
@actions/github
|
||||||
MIT
|
MIT
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
@ -47,6 +59,30 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
@actions/io
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright 2019 GitHub
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
@actions/tool-cache
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright 2019 GitHub
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
@octokit/auth-token
|
@octokit/auth-token
|
||||||
MIT
|
MIT
|
||||||
The MIT License
|
The MIT License
|
||||||
|
@ -463,31 +499,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
fetch-retry
|
|
||||||
MIT
|
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2016 Jon K. Bernhardsen
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
|
|
||||||
|
|
||||||
iconv-lite
|
iconv-lite
|
||||||
MIT
|
MIT
|
||||||
Copyright (c) 2011 Alexander Shtuchkin
|
Copyright (c) 2011 Alexander Shtuchkin
|
||||||
|
@ -608,6 +619,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
semver
|
||||||
|
ISC
|
||||||
|
The ISC License
|
||||||
|
|
||||||
|
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||||
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
string-argv
|
string-argv
|
||||||
MIT
|
MIT
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
83
package-lock.json
generated
83
package-lock.json
generated
|
@ -10,7 +10,9 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^5.1.1",
|
||||||
|
"@actions/tool-cache": "^2.0.1",
|
||||||
"fetch-retry": "^5.0.6",
|
"fetch-retry": "^5.0.6",
|
||||||
"string-argv": "^0.3.2"
|
"string-argv": "^0.3.2"
|
||||||
},
|
},
|
||||||
|
@ -44,6 +46,14 @@
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@actions/exec": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/io": "^1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@actions/github": {
|
"node_modules/@actions/github": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.1.tgz",
|
||||||
|
@ -63,6 +73,41 @@
|
||||||
"tunnel": "^0.0.6"
|
"tunnel": "^0.0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@actions/io": {
|
||||||
|
"version": "1.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz",
|
||||||
|
"integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q=="
|
||||||
|
},
|
||||||
|
"node_modules/@actions/tool-cache": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==",
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/core": "^1.2.6",
|
||||||
|
"@actions/exec": "^1.0.0",
|
||||||
|
"@actions/http-client": "^2.0.1",
|
||||||
|
"@actions/io": "^1.1.1",
|
||||||
|
"semver": "^6.1.0",
|
||||||
|
"uuid": "^3.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@actions/tool-cache/node_modules/semver": {
|
||||||
|
"version": "6.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
||||||
|
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
|
||||||
|
"bin": {
|
||||||
|
"semver": "bin/semver.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@actions/tool-cache/node_modules/uuid": {
|
||||||
|
"version": "3.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||||
|
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||||
|
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@eslint-community/eslint-utils": {
|
"node_modules/@eslint-community/eslint-utils": {
|
||||||
"version": "4.4.0",
|
"version": "4.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz",
|
||||||
|
@ -3646,6 +3691,14 @@
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@actions/exec": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
|
||||||
|
"requires": {
|
||||||
|
"@actions/io": "^1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@actions/github": {
|
"@actions/github": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.1.tgz",
|
||||||
|
@ -3665,6 +3718,36 @@
|
||||||
"tunnel": "^0.0.6"
|
"tunnel": "^0.0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@actions/io": {
|
||||||
|
"version": "1.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz",
|
||||||
|
"integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q=="
|
||||||
|
},
|
||||||
|
"@actions/tool-cache": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==",
|
||||||
|
"requires": {
|
||||||
|
"@actions/core": "^1.2.6",
|
||||||
|
"@actions/exec": "^1.0.0",
|
||||||
|
"@actions/http-client": "^2.0.1",
|
||||||
|
"@actions/io": "^1.1.1",
|
||||||
|
"semver": "^6.1.0",
|
||||||
|
"uuid": "^3.3.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"semver": {
|
||||||
|
"version": "6.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
||||||
|
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="
|
||||||
|
},
|
||||||
|
"uuid": {
|
||||||
|
"version": "3.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||||
|
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"@eslint-community/eslint-utils": {
|
"@eslint-community/eslint-utils": {
|
||||||
"version": "4.4.0",
|
"version": "4.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz",
|
||||||
|
|
|
@ -23,7 +23,9 @@
|
||||||
"homepage": "https://github.com/DeterminateSystems/nix-installer-action#readme",
|
"homepage": "https://github.com/DeterminateSystems/nix-installer-action#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^5.1.1",
|
||||||
|
"@actions/tool-cache": "^2.0.1",
|
||||||
"fetch-retry": "^5.0.6",
|
"fetch-retry": "^5.0.6",
|
||||||
"string-argv": "^0.3.2"
|
"string-argv": "^0.3.2"
|
||||||
},
|
},
|
||||||
|
|
119
src/main.ts
119
src/main.ts
|
@ -1,19 +1,13 @@
|
||||||
import * as actions_core from "@actions/core";
|
import * as actions_core from "@actions/core";
|
||||||
import * as github from "@actions/github";
|
import * as github from "@actions/github";
|
||||||
import { mkdtemp, chmod, access, writeFile, open } from "node:fs/promises";
|
import * as actions_tool_cache from "@actions/tool-cache";
|
||||||
import { spawn } from "node:child_process";
|
import * as actions_exec from "@actions/exec";
|
||||||
|
import { chmod, access, writeFile } from "node:fs/promises";
|
||||||
import { randomUUID } from "node:crypto";
|
import { randomUUID } from "node:crypto";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import { tmpdir } from "node:os";
|
|
||||||
import stream from "node:stream";
|
|
||||||
import stream_web from "node:stream/web";
|
|
||||||
import { finished } from "node:stream/promises";
|
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import stringArgv from "string-argv";
|
import stringArgv from "string-argv";
|
||||||
|
|
||||||
import fetchRetry_ from "fetch-retry";
|
|
||||||
const fetchRetry = fetchRetry_(global.fetch);
|
|
||||||
|
|
||||||
class NixInstallerAction {
|
class NixInstallerAction {
|
||||||
platform: string;
|
platform: string;
|
||||||
nix_package_url: string | null;
|
nix_package_url: string | null;
|
||||||
|
@ -267,33 +261,25 @@ class NixInstallerAction {
|
||||||
args.concat(extra_args);
|
args.concat(extra_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
const merged_env = {
|
const exit_code = await actions_exec.exec(binary_path, args, {
|
||||||
...process.env, // To get $PATH, etc
|
env: {
|
||||||
...execution_env,
|
...execution_env,
|
||||||
};
|
...process.env, // To get $PATH, etc
|
||||||
|
},
|
||||||
const spawned = spawn(`${binary_path}`, args, {
|
listeners: {
|
||||||
env: merged_env,
|
stdout: (data: Buffer) => {
|
||||||
});
|
const trimmed = data.toString("utf-8").trimEnd();
|
||||||
|
|
||||||
spawned.stdout.setEncoding("utf-8");
|
|
||||||
spawned.stdout.on("data", (data) => {
|
|
||||||
const trimmed = data.trimEnd();
|
|
||||||
if (trimmed.length >= 0) {
|
if (trimmed.length >= 0) {
|
||||||
actions_core.info(trimmed);
|
actions_core.info(trimmed);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
stderr: (data: Buffer) => {
|
||||||
spawned.stderr.setEncoding("utf-8");
|
const trimmed = data.toString("utf-8").trimEnd();
|
||||||
spawned.stderr.on("data", (data) => {
|
|
||||||
const trimmed = data.trimEnd();
|
|
||||||
if (trimmed.length >= 0) {
|
if (trimmed.length >= 0) {
|
||||||
actions_core.info(trimmed);
|
actions_core.info(trimmed);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
},
|
||||||
const exit_code: number = await new Promise((resolve, _reject) => {
|
|
||||||
spawned.on("close", resolve);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (exit_code !== 0) {
|
if (exit_code !== 0) {
|
||||||
|
@ -369,32 +355,30 @@ class NixInstallerAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute_uninstall(): Promise<number> {
|
async execute_uninstall(): Promise<number> {
|
||||||
const spawned = spawn(`/nix/nix-installer`, ["uninstall"], {
|
const exit_code = await actions_exec.exec(
|
||||||
|
`/nix/nix-installer`,
|
||||||
|
["uninstall"],
|
||||||
|
{
|
||||||
env: {
|
env: {
|
||||||
NIX_INSTALLER_NO_CONFIRM: "true",
|
NIX_INSTALLER_NO_CONFIRM: "true",
|
||||||
...process.env, // To get $PATH, etc
|
...process.env, // To get $PATH, etc
|
||||||
},
|
},
|
||||||
});
|
listeners: {
|
||||||
|
stdout: (data: Buffer) => {
|
||||||
spawned.stdout.setEncoding("utf-8");
|
const trimmed = data.toString("utf-8").trimEnd();
|
||||||
spawned.stdout.on("data", (data) => {
|
|
||||||
const trimmed = data.trimEnd();
|
|
||||||
if (trimmed.length >= 0) {
|
if (trimmed.length >= 0) {
|
||||||
actions_core.info(trimmed);
|
actions_core.info(trimmed);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
stderr: (data: Buffer) => {
|
||||||
spawned.stderr.setEncoding("utf-8");
|
const trimmed = data.toString("utf-8").trimEnd();
|
||||||
spawned.stderr.on("data", (data) => {
|
|
||||||
const trimmed = data.trimEnd();
|
|
||||||
if (trimmed.length >= 0) {
|
if (trimmed.length >= 0) {
|
||||||
actions_core.info(trimmed);
|
actions_core.info(trimmed);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
},
|
||||||
const exit_code: number = await new Promise((resolve, _reject) => {
|
},
|
||||||
spawned.on("close", resolve);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
if (exit_code !== 0) {
|
if (exit_code !== 0) {
|
||||||
throw new Error(`Non-zero exit code of \`${exit_code}\` detected`);
|
throw new Error(`Non-zero exit code of \`${exit_code}\` detected`);
|
||||||
|
@ -418,50 +402,13 @@ class NixInstallerAction {
|
||||||
private async fetch_binary(): Promise<string> {
|
private async fetch_binary(): Promise<string> {
|
||||||
if (!this.local_root) {
|
if (!this.local_root) {
|
||||||
actions_core.info(`Fetching binary from ${this.nix_installer_url}`);
|
actions_core.info(`Fetching binary from ${this.nix_installer_url}`);
|
||||||
const response = await fetchRetry(this.nix_installer_url, {
|
const binaryPath = await actions_tool_cache.downloadTool(
|
||||||
retries: 5,
|
String(this.nix_installer_url),
|
||||||
retryDelay(
|
|
||||||
attempt: number,
|
|
||||||
_error: Error | null,
|
|
||||||
_response: Response | null,
|
|
||||||
) {
|
|
||||||
return Math.pow(2, attempt) * 1000; // 1000, 2000, 4000
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(
|
|
||||||
`Got a status of ${response.status} from \`${this.nix_installer_url}\`, expected a 200`,
|
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
const tempdir = await mkdtemp(join(tmpdir(), "nix-installer-"));
|
|
||||||
const tempfile = join(tempdir, `nix-installer-${this.platform}`);
|
|
||||||
|
|
||||||
if (response.body !== null) {
|
|
||||||
const handle = await open(
|
|
||||||
tempfile,
|
|
||||||
fs.constants.O_CREAT |
|
|
||||||
fs.constants.O_TRUNC |
|
|
||||||
fs.constants.O_WRONLY |
|
|
||||||
fs.constants.O_DSYNC,
|
|
||||||
);
|
|
||||||
const fileStream = handle.createWriteStream();
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
const bodyCast = response.body as stream_web.ReadableStream<any>;
|
|
||||||
const bodyReader = stream.Readable.fromWeb(bodyCast);
|
|
||||||
await finished(bodyReader.pipe(fileStream));
|
|
||||||
fileStream.close();
|
|
||||||
|
|
||||||
actions_core.info(`Downloaded \`nix-installer\` to \`${tempfile}\``);
|
|
||||||
} else {
|
|
||||||
throw new Error("No response body recieved");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make executable
|
// Make executable
|
||||||
await chmod(tempfile, fs.constants.S_IXUSR | fs.constants.S_IXGRP);
|
await chmod(binaryPath, fs.constants.S_IXUSR | fs.constants.S_IXGRP);
|
||||||
|
|
||||||
return tempfile;
|
return binaryPath;
|
||||||
} else {
|
} else {
|
||||||
const local_path = join(
|
const local_path = join(
|
||||||
this.local_root,
|
this.local_root,
|
||||||
|
|
Loading…
Reference in a new issue