Skip to content
Open
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
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,42 @@ jobs:
name: dist
path: dist/
retention-days: 7

modelparams-pkg:
name: modelparams package (codegen + build + tests)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Codegen
run: npm run codegen --workspace=modelparams

- name: Verify generated files are in sync
run: |
if ! git diff --quiet -- packages/modelparams/src/generated; then
echo "::error::Generated files in packages/modelparams/src/generated are out of date."
echo "Run \`npm run codegen --workspace=modelparams\` locally and commit the result."
git diff --stat -- packages/modelparams/src/generated
exit 1
fi

- name: Typecheck package
run: npm run typecheck --workspace=modelparams

- name: Build package
run: npm run build --workspace=modelparams

- name: Runtime tests
run: npm test --workspace=modelparams

- name: Type-level tests (tsd)
run: npm run test:types --workspace=modelparams
137 changes: 137 additions & 0 deletions .github/workflows/release-modelparams.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Release modelparams

# Publishes the `modelparams` npm package when the catalog or codegen pipeline
# changes on main. Versioning is driven by the same diff classifier
# (`findRemovedParams`) that `param-guard.yml` uses on PRs:
# • any param removed on a still-existing model → MAJOR
# • any other catalog change → PATCH
# • no semantic catalog change → skipped
#
# Provenance: signed via npm OIDC. Configure a trusted publisher for the
# `modelparams` package on npmjs.com (Settings → Trusted Publishers → GitHub
# Actions → org=mnfst, repo=modelparams.dev, workflow=release-modelparams.yml).
# Once configured, `NPM_TOKEN` is no longer needed.

on:
push:
branches: [main]
paths:
- "models/**"
- "packages/modelparams/**"
- "src/schema/model.ts"
- "src/data/load.ts"
- "src/data/removals.ts"
- "src/data/git-baseline.ts"
- ".github/workflows/release-modelparams.yml"
workflow_dispatch:
inputs:
force_level:
description: "Force bump level (overrides auto-detect)"
required: false
type: choice
options: ["", "patch", "major"]
default: ""

concurrency:
group: release-modelparams
cancel-in-progress: false

jobs:
publish:
name: Build and publish
runs-on: ubuntu-latest
permissions:
contents: write # tag + auto-bump commit
id-token: write # npm OIDC provenance
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # full history for diff-based version bump

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
run: npm ci

- name: Validate catalog
run: npm run validate

- name: Typecheck (root)
run: npm run typecheck

- name: Codegen
run: npm run codegen --workspace=modelparams

- name: Build package
run: npm run build --workspace=modelparams

- name: Runtime tests
run: npm test --workspace=modelparams

- name: Type-level tests (tsd)
run: npm run test:types --workspace=modelparams

- name: Compute next version
id: bump
run: npx tsx packages/modelparams/scripts/compute-version.ts
env:
BASE_REF: "HEAD~1"

- name: Apply forced level (workflow_dispatch)
if: github.event_name == 'workflow_dispatch' && inputs.force_level != ''
id: force
run: |
CURRENT=$(node -p "require('./packages/modelparams/package.json').version")
case "${{ inputs.force_level }}" in
major) NEXT=$(node -e "const [M]=process.argv[1].split('.');console.log(\`\${+M+1}.0.0\`)" "$CURRENT");;
patch) NEXT=$(node -e "const [M,m,p]=process.argv[1].split('.');console.log(\`\${M}.\${m}.\${+p+1}\`)" "$CURRENT");;
esac
echo "level=${{ inputs.force_level }}" >> "$GITHUB_OUTPUT"
echo "next=$NEXT" >> "$GITHUB_OUTPUT"

- name: Resolve effective version
id: resolved
run: |
LEVEL="${{ steps.force.outputs.level || steps.bump.outputs.level }}"
NEXT="${{ steps.force.outputs.next || steps.bump.outputs.next }}"
echo "level=$LEVEL" >> "$GITHUB_OUTPUT"
echo "next=$NEXT" >> "$GITHUB_OUTPUT"

- name: Skip publish (no semantic change)
if: steps.resolved.outputs.next == ''
run: echo "::notice::No semantic catalog change since HEAD~1 — nothing to publish."

- name: Bump package.json + commit + tag
if: steps.resolved.outputs.next != ''
env:
NEXT: ${{ steps.resolved.outputs.next }}
run: |
cd packages/modelparams
npm version "$NEXT" --no-git-tag-version
cd ../..
git config user.name "modelparams-bot"
git config user.email "bot@modelparams.dev"
git add packages/modelparams/package.json packages/modelparams/src/generated
git commit -m "release: modelparams@$NEXT"
git tag "modelparams@$NEXT"
git push origin HEAD:main --follow-tags

- name: Publish to npm
if: steps.resolved.outputs.next != ''
run: npm publish --workspace=modelparams --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create GitHub release
if: steps.resolved.outputs.next != ''
uses: softprops/action-gh-release@v2
with:
tag_name: "modelparams@${{ steps.resolved.outputs.next }}"
name: "modelparams@${{ steps.resolved.outputs.next }}"
generate_release_notes: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
node_modules/
/dist/
/build/
packages/*/dist/
packages/*/*.tsbuildinfo
.cache/
*.log
.DS_Store
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ build/
coverage/
*.min.js
*.min.css
packages/modelparams/src/generated/
packages/*/dist/
Loading
Loading