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
19 changes: 15 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,23 @@ jobs:
with:
path: artifacts/

- name: Verify version not already on npm
- name: Check if main package already published
id: check-main
env:
VERSION: ${{ needs.compute-version.outputs.version }}
run: |
PKG="@optave/codegraph"
echo "Checking if $PKG@$VERSION already exists on npm..."
if npm view "$PKG@$VERSION" version 2>/dev/null; then
echo "::error::$PKG@$VERSION is already published on npm."
exit 1
echo "⚠️ $PKG@$VERSION is already published — will skip publish steps"
echo "already_published=true" >> "$GITHUB_OUTPUT"
else
echo "$PKG@$VERSION is not yet published — proceeding"
echo "already_published=false" >> "$GITHUB_OUTPUT"
fi
echo "$PKG@$VERSION is not yet published — proceeding"

- name: Publish platform packages
if: steps.check-main.outputs.already_published == 'false'
env:
VERSION: ${{ needs.compute-version.outputs.version }}
NPM_TAG: ${{ needs.compute-version.outputs.npm_tag }}
Expand Down Expand Up @@ -226,11 +230,18 @@ jobs:
}
PKGJSON

# Skip if this exact version is already published (idempotent re-runs)
if npm view "${pkg_name}@${VERSION}" version 2>/dev/null; then
echo "⚠️ ${pkg_name}@${VERSION} already published — skipping"
continue
fi

echo "Publishing ${pkg_name}@${VERSION} with --tag ${NPM_TAG}"
npm publish "./pkg/$platform" --access public --provenance --tag "$NPM_TAG"
done

- name: Publish main package
if: steps.check-main.outputs.already_published == 'false'
env:
NPM_TAG: ${{ needs.compute-version.outputs.npm_tag }}
run: npm publish --access public --provenance --tag "$NPM_TAG"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"lint:fix": "biome check --write src/ tests/",
"format": "biome format --write src/ tests/",
"prepare": "npm run build:wasm && husky && npm run deps:tree",
"deps:tree": "node -e \"const{execSync}=require('child_process');const t=execSync('npm ls --all --omit=dev',{encoding:'utf8'});require('fs').writeFileSync('DEPENDENCIES.md','# Dependencies\\n\\n```\\n'+t+'```\\n')\"",
"deps:tree": "node scripts/gen-deps.cjs",
"release": "commit-and-tag-version",
"release:dry-run": "commit-and-tag-version --dry-run",
"version": "node scripts/sync-native-versions.js && git add package.json",
Expand Down
21 changes: 21 additions & 0 deletions scripts/gen-deps.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { execSync } = require('child_process');
const fs = require('fs');

try {
const tree = execSync('npm ls --all --omit=dev', { encoding: 'utf8' });
fs.writeFileSync(
'DEPENDENCIES.md',
'# Dependencies\n\n```\n' + tree + '```\n',
);
} catch (err) {
// npm ls exits non-zero on ELSPROBLEMS (version mismatches in optional deps).
// If stdout still has content, write it; otherwise skip silently.
if (err.stdout) {
fs.writeFileSync(
'DEPENDENCIES.md',
'# Dependencies\n\n```\n' + err.stdout + '```\n',
);
} else {
console.warn('deps:tree skipped —', err.message);
}
}
Loading