diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..649bc18 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,26 @@ +# workflow follows example in +# https://docs.github.com/en/actions/tutorials/publish-packages/publish-nodejs-packages#publishing-packages-to-the-npm-registry +name: Publish Package to npmjs +on: + release: + types: [published] +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v5 + # Setup .npmrc file to publish to npm + - uses: actions/setup-node@v4 + with: + node-version: "20.x" + registry-url: "https://registry.npmjs.org" + - run: npm ci + - run: npm run build + + # https://docs.npmjs.com/cli/v11/commands/npm-publish + - run: npm publish --provenance --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/README.md b/README.md index d1911ca..5f5c46e 100644 --- a/README.md +++ b/README.md @@ -48,3 +48,16 @@ Then open `example/index.html` for a simple example. MIT © Imperial College of Science, Technology and Medicine Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms. + +## Publishing to NPM + +Automatically publish to [NPM](https://www.npmjs.com). Assuming a version number 1.0.0: + +* Create a [release on github](https://github.com/reside-ic/dfoptim/releases/new) +* Choose a tag -> Create a new tag: v1.0.0 +* Use this version as the description +* Optionally describe the release +* Click "Publish release" +* This triggers the release workflow and the package will be available on NPM in a few minutes + +Note: This package's name on NPM is `@reside-ic/dfoptim` not `dfoptim`. diff --git a/package.json b/package.json index 3f00250..fa739a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "dfoptim", - "version": "0.0.6", + "name": "@reside-ic/dfoptim", + "version": "1.0.0", "description": "Derivative-Free Optimisation", "main": "lib/index.js", "types": "lib/index.d.ts",