Release #17
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - "v[0-9]+.[0-9]+.[0-9]+" | |
| jobs: | |
| test: | |
| uses: ./.github/workflows/test.yml | |
| # Verify the tag version matches Cargo.toml before publishing anything | |
| verify: | |
| name: Verify version | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check tag matches workspace version | |
| run: | | |
| TAG="${GITHUB_REF_NAME#v}" | |
| CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/') | |
| if [ "$TAG" != "$CARGO_VERSION" ]; then | |
| echo "Tag v$TAG does not match Cargo.toml version $CARGO_VERSION" | |
| exit 1 | |
| fi | |
| crates-io: | |
| name: Publish to crates.io | |
| needs: verify | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - run: cargo publish -p nj --token ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| pypi-build: | |
| name: Build wheels (${{ matrix.target }}) | |
| needs: verify | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64 | |
| manylinux: auto | |
| - os: ubuntu-latest | |
| target: aarch64 | |
| manylinux: auto | |
| - os: macos-latest | |
| target: universal2-apple-darwin | |
| - os: windows-latest | |
| target: x86_64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: cp README.md python/README.md | |
| - uses: actions/setup-python@v5 | |
| with: | |
| # One Python is enough to *find* an interpreter, but for wheels you | |
| # generally want to build multiple; see args below. | |
| python-version: "3.12" | |
| - uses: PyO3/maturin-action@v1 | |
| with: | |
| command: build | |
| # Explicitly provide interpreters so maturin doesn't have to discover them. | |
| args: > | |
| --release | |
| --out dist | |
| -i python3.10 | |
| -i python3.11 | |
| -i python3.12 | |
| target: ${{ matrix.target }} | |
| manylinux: ${{ matrix.manylinux }} | |
| working-directory: python | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{matrix.os}}-${{ matrix.target }} | |
| path: python/dist | |
| pypi-sdist: | |
| name: Build sdist | |
| needs: verify | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: cp README.md python/README.md | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - uses: PyO3/maturin-action@v1 | |
| with: | |
| command: sdist | |
| args: --out dist | |
| working-directory: python | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: sdist | |
| path: python/dist | |
| pypi-publish: | |
| name: Publish to PyPI | |
| needs: [pypi-build, pypi-sdist] | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/nj_py | |
| permissions: | |
| id-token: write # required for OIDC trusted publishing | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: wheels-* | |
| merge-multiple: true | |
| path: dist | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: sdist | |
| path: dist | |
| - uses: pypa/gh-action-pypi-publish@release/v1 | |
| github-release: | |
| name: Create GitHub release | |
| needs: [crates-io, pypi-publish, npm] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Extract version | |
| id: version | |
| run: echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT | |
| - uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true | |
| body: | | |
| | Registry | Package | | |
| |----------|---------| | |
| | crates.io | https://crates.io/crates/nj/${{ steps.version.outputs.version }} | | |
| | PyPI | https://pypi.org/project/nj_py/${{ steps.version.outputs.version }}/ | | |
| | npm | https://www.npmjs.com/package/@holmrenser/nj/v/${{ steps.version.outputs.version }} | | |
| npm: | |
| name: Publish to npm | |
| needs: verify | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write # required for OIDC trusted publishing | |
| contents: read # required to checkout code | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: wasm -> wasm/target | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| registry-url: https://registry.npmjs.org | |
| - run: cp README.md wasm/README.md | |
| - run: npm ci | |
| working-directory: wasm | |
| - run: CARGO_TARGET_DIR=target npm run build | |
| working-directory: wasm | |
| - run: npm publish --access public --provenance | |
| working-directory: wasm |