CoreTextPlace/.github/workflows/publish_jsr.yml
laosb b51545ab39 fix: Strip JSR deps before publishing and add deno.json
JSR itself does not accept 'jsr:' dependencies in package.json, remove
them in the publish workflow before publishing. Add $schema to jsr.json.
2025-11-30 10:28:57 +08:00

52 lines
1.4 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
run: pnpm dlx jsr publish