Skip to content

Commit 117a534

Browse files
committed
fix: ensure npm job depends on goreleaser and improve error handling in installBinaries
1 parent 382d27d commit 117a534

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
GITHUB_TOKEN: ${{ secrets.GORELEASER_TOKEN }}
2929
npm:
3030
runs-on: ubuntu-latest
31+
needs: goreleaser
3132
steps:
3233
- uses: actions/checkout@v4
3334
with:

scripts/create-npm-package.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ mkdir -p "$TARGET_DIR"
1414

1515
cp "${SOURCE_DIR}/constants.js" "${TARGET_DIR}/"
1616
cp "${SOURCE_DIR}/installer.js" "${TARGET_DIR}/"
17+
cp "${SOURCE_DIR}/lib.js" "${TARGET_DIR}/"
1718
cp "${SOURCE_DIR}/runner.js" "${TARGET_DIR}/"
1819
cp "${SOURCE_DIR}/package.json" "${TARGET_DIR}/"
1920
cp "${SOURCE_DIR}/README.md" "${TARGET_DIR}/"

scripts/npm/lib.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export async function installBinaries() {
1212
if (!ARCH) throw UNSUPPORTED_ARCH;
1313

1414
const destination = BIN_DIR;
15-
const release = await getRelease(`v${VERSION}`);
15+
const release = await getRelease(`v${VERSION}`).catch(err => {
16+
throw new Error(`Unable to find release v${VERSION}`);
17+
});
1618
const assetPrefix = `${BIN_NAME}_${PLATFORM}_${ARCH}`
1719
const asset = release.assets.find((a) => a.name.startsWith(assetPrefix));
1820
if (!asset) throw new Error(`Cannot find an asset for ${PLATFORM} - ${ARCH} (${assetPrefix})`);

scripts/npm/runner.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ async function run() {
1212
await installBinaries()
1313
}
1414

15+
const [, , ...args] = process.argv
16+
1517
let result = spawnSync(binfile, args, {
1618
cwd: process.cwd(),
1719
stdio: "inherit",

0 commit comments

Comments
 (0)