From 96e9c7c3b03918b876bb1996f22ba24a0789f0da Mon Sep 17 00:00:00 2001 From: Nathan Drezner Date: Tue, 11 Feb 2025 11:28:11 -0500 Subject: [PATCH] Manage NPM packages properly --- .github/workflows/build.yml | 20 ++++++++++++++++---- .github/workflows/publish-to-pypi.yml | 18 +++++++++++++++--- .github/workflows/release.yml | 13 +++++++++---- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d0c5429..5814657 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,11 +36,17 @@ jobs: source .venv/bin/activate npm run build shell: bash - - name: Generate distribution + - name: Generate Python distribution run: | source .venv/bin/activate npm run dist - npm pack && mv *.tgz dist/ + shell: bash + - name: Build npm package + run: | + source .venv/bin/activate + npm pack + mkdir -p npm-dist + mv *.tgz npm-dist/ shell: bash - name: Validate distribution run: | @@ -50,8 +56,14 @@ jobs: uv pip install "${WHL_FILE}[dev]" npm run test shell: bash - - name: Upload built distributions + - name: Upload Python distributions uses: actions/upload-artifact@v4 with: - name: package-distributions + name: python-distributions path: dist/ + + - name: Upload npm package + uses: actions/upload-artifact@v4 + with: + name: npm-package + path: npm-dist/ \ No newline at end of file diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 0b5349d..3bfb03f 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -23,12 +23,24 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - name: Download built distributions + - name: Download Python distributions uses: actions/download-artifact@v4 with: - name: package-distributions + name: python-distributions path: dist/ - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file + password: ${{ secrets.PYPI_API_TOKEN }} + + - name: Download npm package + uses: actions/download-artifact@v4 + with: + name: npm-package + path: npm-dist/ + - name: Publish to npm + run: | + npm publish npm-dist/*.tgz --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + shell: bash \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 27c3cef..92a53f5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,13 +21,18 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v4 - - name: Download built distributions + - name: Download Python distributions uses: actions/download-artifact@v4 with: - name: package-distributions + name: python-distributions path: dist/ + - name: Download npm package + uses: actions/download-artifact@v4 + with: + name: npm-package + path: npm-dist/ - name: Upload GitHub Release uses: ncipollo/release-action@v1 with: - artifacts: "dist/*.whl,dist/*.tar.gz" - draft: true \ No newline at end of file + artifacts: "dist/*.whl,dist/*.tar.gz,npm-dist/*.tgz" + draft: true \ No newline at end of file