ci: automate npm publish (#305)

Add a workflow that performs the publishing when a new Git tag is
pushed.
development
Thomas Bouffard 2024-01-14 16:28:29 +01:00 committed by GitHub
parent eb1e866ede
commit 41a3fbfd55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 0 deletions

View File

@ -1,6 +1,11 @@
name: 'Build Setup'
description: 'Setup node and install dependencies'
inputs:
registry-url:
description: 'Optional registry to set up for auth.'
required: false
runs:
using: 'composite'
steps:
@ -8,6 +13,7 @@ runs:
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: ${{ inputs.registry-url }}
- name: Install dependencies
uses: bahmutov/npm-install@v1
with:

View File

@ -0,0 +1,22 @@
name: Publish NPM Package
on:
push:
tags:
- v*
jobs:
build:
runs-on: ubuntu-22.04
permissions:
# required for "npm provenance"
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
- name: Build Setup
uses: ./.github/actions/build-setup
with:
registry-url: 'https://registry.npmjs.org'
# scoped package requires "access=public"
- run: npm publish -w packages/core --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

View File

@ -56,6 +56,9 @@ git tag v0.2.0
## Publish the npm package
The package is published automatically once the Git tag is pushed thanks to a [GitHub workflow](https://github.com/maxGraph/maxgraph-integration-examples/actions/workflows/publish-npm-package.yml).
If its execution fails, and you want to publish the package manually:
- Checkout the tag that has just been created
- From packages/core:
- run `npm publish`