Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Publish to NPM

on:
workflow_dispatch:
inputs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imho it's less work to just read version from package.json, instead of committing it. And it's more intuitive approach, ie it is package.json which is golden source of version, instead of relying on developer putting some version here. We can then get rid out of this input, and instead make input like ref (see here https://github.com/Cardinal-Cryptography/blanksquare-monorepo/blob/main/.github/workflows/_build-enclave-artifacts.yml#L7-L10), so that one can put as this ref SHA or some git tag.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, version should be hardcoded into package.json. (it already is)

ref:
description: 'git ref: hash, branch, tag to publish from'
type: string
required: true
default: 'main'
tag:
description: "NPM tag"
required: true
type: choice
options:
- develop
- latest
default: 'latest'

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '23'
registry-url: 'https://registry.npmjs.org'

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: latest

- name: Install dependencies
run: pnpm install

- name: Build the library
run: pnpm --filter ./ts/lib... build

- name: Display version
working-directory: ./ts/lib
run: echo "Publishing version $(node -p "require('./package.json').version")"

- name: Publish to NPM
working-directory: ./ts/lib
run: npm publish --access public --tag ${{ github.event.inputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion ts/lib/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@cardinal-cryptography/ecies-encryption-lib",
"author": "CardinalCryptography",
"version": "1.0.0",
"version": "0.1.6",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down