From 182314c0f6b1bbd27c68848f124257eaa12c0597 Mon Sep 17 00:00:00 2001 From: Shibo Lyu Date: Sun, 5 May 2024 12:03:02 +0800 Subject: [PATCH] chore: publish on both jsr & npm (0.1.2) --- .github/workflows/publish_npm.yml | 27 +++++++++++++++++++++++++++ deno.json | 2 +- scripts/build_npm.ts | 4 +++- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/publish_npm.yml diff --git a/.github/workflows/publish_npm.yml b/.github/workflows/publish_npm.yml new file mode 100644 index 0000000..eecb58c --- /dev/null +++ b/.github/workflows/publish_npm.yml @@ -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 }} diff --git a/deno.json b/deno.json index 2bfd7fc..9ed1c44 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@textplace/core", - "version": "0.1.1", + "version": "0.1.2", "exports": "./mod.ts", "imports": { "@deno/dnt": "jsr:@deno/dnt@^0.41.1" diff --git a/scripts/build_npm.ts b/scripts/build_npm.ts index a218df1..c1a13f2 100644 --- a/scripts/build_npm.ts +++ b/scripts/build_npm.ts @@ -1,5 +1,7 @@ import { build, emptyDir } from "@deno/dnt"; +import denoJson from "../deno.json" with { type: "json" }; + await emptyDir("./npm"); await build({ @@ -12,7 +14,7 @@ await build({ package: { // package.json properties name: "@textplace/core", - version: Deno.args[0], + version: denoJson.version, description: "The core logic of TextPlace.", license: "MIT", repository: {