diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e8ec3dfd..4a3c5468 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,34 +3,52 @@ name: Release on: release: types: [published] + workflow_dispatch: jobs: - PyPI: + pypi-build: runs-on: ubuntu-latest + steps: - uses: actions/checkout@v5 - uses: actions/setup-python@v6 with: python-version: "3.x" - - run: python -m pip install --upgrade pip build wheel twine - - name: Build dist packages - run: python -m build --sdist --wheel - - run: python -m twine upload dist/* - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + - run: python -m pip install --upgrade pip build wheel + - run: python -m build --sdist --wheel + - uses: actions/upload-artifact@v4 + with: + name: release-dists + path: dist/ - npm: + pypi-publish: runs-on: ubuntu-latest + needs: + - release-build + permissions: + id-token: write + + steps: + - uses: actions/download-artifact@v5 + with: + name: release-dists + path: dist/ + - uses: pypa/gh-action-pypi-publish@release/v1 + + npmjs: + name: npmjs.org + runs-on: ubuntu-latest + permissions: + id-token: write steps: - uses: actions/checkout@v5 - uses: actions/setup-node@v6 - - uses: actions/setup-python@v6 with: - python-version: "3.x" - - run: python -m pip install --upgrade setuptools_scm - - run: python set_version.py - - name: Upload packages - run: npm publish - env: - NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + node-version-file: .nvmrc + registry-url: 'https://registry.npmjs.org' + - run: npm install -g npm@latest + - run: npm ci + - run: npm config set git-tag-version=false + - run: npm version ${{ github.event.release.tag_name }} + - run: npm run build --if-present + - run: npm publish diff --git a/set_version.py b/set_version.py deleted file mode 100755 index fa18ce33..00000000 --- a/set_version.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python3 -"""Set the version in NPM's package.json to match the git tag.""" -import json - -from setuptools_scm import get_version - -if __name__ == "__main__": - with open("package.json", "r+") as f: - data = json.load(f) - f.seek(0) - data["version"] = get_version(root=".", relative_to=__file__) - json.dump(data, f) - f.truncate()