Skip to content

add github action to publish to npm if version updated in package.json #38

@hanayik

Description

@hanayik

Adding a github action to automatically publish to NPM would be convenient. @neurolabusc , leave this to me. It will be a useful addition, and can potentially apply to some other repos we work with. These are my notes for later.

The same pixi-based github action can also be used to build and publish the conda package (in combination with rattler-build). It would help #33. Note that the conda package would just include the compiled exe, not the wasm package. The wasm package would be published to npm.

This would allow cross platform use of niimath for anyone using conda. This would be great for scientific reproducibility where package managers are used to install analysis environments using conda-forge channels.

I would also recommend that we switch to using sem-ver versioning if we publish niimath to conda-forge. While Date-based versions like 1.0.20241212 do work, they don't convey the same info to downstream developers who rely on version pinning mechanisms.

Steps required for wasm package publishing to npm:

  • setup NPM token as a github secret
  • use a pixi github action
  • install emscripten conda install conda-forge::emscripten (or setup pixi.toml)
  • check version in package.json current_version=$(node -p "require('./package.json').version")
  • check latest version available on npm published_version=$(npm view @niivue/niimath version)
  • check if current_version equals published_version is_latest=$([ "$current_version" = "$published_version" ] && echo 1 || echo 0)
  • use these values in a github action workflow to determine if the NPM package should be built and published

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions