CoreTextPlace/.github/workflows/publish_jsr.yml
laosb cfe0fb1514 fix: Use --allow-dirty for jsr publish
Allow publishing when package.json is modified earlier in the workflow
2025-11-30 10:33:38 +08:00

53 lines
1.5 KiB
YAML

name: Publish on JSR
on:
workflow_run:
workflows: ["Test"]
types: [completed]
branches:
- "main"
jobs:
publish:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- name: Setup repo
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: "24.x"
cache: "pnpm"
- name: Install dependencies
run: pnpm install
# This step removes JSR dependencies from package.json before publishing,
# Because apparently now while major npm compatible package managers
# support JSR dependencies in package.json, JSR itself does not.
- name: Remove JSR deps from package.json
run: |
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
for (const dep in pkg.dependencies ?? {}) {
if (pkg.dependencies[dep].startsWith('jsr:')) {
delete pkg.dependencies[dep];
}
}
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
"
- name: Publish to JSR
# Have to use --allow-dirty because we modified package.json in the previous step
run: pnpm dlx jsr publish --allow-dirty