From aec255ede1bb279a14f4b95ce87b7c7959b5c149 Mon Sep 17 00:00:00 2001 From: Jason Reed Date: Sat, 23 Mar 2024 13:30:17 -0400 Subject: [PATCH] Automate npm publish - Also replace `npm i` with `npm ci` in other workflow targets. - Also fix `README.md` being accidentally published as npm package `README.md`. --- .github/workflows/publish.yml | 30 ++++++++++++++++++++++++++++++ .github/workflows/run-tests.yml | 2 +- .github/workflows/static.yml | 2 +- Makefile | 3 ++- README.npm-lib.md | 8 ++++++++ package.json | 7 ++----- 6 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 README.npm-lib.md diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..58dbcc2 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,30 @@ +# Simple workflow for deploying static content to GitHub Pages +name: Publish NPM package + +on: + # Runs on pushes targeting the deploy branch + push: + branches: ["publish"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: 18.x + registry-url: 'https://registry.npmjs.org' + - name: Install node modules + run: npm ci + + - name: Build + env: + NPM_AUTH_TOKEN: "${{ secrets.NPM_PUBLISH_TOKEN }}" + run: make ci-publish diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ac380f9..acbbe8f 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -20,4 +20,4 @@ jobs: node-version: 18.x - name: Run tests - run: npm install && npx jest + run: npm ci && npx jest diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 4da22c9..6a53756 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -37,7 +37,7 @@ jobs: node-version: 18.x - name: Install node modules - run: npm i + run: npm ci - name: Build run: make build diff --git a/Makefile b/Makefile index 7d629f0..a8e370e 100644 --- a/Makefile +++ b/Makefile @@ -28,8 +28,9 @@ test: npm run test-watch # publish to npm -publish: +ci-publish: make build-lib + mv README.npm-lib.md README.md npm run test npm publish diff --git a/README.npm-lib.md b/README.npm-lib.md new file mode 100644 index 0000000..f4d5034 --- /dev/null +++ b/README.npm-lib.md @@ -0,0 +1,8 @@ +Twelf on Wasm Support +===================== + +What we publish as an npm library as package `twelf-wasm` is just a +small library. The intended use is for libary users (specifically the +Twelf wiki) to conveniently construct url-fragment arguments with the +`encode` function so that they can link to twelf-wasm and have it load +a particular bit of twelf code at startup. diff --git a/package.json b/package.json index 2f63179..2ba3d6b 100644 --- a/package.json +++ b/package.json @@ -4,16 +4,13 @@ "require": "./lib/encoding.cjs" }, "types": "lib/encoding.d.ts", - "version": "0.1.2", + "version": "0.1.3", "description": "Running Twelf as a webassembly binary in a web page", "homepage": "https://jcreedcmu.github.io/twelf-wasm/", "bugs": { "url": "https://github.com/jcreedcmu/twelf-wasm/issues" }, - "repository": { - "type": "git", - "url": "https://github.com/jcreedcmu/twelf-wasm" - }, + "repository": "git://github.com/jcreedcmu/twelf-wasm.git", "engines" : { "node" : ">=18.0.0" },