From 0f29716a17550bf9fed965a43242cd9778c2e381 Mon Sep 17 00:00:00 2001 From: Mantra Date: Thu, 25 Sep 2025 12:40:30 +0100 Subject: [PATCH 1/5] add publishing workflow and change package name --- .github/workflows/publish.yml | 24 ++++++++++++++++++++++++ package.json | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..1104b12 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,24 @@ +name: Publish Package to npmjs +on: + release: + types: [published] + pull_request: + branch: npm-publish-on-release +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 + - run: npm publish --provenance --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 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", From b76ea4099be2756a1955fb813bb7f5dc120738e3 Mon Sep 17 00:00:00 2001 From: Mantra Date: Thu, 25 Sep 2025 13:50:22 +0100 Subject: [PATCH 2/5] remove tmp publish on current branch --- .github/workflows/publish.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1104b12..52d913f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,8 +2,6 @@ name: Publish Package to npmjs on: release: types: [published] - pull_request: - branch: npm-publish-on-release jobs: build: runs-on: ubuntu-latest From 6fd658f6fbe064aa75e26814bf8c1d67cc3b5b89 Mon Sep 17 00:00:00 2001 From: Mantra Date: Thu, 25 Sep 2025 14:08:37 +0100 Subject: [PATCH 3/5] add comments to github workflow and update readme to include instructions for publishing --- .github/workflows/publish.yml | 4 ++++ README.md | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 52d913f..649bc18 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,3 +1,5 @@ +# 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: @@ -17,6 +19,8 @@ jobs: 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..78143fc 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 +* 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` after migration to `reside-ic` org. From b07e955e7c3ede02bfe97ae4290d9c25b04edf77 Mon Sep 17 00:00:00 2001 From: Mantra Date: Thu, 25 Sep 2025 14:10:17 +0100 Subject: [PATCH 4/5] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 78143fc..c216c5b 100644 --- a/README.md +++ b/README.md @@ -60,4 +60,4 @@ Automatically publish to [NPM](https://www.npmjs.com). Assuming a version number * 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` after migration to `reside-ic` org. +Note: This package's name on NPM is `@reside-ic/dfoptim` not `dfoptim`. From 344ed2a86931a30e7b2b00deee51f05dbf27781e Mon Sep 17 00:00:00 2001 From: Mantra Date: Thu, 25 Sep 2025 14:14:56 +0100 Subject: [PATCH 5/5] add link to creating release --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c216c5b..5f5c46e 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Please note that this project is released with a [Contributor Code of Conduct](C Automatically publish to [NPM](https://www.npmjs.com). Assuming a version number 1.0.0: -* Create a release on github +* 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