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
18 changes: 11 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ jobs:
- name: Run tests
run: deno task test

- name: Publish to JSR
run: deno publish

# No npm/JSR publish rights required from here on - this only needs push access to this
# repo's own npm-dist branch, which the default GITHUB_TOKEN already has via the
# `contents: write` permission above. Consumers add it as a git dependency instead of a
# registry one, e.g. "grud-devtools": "git+https://github.com/campudus/grud-devtools.git#npm-dist".
# Runs before "Publish to JSR" on purpose: a failed step aborts every step after it in the
# same job (no guard/continue-on-error was in place), which is exactly what silently skipped
# both of these the first time around when deno publish failed. Building/pushing npm-dist
# first means it always happens regardless of whether the JSR publish succeeds - it only
# needs push access to this repo's own npm-dist branch, which the default GITHUB_TOKEN
# already has via the `contents: write` permission above, no npm/JSR publish rights at all.
# Consumers add it as a git dependency instead of a registry one, e.g.
# "grud-devtools": "git+https://github.com/campudus/grud-devtools.git#npm-dist".
- name: Build npm package with dnt
run: deno run -A scripts/build_npm.ts

Expand All @@ -57,3 +58,6 @@ jobs:
-c user.email="github-actions[bot]@users.noreply.github.com" \
commit -q -m "npm-dist: ${{ github.sha }}"
git push -f "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" npm-dist:npm-dist

- name: Publish to JSR
run: deno publish
10 changes: 10 additions & 0 deletions scripts/build_npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ await build({
dependencies: {
ramda: "^0.30.1",
},
// dnt's own type-check pass (below) runs npm install inside ./outDir first, then relies on
// TypeScript's automatic @types/ resolution against whatever ended up in that node_modules -
// it does not fall back to any ambient types from outside that directory. Without these two,
// that check fails on `ramda` having no bundled types and on `console` (a Node global that
// only exists once @types/node's ambient declarations are present), even though nothing here
// is Deno-specific - see jsr.io/@deno/dnt/0.41.3/mod.ts's getProgramAndMaybeTypeCheck.
devDependencies: {
"@types/ramda": "^0.30.1",
"@types/node": "^20.11.0",
},
},
postBuild() {
Deno.copyFileSync("LICENSE", "npm/LICENSE");
Expand Down
Loading