diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 95d6f2e..398814b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -108,7 +108,7 @@ jobs: - version-check - publish-npm - build-native-bundles - if: needs.version-check.outputs.should_publish == 'true' + if: needs.version-check.outputs.should_build_release == 'true' && needs.build-native-bundles.result == 'success' && (needs.publish-npm.result == 'success' || needs.publish-npm.result == 'skipped') runs-on: blacksmith-4vcpu-ubuntu-2404 permissions: contents: write @@ -122,7 +122,15 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} VERSION: ${{ needs.version-check.outputs.version }} run: | - gh release create "v$VERSION" release-assets/* \ - --title "v$VERSION" \ - --notes "Standalone Feynman bundles for native installation." \ - --target "$GITHUB_SHA" + if gh release view "v$VERSION" >/dev/null 2>&1; then + gh release upload "v$VERSION" release-assets/* --clobber + gh release edit "v$VERSION" \ + --title "v$VERSION" \ + --notes "Standalone Feynman bundles for native installation." \ + --draft=false + else + gh release create "v$VERSION" release-assets/* \ + --title "v$VERSION" \ + --notes "Standalone Feynman bundles for native installation." \ + --target "$GITHUB_SHA" + fi diff --git a/scripts/build-native-bundle.mjs b/scripts/build-native-bundle.mjs index 798e4c2..93948f0 100644 --- a/scripts/build-native-bundle.mjs +++ b/scripts/build-native-bundle.mjs @@ -13,25 +13,41 @@ function fail(message) { process.exit(1); } +function resolveCommand(command) { + if (process.platform === "win32" && command === "npm") { + return "npm.cmd"; + } + + return command; +} + function run(command, args, options = {}) { - const result = spawnSync(command, args, { + const resolvedCommand = resolveCommand(command); + const result = spawnSync(resolvedCommand, args, { stdio: "inherit", ...options, }); + if (result.error) { + fail(`${resolvedCommand} ${args.join(" ")} failed: ${result.error.message}`); + } if (result.status !== 0) { - fail(`${command} ${args.join(" ")} failed with code ${result.status ?? 1}`); + fail(`${resolvedCommand} ${args.join(" ")} failed with code ${result.status ?? 1}`); } } function runCapture(command, args, options = {}) { - const result = spawnSync(command, args, { + const resolvedCommand = resolveCommand(command); + const result = spawnSync(resolvedCommand, args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], ...options, }); + if (result.error) { + fail(`${resolvedCommand} ${args.join(" ")} failed: ${result.error.message}`); + } if (result.status !== 0) { const errorOutput = result.stderr?.trim() || result.stdout?.trim() || "unknown error"; - fail(`${command} ${args.join(" ")} failed: ${errorOutput}`); + fail(`${resolvedCommand} ${args.join(" ")} failed: ${errorOutput}`); } return result.stdout.trim(); }