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
7 changes: 1 addition & 6 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,7 @@ jobs:
chmod +x npm/darwin-x64/bin/squawk npm/darwin-arm64/bin/squawk npm/linux-x64/bin/squawk npm/linux-arm64/bin/squawk npm/linux-x64-musl/bin/squawk npm/linux-arm64-musl/bin/squawk

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

publish-docker:
if: startsWith(github.ref, 'refs/tags/')
Expand Down
61 changes: 61 additions & 0 deletions s/publish-npm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env node
"use strict"

const childProcess = require("child_process")
const fs = require("fs")
const path = require("path")

/** @type {readonly string[]} */
const PLATFORMS = [
"darwin-x64",
"darwin-arm64",
"linux-x64",
"linux-arm64",
"linux-x64-musl",
"linux-arm64-musl",
"win32-x64",
]

/**
* @param {string} name
* @param {string} version
* @returns {boolean}
*/
function isPublished(name, version) {
const result = childProcess.spawnSync(
"npm",
["view", `${name}@${version}`, "version"],
{ encoding: "utf8" },
)
return result.status === 0 && result.stdout.trim() === version
}

/**
* @param {string} dir
* @returns {void}
*/
function publish(dir) {
/** @type {{ name: string, version: string }} */
const { name, version } = JSON.parse(
fs.readFileSync(path.join(dir, "package.json"), "utf8"),
)
if (isPublished(name, version)) {
console.log(`skipping ${name}@${version}, already published`)
return
}
childProcess.execFileSync(
"npm",
["publish", "--access", "public", "--provenance"],
{ cwd: dir, stdio: "inherit" },
)
}

/** @returns {void} */
function main() {
for (const platform of PLATFORMS) {
publish(path.join("npm", platform))
}
publish(".")
}

main()
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"jsx": "react",
"noEmit": true
},
"include": ["js/**/*.js"],
"include": ["js/**/*.js", "s/**/*.js"],
"exclude": ["build", "node_modules", "docs", "plopfile.js", "playground"]
}
Loading