Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,39 @@ jobs:
with:
node-version: 24
- run: npm --version
- run: npm publish

- name: Download release artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: release-squawk-*

- name: Stage platform binaries
run: |
set -euo pipefail
mkdir -p npm/darwin-x64/bin npm/darwin-arm64/bin npm/linux-x64/bin npm/linux-arm64/bin npm/win32-x64/bin
cp artifacts/release-squawk-darwin-x64/squawk-darwin-x64 npm/darwin-x64/bin/squawk
cp artifacts/release-squawk-darwin-arm64/squawk-darwin-arm64 npm/darwin-arm64/bin/squawk
cp artifacts/release-squawk-linux-x64/squawk-linux-x64 npm/linux-x64/bin/squawk
cp artifacts/release-squawk-linux-arm64/squawk-linux-arm64 npm/linux-arm64/bin/squawk
cp artifacts/release-squawk-windows-x64.exe/squawk-windows-x64.exe npm/win32-x64/bin/squawk.exe
chmod +x npm/darwin-x64/bin/squawk npm/darwin-arm64/bin/squawk npm/linux-x64/bin/squawk npm/linux-arm64/bin/squawk

- name: Inject optionalDependencies into root package.json
run: |
set -euo pipefail
VERSION=$(node -p 'require("./package.json").version')
for tgt in darwin-x64 darwin-arm64 linux-x64 linux-arm64 win32-x64; do
npm pkg set "optionalDependencies.@squawk-cli/${tgt}=${VERSION}"
done

- name: Publish packages
run: |
set -euo pipefail
for pkg in darwin-x64 darwin-arm64 linux-x64 linux-arm64 win32-x64; do
(cd "npm/$pkg" && npm publish --access public --provenance)
done
npm publish --access public --provenance

publish-docker:
if: startsWith(github.ref, 'refs/tags/')
Expand Down
14 changes: 14 additions & 0 deletions crates/xtask/src/update_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@ fn update_versions(sh: &Shell, v: &str) -> Result<()> {
r#""version": ".*""#,
&json_rep,
)?;
for target in [
"darwin-arm64",
"darwin-x64",
"linux-arm64",
"linux-x64",
"win32-x64",
] {
replace_in_file(
sh,
&format!("npm/{target}/package.json"),
r#""version": ".*""#,
&json_rep,
)?;
}

replace_in_file(
sh,
Expand Down
55 changes: 1 addition & 54 deletions js/bin/squawk
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,4 @@

"use strict"

// Copyright (c) 2016 Sentry (https://sentry.io/) and individual contributors.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Sentry nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// from: https://github.com/getsentry/sentry-cli/blob/acc8d00eb1965d8f49a9f337b7776c782d253ac4/bin/sentry-cli

const childProcess = require("child_process")
const { binaryPath } = require("../helpers")

const child = childProcess.spawn(binaryPath, process.argv.slice(2), {
stdio: "inherit",
})

child.on("error", err => {
console.error("error: failed to invoke squawk")
console.error(err.stack)
process.exit(1)
})

child.on("exit", code => {
process.exit(code)
})

process.on("SIGTERM", () => {
child.kill("SIGTERM")
})

process.on("SIGINT", () => {
child.kill("SIGINT")
})
require("../index.js").run()
2 changes: 0 additions & 2 deletions js/binaries/.gitignore

This file was deleted.

8 changes: 0 additions & 8 deletions js/helpers.js

This file was deleted.

68 changes: 68 additions & 0 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"use strict"

const childProcess = require("child_process")

/** @type {Record<string, string>} */
const PLATFORM_PACKAGES = {
"darwin-x64": "@squawk-cli/darwin-x64",
"darwin-arm64": "@squawk-cli/darwin-arm64",
"linux-x64": "@squawk-cli/linux-x64",
"linux-arm64": "@squawk-cli/linux-arm64",
"win32-x64": "@squawk-cli/win32-x64",
}

function getBinaryPath() {
const key = `${process.platform}-${process.arch}`
const pkg = PLATFORM_PACKAGES[key]
if (!pkg) {
throw new Error(
`squawk: unsupported platform "${key}". Supported: ${Object.keys(PLATFORM_PACKAGES).join(", ")}.`,
)
}
const binaryName = process.platform === "win32" ? "squawk.exe" : "squawk"
try {
return require.resolve(`${pkg}/bin/${binaryName}`)
} catch {
throw new Error(
`squawk: the "${pkg}" optional dependency was not installed.\n` +
`This usually means your package manager skipped optional dependencies. ` +
`Re-install with optional dependencies enabled (e.g. "npm install --include=optional").`,
)
}
}

function resolveBinaryOrExit() {
try {
return getBinaryPath()
} catch (err) {
console.error(err instanceof Error ? err.message : err)
process.exit(1)
}
}

function run() {
const binaryPath = resolveBinaryOrExit()

const child = childProcess.spawn(binaryPath, process.argv.slice(2), {
stdio: "inherit",
})

child.on("error", (err) => {
console.error("error: failed to invoke squawk")
console.error(err.stack)
})

child.on("exit", (code) => {
process.exit(code ?? 1)
})

process.on("SIGTERM", () => {
child.kill("SIGTERM")
})

process.on("SIGINT", () => {
child.kill("SIGINT")
})
}

module.exports = { getBinaryPath, run }
168 changes: 0 additions & 168 deletions js/install.js

This file was deleted.

2 changes: 2 additions & 0 deletions npm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/bin/squawk
*/bin/squawk.exe
19 changes: 19 additions & 0 deletions npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@squawk-cli/darwin-arm64",
"version": "0.0.0",
"description": "squawk-cli binary for darwin-arm64",
"repository": "git@github.com:sbdchd/squawk.git",
"license": "(Apache-2.0 OR MIT)",
"os": [
"darwin"
],
"cpu": [
"arm64"
],
"bin": {
"squawk": "bin/squawk"
},
"files": [
"bin/squawk"
]
}
Loading
Loading