chore: publish on both jsr & npm (0.1.2)

This commit is contained in:
Shibo Lyu 2024-05-05 12:03:02 +08:00
parent 1bff47e2a3
commit 182314c0f6
3 changed files with 31 additions and 2 deletions

27
.github/workflows/publish_npm.yml vendored Normal file
View file

@ -0,0 +1,27 @@
name: Publish Package to npmjs
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"
- name: Setup Deno
# uses: denoland/setup-deno@v1
uses: denoland/setup-deno@61fe2df320078202e33d7d5ad347e7dcfa0e8f31 # v1.1.2
with:
deno-version: v1.x
- run: deno run -A scripts/build_npm.ts
- run: npm install -g npm
- run: cd npm && npm ci
- run: cd npm && npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

View file

@ -1,6 +1,6 @@
{ {
"name": "@textplace/core", "name": "@textplace/core",
"version": "0.1.1", "version": "0.1.2",
"exports": "./mod.ts", "exports": "./mod.ts",
"imports": { "imports": {
"@deno/dnt": "jsr:@deno/dnt@^0.41.1" "@deno/dnt": "jsr:@deno/dnt@^0.41.1"

View file

@ -1,5 +1,7 @@
import { build, emptyDir } from "@deno/dnt"; import { build, emptyDir } from "@deno/dnt";
import denoJson from "../deno.json" with { type: "json" };
await emptyDir("./npm"); await emptyDir("./npm");
await build({ await build({
@ -12,7 +14,7 @@ await build({
package: { package: {
// package.json properties // package.json properties
name: "@textplace/core", name: "@textplace/core",
version: Deno.args[0], version: denoJson.version,
description: "The core logic of TextPlace.", description: "The core logic of TextPlace.",
license: "MIT", license: "MIT",
repository: { repository: {