Merge pull request #59 from relateby/release/v0.3.0 #11
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: Publish | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: read | |
| jobs: | |
| validate: | |
| name: Validate Release | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.verify.outputs.version }} | |
| tag: ${{ steps.verify.outputs.tag }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| fetch-depth: 0 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy, rustfmt | |
| targets: wasm32-unknown-unknown | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: package-lock.json | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.12' | |
| - uses: astral-sh/setup-uv@v6 | |
| - name: Install release tooling | |
| run: | | |
| cargo install wasm-pack | |
| pip install maturin twine | |
| - name: Verify stable tag on main | |
| id: verify | |
| run: bash scripts/release/verify-tag.sh "${GITHUB_REF_NAME}" "${GITHUB_SHA}" | |
| - name: Run release validation | |
| run: bash scripts/ci-local.sh --release | |
| publish-crates: | |
| name: Publish crates.io artifacts | |
| runs-on: ubuntu-latest | |
| needs: validate | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - uses: dtolnay/rust-toolchain@stable | |
| - name: Publish relateby-pattern | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| run: cargo publish -p relateby-pattern | |
| - name: Wait for crates.io indexing | |
| run: sleep 30 | |
| - name: Publish relateby-gram | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| run: cargo publish -p relateby-gram | |
| - name: Wait for crates.io indexing | |
| run: sleep 30 | |
| - name: Publish relateby-pato | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| run: cargo publish -p relateby-pato | |
| build-release-assets: | |
| name: Build GitHub Release assets | |
| runs-on: ${{ matrix.runner }} | |
| needs: validate | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runner: ubuntu-latest | |
| artifact_name: pato-linux-x86_64 | |
| archive_suffix: linux-x86_64 | |
| - runner: macos-latest | |
| artifact_name: pato-macos | |
| archive_suffix: macos | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt | |
| - name: Build release binary | |
| run: cargo build --release -p relateby-pato | |
| - name: Package release artifact | |
| env: | |
| RELEASE_VERSION: ${{ needs.validate.outputs.version }} | |
| ARCHIVE_SUFFIX: ${{ matrix.archive_suffix }} | |
| ARTIFACT_NAME: ${{ matrix.artifact_name }} | |
| run: | | |
| mkdir -p "target/release-assets/pato-${RELEASE_VERSION}-${ARCHIVE_SUFFIX}" | |
| cp "target/release/pato" "target/release-assets/pato-${RELEASE_VERSION}-${ARCHIVE_SUFFIX}/" | |
| cp "crates/pato/README.md" "target/release-assets/pato-${RELEASE_VERSION}-${ARCHIVE_SUFFIX}/" | |
| cp "LICENSE" "target/release-assets/pato-${RELEASE_VERSION}-${ARCHIVE_SUFFIX}/" | |
| tar -C target/release-assets -czf "target/pato-${RELEASE_VERSION}-${ARCHIVE_SUFFIX}.tar.gz" "pato-${RELEASE_VERSION}-${ARCHIVE_SUFFIX}" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact_name }} | |
| path: target/pato-${{ needs.validate.outputs.version }}-${{ matrix.archive_suffix }}.tar.gz | |
| publish-github-release: | |
| name: Publish GitHub Release | |
| runs-on: ubuntu-latest | |
| needs: [validate, publish-crates, publish-npm, publish-python, build-release-assets] | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: pato-linux-x86_64 | |
| path: target/release-assets/linux | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: pato-macos | |
| path: target/release-assets/macos | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| target/release-assets/linux/pato-${{ needs.validate.outputs.version }}-linux-x86_64.tar.gz | |
| target/release-assets/macos/pato-${{ needs.validate.outputs.version }}-macos.tar.gz | |
| generate_release_notes: true | |
| publish-npm: | |
| name: Publish npm artifacts | |
| runs-on: ubuntu-latest | |
| needs: validate | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| cache-dependency-path: package-lock.json | |
| - name: Update npm for trusted publishing | |
| run: npm install -g npm@latest | |
| - name: Install wasm-pack | |
| run: cargo install wasm-pack | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build npm artifacts | |
| run: | | |
| npm run build --workspace=@relateby/pattern | |
| npm run build --workspace=@relateby/graph | |
| npm run build --workspace=@relateby/gram | |
| - name: Publish @relateby/pattern | |
| run: npm publish --workspace=@relateby/pattern --access public --provenance | |
| - name: Publish @relateby/graph | |
| run: npm publish --workspace=@relateby/graph --access public --provenance | |
| - name: Publish @relateby/gram | |
| run: npm publish --workspace=@relateby/gram --access public --provenance | |
| publish-python: | |
| name: Publish combined Python artifact | |
| runs-on: ubuntu-latest | |
| needs: validate | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.12' | |
| - name: Install build tooling | |
| run: pip install maturin twine | |
| - name: Resolve Python package directory | |
| run: echo "PY_PACKAGE_DIR=python/packages/relateby" >> "$GITHUB_ENV" | |
| - name: Build combined wheel | |
| run: | | |
| cd "$PY_PACKAGE_DIR" | |
| python -m pip wheel . -w dist --no-deps | |
| - name: Publish relateby-pattern wheel | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: twine upload "$PY_PACKAGE_DIR"/dist/* | |
| verify-release: | |
| name: Verify published artifacts | |
| runs-on: ubuntu-latest | |
| needs: [validate, publish-crates, publish-npm, publish-python, publish-github-release] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20' | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.12' | |
| - name: Verify crates.io versions | |
| env: | |
| RELEASE_VERSION: ${{ needs.validate.outputs.version }} | |
| run: | | |
| python - <<'PY' | |
| import json | |
| import os | |
| import urllib.request | |
| version = os.environ["RELEASE_VERSION"] | |
| for crate in ("relateby-pattern", "relateby-gram", "relateby-pato"): | |
| with urllib.request.urlopen(f"https://crates.io/api/v1/crates/{crate}") as response: | |
| payload = json.load(response) | |
| versions = {item["num"] for item in payload.get("versions", [])} | |
| if version not in versions: | |
| raise SystemExit(f"{crate} version {version} not found on crates.io") | |
| PY | |
| - name: Verify npm versions | |
| env: | |
| RELEASE_VERSION: ${{ needs.validate.outputs.version }} | |
| run: | | |
| for package in @relateby/pattern @relateby/graph @relateby/gram; do | |
| test "$(npm view "${package}@${RELEASE_VERSION}" version)" = "${RELEASE_VERSION}" | |
| done | |
| - name: Verify PyPI install smoke test | |
| env: | |
| RELEASE_VERSION: ${{ needs.validate.outputs.version }} | |
| run: | | |
| python -m pip install "relateby-pattern==${RELEASE_VERSION}" | |
| python scripts/release/python-smoke.py --expect-distribution relateby-pattern |