fix publish: generate platform packages manually, add optionalDependencies
Skip napi prepublish/artifacts commands that require GitHub API auth. Instead, create platform package.json files and copy binaries directly. Add optionalDependencies to main package so npm/bun auto-selects the right binary. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
a1c62eb24e
commit
9154085e2c
@@ -78,30 +78,54 @@ jobs:
|
|||||||
|
|
||||||
- name: Prepare and publish
|
- name: Prepare and publish
|
||||||
working-directory: napi
|
working-directory: napi
|
||||||
env:
|
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
run: |
|
||||||
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > .npmrc
|
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > .npmrc
|
||||||
echo "@firecrawl:registry=https://npm.pkg.github.com" >> .npmrc
|
echo "@firecrawl:registry=https://npm.pkg.github.com" >> .npmrc
|
||||||
|
|
||||||
# Create platform package dirs expected by napi artifacts
|
VERSION=$(node -p "require('./package.json').version")
|
||||||
|
|
||||||
|
# Create platform package dirs and package.json files
|
||||||
mkdir -p npm/linux-x64-gnu npm/darwin-arm64
|
mkdir -p npm/linux-x64-gnu npm/darwin-arm64
|
||||||
|
|
||||||
# Move binaries into platform dirs
|
cat > npm/linux-x64-gnu/package.json << PKGEOF
|
||||||
bunx napi artifacts --build-output-dir artifacts
|
{
|
||||||
|
"name": "@firecrawl/pdf-inspector-js-linux-x64-gnu",
|
||||||
|
"version": "${VERSION}",
|
||||||
|
"os": ["linux"],
|
||||||
|
"cpu": ["x64"],
|
||||||
|
"main": "pdf-inspector.linux-x64-gnu.node",
|
||||||
|
"files": ["pdf-inspector.linux-x64-gnu.node"],
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": { "type": "git", "url": "https://github.com/firecrawl/pdf-inspector" },
|
||||||
|
"publishConfig": { "registry": "https://npm.pkg.github.com", "access": "public" }
|
||||||
|
}
|
||||||
|
PKGEOF
|
||||||
|
|
||||||
# Generate platform package.json files
|
cat > npm/darwin-arm64/package.json << PKGEOF
|
||||||
bunx napi prepublish -t npm --skip-gh-release
|
{
|
||||||
|
"name": "@firecrawl/pdf-inspector-js-darwin-arm64",
|
||||||
|
"version": "${VERSION}",
|
||||||
|
"os": ["darwin"],
|
||||||
|
"cpu": ["arm64"],
|
||||||
|
"main": "pdf-inspector.darwin-arm64.node",
|
||||||
|
"files": ["pdf-inspector.darwin-arm64.node"],
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": { "type": "git", "url": "https://github.com/firecrawl/pdf-inspector" },
|
||||||
|
"publishConfig": { "registry": "https://npm.pkg.github.com", "access": "public" }
|
||||||
|
}
|
||||||
|
PKGEOF
|
||||||
|
|
||||||
|
# Move binaries into platform dirs
|
||||||
|
cp artifacts/bindings-x86_64-unknown-linux-gnu/*.node npm/linux-x64-gnu/
|
||||||
|
cp artifacts/bindings-aarch64-apple-darwin/*.node npm/darwin-arm64/
|
||||||
|
|
||||||
echo "=== Package contents ==="
|
echo "=== Package contents ==="
|
||||||
ls -R npm/
|
ls -R npm/
|
||||||
|
|
||||||
# Publish platform packages first, then main package
|
# Publish platform packages first, then main package
|
||||||
for dir in npm/*/; do
|
for dir in npm/*/; do
|
||||||
if [ -f "$dir/package.json" ]; then
|
|
||||||
echo "Publishing $dir"
|
echo "Publishing $dir"
|
||||||
(cd "$dir" && npm publish --access public) || true
|
(cd "$dir" && npm publish --access public)
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
echo "Publishing main package"
|
echo "Publishing main package"
|
||||||
npm publish --access public || true
|
npm publish --access public
|
||||||
|
|||||||
+9
-3
@@ -4,6 +4,10 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"index.d.ts"
|
||||||
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/firecrawl/pdf-inspector"
|
"url": "https://github.com/firecrawl/pdf-inspector"
|
||||||
@@ -22,11 +26,13 @@
|
|||||||
"name": "@firecrawl/pdf-inspector-js"
|
"name": "@firecrawl/pdf-inspector-js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@firecrawl/pdf-inspector-js-linux-x64-gnu": "0.2.0",
|
||||||
|
"@firecrawl/pdf-inspector-js-darwin-arm64": "0.2.0"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "napi build --platform --release",
|
"build": "napi build --platform --release",
|
||||||
"build:debug": "napi build --platform",
|
"build:debug": "napi build --platform"
|
||||||
"prepublishOnly": "napi prepublish -t npm",
|
|
||||||
"artifacts": "napi artifacts"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@napi-rs/cli": "^3.4.1"
|
"@napi-rs/cli": "^3.4.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user