Skip to content

Commit

Permalink
chore(github): publish NPM package automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
jbms committed Feb 24, 2024
1 parent dd15d7e commit 3b04a58
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
26 changes: 25 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,20 @@ jobs:
run: npm run build -- --no-typecheck --no-lint
- name: Build Python client bundles
run: npm run build-python -- --no-typecheck --no-lint
- run: npm run build-package
- run: npm publish --dry-run
working-directory: dist/package
- uses: ./.github/actions/setup-firefox
- name: Run JavaScript tests (including WebGL)
run: npm test
- name: Run JavaScript benchmarks
run: npm run benchmark
- name: Upload NPM package as artifact
uses: actions/upload-artifact@v4
with:
name: npm-package
path: dist/package
if: ${{ runner.os == 'Linux' }}

# Builds Python package and runs Python tests
#
Expand Down Expand Up @@ -152,18 +161,28 @@ jobs:
dist/*.whl
dist/*.tar.gz
python-publish-package:
publish-package:
# Only publish package on push to tag or default branch.
if: ${{ github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master') }}
runs-on: ubuntu-latest
needs:
- "client"
- "python-build-package"
steps:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: "https://registry.npmjs.org"
- uses: actions/download-artifact@v4
with:
pattern: python-wheels-*
path: dist
merge-multiple: true
- uses: actions/download-artifact@v4
with:
name: npm-package
path: npm-package
# - name: Publish to PyPI (test server)
# uses: pypa/gh-action-pypi-publish@54b39fb9371c0b3a6f9f14bb8a67394defc7a806 # 2020-09-25
# with:
Expand All @@ -175,6 +194,11 @@ jobs:
user: __token__
password: ${{ secrets.pypi_token }}
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Publish to NPM registry
run: npm publish
working-directory: npm-package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
ngauth:
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion build_tools/build-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async function buildPackage(options: { inplace?: boolean }) {
packageJson["scripts"] = { postpack };
} else {
delete packageJson["private"];
delete packageJson["scripts"];
packageJson["scripts"] = {};
delete packageJson["files"];
}

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"test:watch": "vitest watch",
"benchmark": "vitest bench --run",
"benchmark:watch": "vitest bench",
"prepublishOnly": "npm run test && npm run build-module",
"lint:check": "eslint .",
"lint:fix": "eslint . --fix",
"format:check": "prettier --cache . -c",
Expand Down Expand Up @@ -73,7 +72,7 @@
"codemirror": "^5.61.1",
"gl-matrix": "3.1.0",
"glsl-editor": "^1.0.0",
"ikonate": "mikolajdobrucki/ikonate#a86b4107c6ec717e7877f880a930d1ccf0b59d89",
"ikonate": "github:mikolajdobrucki/ikonate#a86b4107c6ec717e7877f880a930d1ccf0b59d89",
"lodash-es": "^4.17.21",
"nifti-reader-js": "^0.6.8",
"numcodecs": "^0.3.1",
Expand Down

0 comments on commit 3b04a58

Please sign in to comment.