caelum0x 4847e35451 OpenJev: open-source typed decision service
Typed decision/classification service with an in-process gte-small ONNX
embedding engine and lexical fallback, JS/Python SDKs, adapters, and the
otsone model family. Apache-2.0 (sub-packages keep their MIT licenses).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 00:12:36 +03:00

105 lines
4.0 KiB
YAML

name: Publish npm
on:
push:
tags: ['v[0-9]*']
workflow_dispatch:
inputs:
dry_run:
description: 'Build and test without publishing or creating a release'
type: boolean
default: true
permissions: {}
concurrency:
group: publish-npm
cancel-in-progress: false
jobs:
publish:
if: github.repository == 'caelum0x/openjev'
runs-on: ubuntu-latest
environment: npm
permissions:
contents: write
id-token: write
env:
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: '3.13'
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '24'
package-manager-cache: false
registry-url: https://registry.npmjs.org
- run: npm install --global npm@11.19.0
- name: Validate public release tag and extract changelog notes
id: release
env:
REPOSITORY_PRIVATE: ${{ github.event.repository.private }}
run: |
if [ "$DRY_RUN" = true ]; then
TAG="v$(node -p 'require("./package.json").version')"
else
test "$REPOSITORY_PRIVATE" = false || { echo 'Repository must be public for npm provenance; use dry_run=true for testing'; exit 1; }
test "$GITHUB_REF_TYPE" = tag || { echo 'Select a public version tag for publication'; exit 1; }
TAG="$GITHUB_REF_NAME"
git merge-base --is-ancestor HEAD origin/main || { echo 'Release tag must be on public main'; exit 1; }
fi
node scripts/check-version.mjs
python3 .github/scripts/release_notes.py "$TAG" "$(node -p 'require("./package.json").version')"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
- run: npm ci
- name: Build from public source and check the package
run: |
npm run build
npm run test:dist
npm run check:package
- name: Pack and test the installable artifact
run: |
mkdir release
npm pack --pack-destination release
mv release-notes.md release/
node scripts/test-tarball.mjs
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: npm-release
path: release/
if-no-files-found: error
- name: Publish tested tarball with public provenance
if: env.DRY_RUN != 'true'
env:
# Optional first-publication token; remove after configuring npm OIDC trust.
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: node scripts/publish-npm.mjs
- name: Create or update GitHub release from changelog
if: env.DRY_RUN != 'true'
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_TITLE: ${{ steps.release.outputs.title }}
RELEASE_TAG: ${{ steps.release.outputs.tag }}
run: |
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
gh release edit "$RELEASE_TAG" --title "$RELEASE_TITLE" --notes-file release/release-notes.md
else
gh release create "$RELEASE_TAG" --verify-tag --title "$RELEASE_TITLE" --notes-file release/release-notes.md
fi
gh release upload "$RELEASE_TAG" release/*.tgz --clobber
- name: Summarize release
env:
RELEASE_TAG: ${{ steps.release.outputs.tag }}
run: |
if [ "$DRY_RUN" = true ]; then
echo 'Dry run passed. Review the npm-release artifact. No package or GitHub Release was published.' >> "$GITHUB_STEP_SUMMARY"
else
echo "Published $RELEASE_TAG from its public source and updated the GitHub Release." >> "$GITHUB_STEP_SUMMARY"
fi