chore: publish on npm

This commit is contained in:
Shibo Lyu 2024-09-26 01:48:16 +08:00
parent 3eabba3466
commit 1281fe32da
5 changed files with 53 additions and 21 deletions

View file

@ -1,16 +0,0 @@
name: Publish on JSR
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # The OIDC ID token is used for authentication with JSR.
steps:
- uses: actions/checkout@v4
- run: npx jsr publish

36
.github/workflows/publish.yml vendored Normal file
View file

@ -0,0 +1,36 @@
name: Publish on JSR & npm
on:
workflow_run:
workflows: [Deno]
types: [completed]
branches: [main]
jobs:
publish:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
contents: read
id-token: write # The OIDC ID token is used for authentication with JSR.
steps:
- name: Setup Deno
uses: denoland/setup-deno@61fe2df320078202e33d7d5ad347e7dcfa0e8f31 # v1.1.2
with:
deno-version: v1.x
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- name: Checkout repo
uses: actions/checkout@v4
- name: Build & test npm package
run: deno task build:npm
- name: Publish to JSR
run: npx jsr publish
- name: Publish to npm
run: |
cd npm
npx is-published@0.2.0 || npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
npm

View file

@ -12,7 +12,7 @@
"zod": "npm:zod@^3.23.8"
},
"tasks": {
"build:npm": "deno run ./scripts/build_npm.ts"
"build:npm": "deno run -A ./scripts/build_npm.ts"
},
"publish": {
"include": ["LICENSE", "README.md", "crypto", "identity"],

View file

@ -1,18 +1,29 @@
import { build, emptyDir } from "@deno/dnt";
import denoJson from "../deno.json" with { type: "json" };
await emptyDir("./npm");
await build({
entryPoints: ["./mod.ts"],
entryPoints: [
{ name: "./crypto", path: "crypto/mod.ts" },
{ name: "./identity", path: "identity/mod.ts" },
],
outDir: "./npm",
importMap: "deno.json",
compilerOptions: {
lib: ["ESNext", "DOM"],
},
shims: {
// see JS docs for overview and more options
deno: true,
deno: {
test: "dev",
},
crypto: true,
webSocket: true,
},
package: {
// package.json properties
name: "@blah-im/core",
version: Deno.args[0],
version: denoJson.version,
description: "Core logic & types for Blah IM.",
license: "GPL-3.0-only",
repository: {