Skip to content

JS publish to NPM

JS publish to NPM #3

Workflow file for this run

name: JS publish to NPM
env:
DEBUG: napi:*
APP_NAME: self-encryption
MACOSX_DEPLOYMENT_TARGET: '10.13'
permissions:
contents: write
id-token: write
on:
workflow_dispatch:
defaults:
run:
working-directory: ./nodejs/
jobs:
build-and-test:
# Build Node.js bindings for all platforms
uses: ./.github/workflows/nodejs.yml
publish:
name: Publish
runs-on: ubuntu-latest
needs:
- build-and-test
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 23
- run: corepack enable
- name: Get yarn cache directory path
id: yarn-cache-dir-path
shell: bash
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./nodejs/artifacts
- name: Move artifacts
run: yarn artifacts
- name: List packages
run: ls -R ./npm
shell: bash
- name: Publish
run: |
npm config set provenance true
yarn npm publish --tag latest --access public
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# docs:
# name: Build docs
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Setup node
# uses: actions/setup-node@v4
# with:
# node-version: 20
# cache: yarn
# cache-dependency-path: 'nodejs/yarn.lock'
# - name: Install dependencies
# run: yarn install
# - name: Build docs
# run: yarn docs --out docs/$(npm pkg get version | xargs)
# - name: Upload static files as artifact
# id: deployment
# uses: actions/upload-pages-artifact@v3
# with:
# path: ./nodejs/docs
# docs-deploy:
# name: Deploy docs on GitHub Pages
# needs: docs
# runs-on: ubuntu-latest
# permissions:
# pages: write
# id-token: write
# environment:
# name: github-pages
# url: ${{ steps.deployment.outputs.page_url }}
# steps:
# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v4