diff --git a/dist/publish-crates-eclipse-main.js b/dist/publish-crates-eclipse-main.js index c2c20a6..d97af27 100644 --- a/dist/publish-crates-eclipse-main.js +++ b/dist/publish-crates-eclipse-main.js @@ -127589,6 +127589,27 @@ function buildDebian(path, target, version) { __webpack_async_result__(); } catch(e) { __webpack_async_result__(e); } }, 1); +/***/ }), + +/***/ 36410: +/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => { + +"use strict"; +/* harmony export */ __nccwpck_require__.d(__webpack_exports__, { +/* harmony export */ "J": () => (/* binding */ sha256) +/* harmony export */ }); +/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(6113); +/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(crypto__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(73292); +/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__nccwpck_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_1__); + + +async function sha256(path) { + const contents = await fs_promises__WEBPACK_IMPORTED_MODULE_1__.readFile(path); + return crypto__WEBPACK_IMPORTED_MODULE_0__.createHash("sha256").update(contents).digest("hex"); +} + + /***/ }), /***/ 28121: @@ -127772,6 +127793,9 @@ __nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __we /* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(28121); /* harmony import */ var _build_crates_debian__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(22771); /* harmony import */ var _build_crates_standalone__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(32); +/* harmony import */ var _checksum__WEBPACK_IMPORTED_MODULE_7__ = __nccwpck_require__(36410); +/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_8__ = __nccwpck_require__(73292); +/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__nccwpck_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_8__); var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_build_crates_debian__WEBPACK_IMPORTED_MODULE_5__, _build_crates_standalone__WEBPACK_IMPORTED_MODULE_6__]); ([_build_crates_debian__WEBPACK_IMPORTED_MODULE_5__, _build_crates_standalone__WEBPACK_IMPORTED_MODULE_6__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__); @@ -127781,6 +127805,8 @@ var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_bui + + const artifact = new _actions_artifact__WEBPACK_IMPORTED_MODULE_2__.DefaultArtifactClient(); function setup() { const liveRun = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getBooleanInput("live-run", { required: true }); @@ -127810,14 +127836,18 @@ async function main(input) { return input.archiveRegExp.test(name); } }; + const checksumFile = "sha256sums.txt"; + const archiveDir = `${input.sshHostPath}/${input.version}`; const results = await artifact.listArtifacts({ latest: true }); for (const result of results.artifacts) { if (shouldPublishArtifact(result.name)) { const { downloadPath } = await artifact.downloadArtifact(result.id); const archive = path__WEBPACK_IMPORTED_MODULE_0__.join(downloadPath, result.name); - const archiveDir = `${input.sshHostPath}/${input.version}`; - _actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`Uploading ${archive} to download.eclipse.org`); + const checksum = await (0,_checksum__WEBPACK_IMPORTED_MODULE_7__/* .sha256 */ .J)(archive); + // Write the sha256 checksum of the archive + await fs_promises__WEBPACK_IMPORTED_MODULE_8__.appendFile(checksumFile, `${checksum} ${archive}\n`); if (input.liveRun) { + _actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`Uploading ${archive} to download.eclipse.org`); await _ssh__WEBPACK_IMPORTED_MODULE_3__/* .withIdentity */ .Y(input.sshPrivateKey, input.sshPassphrase, env => { (0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)(`ssh -v -o StrictHostKeyChecking=no ${input.sshHost} mkdir -p ${archiveDir}`, { env }); (0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)(`scp -v -o StrictHostKeyChecking=no -r ${archive} ${input.sshHost}:${archiveDir}`, { env }); @@ -127825,6 +127855,12 @@ async function main(input) { } } } + if (input.liveRun) { + _actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`Uploading ${checksumFile} to download.eclipse.org`); + await _ssh__WEBPACK_IMPORTED_MODULE_3__/* .withIdentity */ .Y(input.sshPrivateKey, input.sshPassphrase, env => { + (0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)(`scp -v -o StrictHostKeyChecking=no -r ${checksumFile} ${input.sshHost}:${archiveDir}`, { env }); + }); + } cleanup(); } catch (error) { diff --git a/dist/publish-crates-homebrew-main.js b/dist/publish-crates-homebrew-main.js index 9a3f132..85981f2 100644 --- a/dist/publish-crates-homebrew-main.js +++ b/dist/publish-crates-homebrew-main.js @@ -127493,6 +127493,27 @@ function buildDebian(path, target, version) { __webpack_async_result__(); } catch(e) { __webpack_async_result__(e); } }, 1); +/***/ }), + +/***/ 36410: +/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => { + +"use strict"; +/* harmony export */ __nccwpck_require__.d(__webpack_exports__, { +/* harmony export */ "J": () => (/* binding */ sha256) +/* harmony export */ }); +/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(6113); +/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(crypto__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(73292); +/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__nccwpck_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_1__); + + +async function sha256(path) { + const contents = await fs_promises__WEBPACK_IMPORTED_MODULE_1__.readFile(path); + return crypto__WEBPACK_IMPORTED_MODULE_0__.createHash("sha256").update(contents).digest("hex"); +} + + /***/ }), /***/ 28121: @@ -127667,13 +127688,12 @@ __nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __we /* unused harmony export cleanup */ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(73292); /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(6113); -/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__nccwpck_require__.n(crypto__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(42186); -/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__nccwpck_require__.n(_actions_core__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _actions_artifact__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(79450); -/* harmony import */ var _actions_artifact__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__nccwpck_require__.n(_actions_artifact__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(28121); +/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(42186); +/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__nccwpck_require__.n(_actions_core__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _actions_artifact__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(79450); +/* harmony import */ var _actions_artifact__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__nccwpck_require__.n(_actions_artifact__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(28121); +/* harmony import */ var _checksum__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(36410); /* harmony import */ var _ssh__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(27149); /* harmony import */ var _build_crates_standalone__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(32); /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_7__ = __nccwpck_require__(81724); @@ -127687,19 +127707,19 @@ _build_crates_standalone__WEBPACK_IMPORTED_MODULE_6__ = (__webpack_async_depende -const artifact = new _actions_artifact__WEBPACK_IMPORTED_MODULE_3__.DefaultArtifactClient(); +const artifact = new _actions_artifact__WEBPACK_IMPORTED_MODULE_2__.DefaultArtifactClient(); function setup() { - const liveRun = _actions_core__WEBPACK_IMPORTED_MODULE_2__.getBooleanInput("live-run", { required: true }); - const version = _actions_core__WEBPACK_IMPORTED_MODULE_2__.getInput("version", { required: true }); - const repo = _actions_core__WEBPACK_IMPORTED_MODULE_2__.getInput("repo", { required: true }); - const formulae = _actions_core__WEBPACK_IMPORTED_MODULE_2__.getInput("formulae", { required: true }); - const tap = _actions_core__WEBPACK_IMPORTED_MODULE_2__.getInput("tap", { required: true }); - const sshHost = _actions_core__WEBPACK_IMPORTED_MODULE_2__.getInput("ssh-host", { required: true }); - const sshHostUrl = _actions_core__WEBPACK_IMPORTED_MODULE_2__.getInput("ssh-host-url", { required: true }); - const sshHostPath = _actions_core__WEBPACK_IMPORTED_MODULE_2__.getInput("ssh-host-path", { required: true }); - const sshPrivateKey = _actions_core__WEBPACK_IMPORTED_MODULE_2__.getInput("ssh-private-key", { required: true }); - const sshPassphrase = _actions_core__WEBPACK_IMPORTED_MODULE_2__.getInput("ssh-passphrase", { required: true }); - const githubToken = _actions_core__WEBPACK_IMPORTED_MODULE_2__.getInput("github-token", { required: true }); + const liveRun = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getBooleanInput("live-run", { required: true }); + const version = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("version", { required: true }); + const repo = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("repo", { required: true }); + const formulae = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("formulae", { required: true }); + const tap = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("tap", { required: true }); + const sshHost = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("ssh-host", { required: true }); + const sshHostUrl = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("ssh-host-url", { required: true }); + const sshHostPath = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("ssh-host-path", { required: true }); + const sshPrivateKey = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("ssh-private-key", { required: true }); + const sshPassphrase = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("ssh-passphrase", { required: true }); + const githubToken = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("github-token", { required: true }); return { liveRun, version, @@ -127723,7 +127743,7 @@ const X86_64_SHA256 = "x86_64-sha256"; async function main(input) { try { const repo = input.repo.split("/").at(1); - const tapPath = `${(0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)("brew --repository").trim()}/Library/Taps/${input.tap}`; + const tapPath = `${(0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)("brew --repository").trim()}/Library/Taps/${input.tap}`; const tapUrl = `https://${input.githubToken}@github.com/${input.tap}.git`; for (const target of [X86_64_APPLE_DARWIN, AARCH64_APPLE_DARWIN]) { const name = (0,_build_crates_standalone__WEBPACK_IMPORTED_MODULE_6__/* .artifactName */ .vz)(repo, input.version, target); @@ -127731,20 +127751,16 @@ async function main(input) { await artifact.downloadArtifact(result.artifact.id); if (input.liveRun) { await _ssh__WEBPACK_IMPORTED_MODULE_5__/* .withIdentity */ .Y(input.sshPrivateKey, input.sshPassphrase, env => { - (0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)(`ssh -v -o StrictHostKeyChecking=no ${input.sshHost} mkdir -p ${input.sshHostPath}`, { env }); - (0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)(`scp -v -o StrictHostKeyChecking=no -r ${name} ${input.sshHost}:${input.sshHostPath}`, { env }); + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`ssh -v -o StrictHostKeyChecking=no ${input.sshHost} mkdir -p ${input.sshHostPath}`, { env }); + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`scp -v -o StrictHostKeyChecking=no -r ${name} ${input.sshHost}:${input.sshHostPath}`, { env }); }); } } - (0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)(`brew untap ${input.tap}`, { check: false }); - (0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)(`brew tap ${input.tap} ${tapUrl}`); + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`brew untap ${input.tap}`, { check: false }); + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`brew tap ${input.tap} ${tapUrl}`); const releasePath = `${tapPath}/release.json`; const releaseFile = await fs_promises__WEBPACK_IMPORTED_MODULE_0__.readFile(releasePath, "utf-8"); const release = JSON.parse(releaseFile); - const sha256 = async (target) => { - const contents = await fs_promises__WEBPACK_IMPORTED_MODULE_0__.readFile((0,_build_crates_standalone__WEBPACK_IMPORTED_MODULE_6__/* .artifactName */ .vz)(repo, input.version, target)); - return crypto__WEBPACK_IMPORTED_MODULE_1__.createHash("sha256").update(contents).digest("hex"); - }; const url = (target) => { const baseUrl = input.liveRun ? input.sshHostUrl : `file://${process.cwd()}`; return `${baseUrl}/${(0,_build_crates_standalone__WEBPACK_IMPORTED_MODULE_6__/* .artifactName */ .vz)(repo, input.version, target)}`; @@ -127752,37 +127768,37 @@ async function main(input) { for (const formula of input.formulae) { release[formula] = { [X86_64_URL]: url(X86_64_APPLE_DARWIN), - [X86_64_SHA256]: await sha256(X86_64_APPLE_DARWIN), + [X86_64_SHA256]: await (0,_checksum__WEBPACK_IMPORTED_MODULE_4__/* .sha256 */ .J)((0,_build_crates_standalone__WEBPACK_IMPORTED_MODULE_6__/* .artifactName */ .vz)(repo, input.version, X86_64_APPLE_DARWIN)), [AARCH64_URL]: url(AARCH64_APPLE_DARWIN), - [AARCH64_SHA256]: await sha256(AARCH64_APPLE_DARWIN), + [AARCH64_SHA256]: await (0,_checksum__WEBPACK_IMPORTED_MODULE_4__/* .sha256 */ .J)((0,_build_crates_standalone__WEBPACK_IMPORTED_MODULE_6__/* .artifactName */ .vz)(repo, input.version, AARCH64_APPLE_DARWIN)), }; } await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(releasePath, JSON.stringify(release, null, 2)); const message = `chore: Bump ${input.formulae.join(", ")} to \`${input.version}\``; - (0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)(`git commit ${releasePath} --message '${message}'`, { cwd: tapPath, env: _config__WEBPACK_IMPORTED_MODULE_7__/* .gitEnv */ .B }); + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`git commit ${releasePath} --message '${message}'`, { cwd: tapPath, env: _config__WEBPACK_IMPORTED_MODULE_7__/* .gitEnv */ .B }); for (const formula of input.formulae) { - (0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)(`brew audit ${formula}`); - (0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)(`brew install --force ${formula}`); - (0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)(`brew uninstall --force --ignore-dependencies ${formula}`); - (0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)("brew autoremove"); + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`brew audit ${formula}`); + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`brew install --force ${formula}`); + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`brew uninstall --force --ignore-dependencies ${formula}`); + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)("brew autoremove"); } if (input.liveRun) { - (0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)(`git pull ${tapUrl} --rebase`, { cwd: tapPath }); - (0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)(`git push ${tapUrl}`, { cwd: tapPath }); + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`git pull ${tapUrl} --rebase`, { cwd: tapPath }); + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`git push ${tapUrl}`, { cwd: tapPath }); } cleanup(input); } catch (error) { cleanup(input); if (error instanceof Error) - _actions_core__WEBPACK_IMPORTED_MODULE_2__.setFailed(error.message); + _actions_core__WEBPACK_IMPORTED_MODULE_1__.setFailed(error.message); } } function cleanup(input) { for (const formula of input.formulae) { - (0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)(`brew uninstall --force --ignore-dependencies ${formula}`, { check: false }); + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`brew uninstall --force --ignore-dependencies ${formula}`, { check: false }); } - (0,_command__WEBPACK_IMPORTED_MODULE_4__.sh)(`brew untap ${input.tap}`, { check: false }); + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`brew untap ${input.tap}`, { check: false }); } __webpack_async_result__(); diff --git a/src/checksum.ts b/src/checksum.ts new file mode 100644 index 0000000..43fc14a --- /dev/null +++ b/src/checksum.ts @@ -0,0 +1,8 @@ +import { PathLike } from "node:fs"; +import * as crypto from "crypto"; +import * as fs from "fs/promises"; + +export async function sha256(path: PathLike | fs.FileHandle) { + const contents = await fs.readFile(path); + return crypto.createHash("sha256").update(contents).digest("hex"); +} diff --git a/src/publish-crates-eclipse.ts b/src/publish-crates-eclipse.ts index d725fef..9404cc8 100644 --- a/src/publish-crates-eclipse.ts +++ b/src/publish-crates-eclipse.ts @@ -6,8 +6,10 @@ import { DefaultArtifactClient } from "@actions/artifact"; import * as ssh from "./ssh"; import { sh } from "./command"; -import { artifactRegExp as artfifactRegExpDebain } from "./build-crates-debian"; -import { artifactRegExp as artfifactRegExpStandalone } from "./build-crates-standalone"; +import { artifactRegExp as artifactRegExpDebian } from "./build-crates-debian"; +import { artifactRegExp as artifactRegExpStandalone } from "./build-crates-standalone"; +import { sha256 } from "./checksum"; +import * as fs from "fs/promises"; const artifact = new DefaultArtifactClient(); @@ -45,21 +47,25 @@ export async function main(input: Input) { try { const shouldPublishArtifact = (name: string): boolean => { if (input.archiveRegExp == undefined) { - return artfifactRegExpStandalone.test(name) || artfifactRegExpDebain.test(name); + return artifactRegExpStandalone.test(name) || artifactRegExpDebian.test(name); } else { return input.archiveRegExp.test(name); } }; + const checksumFile = "sha256sums.txt"; + const archiveDir = `${input.sshHostPath}/${input.version}`; const results = await artifact.listArtifacts({ latest: true }); for (const result of results.artifacts) { if (shouldPublishArtifact(result.name)) { const { downloadPath } = await artifact.downloadArtifact(result.id); const archive = path.join(downloadPath, result.name); - const archiveDir = `${input.sshHostPath}/${input.version}`; - core.info(`Uploading ${archive} to download.eclipse.org`); + const checksum = await sha256(archive); + // Write the sha256 checksum of the archive + await fs.appendFile(checksumFile, `${checksum} ${archive}\n`); if (input.liveRun) { + core.info(`Uploading ${archive} to download.eclipse.org`); await ssh.withIdentity(input.sshPrivateKey, input.sshPassphrase, env => { sh(`ssh -v -o StrictHostKeyChecking=no ${input.sshHost} mkdir -p ${archiveDir}`, { env }); sh(`scp -v -o StrictHostKeyChecking=no -r ${archive} ${input.sshHost}:${archiveDir}`, { env }); @@ -68,6 +74,13 @@ export async function main(input: Input) { } } + if (input.liveRun) { + core.info(`Uploading ${checksumFile} to download.eclipse.org`); + await ssh.withIdentity(input.sshPrivateKey, input.sshPassphrase, env => { + sh(`scp -v -o StrictHostKeyChecking=no -r ${checksumFile} ${input.sshHost}:${archiveDir}`, { env }); + }); + } + cleanup(); } catch (error) { cleanup(); diff --git a/src/publish-crates-homebrew.ts b/src/publish-crates-homebrew.ts index 4454d4a..6c73c00 100644 --- a/src/publish-crates-homebrew.ts +++ b/src/publish-crates-homebrew.ts @@ -1,10 +1,10 @@ import * as fs from "fs/promises"; -import * as crypto from "crypto"; import * as core from "@actions/core"; import { DefaultArtifactClient } from "@actions/artifact"; import { sh } from "./command"; +import { sha256 } from "./checksum"; import * as ssh from "./ssh"; import { artifactName } from "./build-crates-standalone"; @@ -97,11 +97,6 @@ export async function main(input: Input) { const releaseFile = await fs.readFile(releasePath, "utf-8"); const release = JSON.parse(releaseFile) as Release; - const sha256 = async (target: string): Promise => { - const contents = await fs.readFile(artifactName(repo, input.version, target)); - return crypto.createHash("sha256").update(contents).digest("hex"); - }; - const url = (target: string): string => { const baseUrl = input.liveRun ? input.sshHostUrl : `file://${process.cwd()}`; return `${baseUrl}/${artifactName(repo, input.version, target)}`; @@ -110,9 +105,9 @@ export async function main(input: Input) { for (const formula of input.formulae) { release[formula] = { [X86_64_URL]: url(X86_64_APPLE_DARWIN), - [X86_64_SHA256]: await sha256(X86_64_APPLE_DARWIN), + [X86_64_SHA256]: await sha256(artifactName(repo, input.version, X86_64_APPLE_DARWIN)), [AARCH64_URL]: url(AARCH64_APPLE_DARWIN), - [AARCH64_SHA256]: await sha256(AARCH64_APPLE_DARWIN), + [AARCH64_SHA256]: await sha256(artifactName(repo, input.version, AARCH64_APPLE_DARWIN)), }; }