ci(release): mirror registry workflows to public (#246) #16
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 Python package | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: "Build and upload artifacts without publishing" | |
| required: true | |
| type: boolean | |
| default: true | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: release-pypi-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| metadata: | |
| name: validate package versions | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Python | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: "3.12" | |
| - name: Validate release metadata | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| python - <<'PY' | |
| import json | |
| import os | |
| import pathlib | |
| import tomllib | |
| root = pathlib.Path(".") | |
| cargo_lock = tomllib.loads((root / "Cargo.lock").read_text()) | |
| cargo_versions = { | |
| package["name"]: package["version"] | |
| for package in cargo_lock["package"] | |
| if package["name"] in {"rustwright-core", "rustwright-node"} | |
| } | |
| node_lock = json.loads((root / "node/package-lock.json").read_text()) | |
| versions = { | |
| "pyproject.toml": tomllib.loads((root / "pyproject.toml").read_text())["project"]["version"], | |
| "Cargo.toml": tomllib.loads((root / "Cargo.toml").read_text())["package"]["version"], | |
| "node/Cargo.toml": tomllib.loads((root / "node/Cargo.toml").read_text())["package"]["version"], | |
| "node/package.json": json.loads((root / "node/package.json").read_text())["version"], | |
| "Cargo.lock rustwright-core": cargo_versions["rustwright-core"], | |
| "Cargo.lock rustwright-node": cargo_versions["rustwright-node"], | |
| "node/package-lock.json": node_lock["version"], | |
| 'node/package-lock.json packages[""]': node_lock["packages"][""]["version"], | |
| } | |
| expected = next(iter(versions.values())) | |
| if any(version != expected for version in versions.values()): | |
| raise SystemExit(f"Package versions do not match: {versions}") | |
| if os.environ["GITHUB_REF_TYPE"] == "tag": | |
| tag_version = os.environ["GITHUB_REF_NAME"].removeprefix("v") | |
| if tag_version != expected: | |
| raise SystemExit( | |
| f"Tag version {tag_version!r} does not match package version {expected!r}" | |
| ) | |
| print(f"Validated package version {expected}") | |
| PY | |
| wheels: | |
| name: wheel - ${{ matrix.platform.target }} | |
| needs: metadata | |
| runs-on: ${{ matrix.platform.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - runner: macos-latest | |
| target: aarch64-apple-darwin | |
| manylinux: auto | |
| zig_target: "" | |
| extra_args: "" | |
| - runner: macos-latest | |
| target: x86_64-apple-darwin | |
| manylinux: auto | |
| zig_target: "" | |
| extra_args: "" | |
| - runner: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| manylinux: "2_17" | |
| zig_target: "" | |
| extra_args: "" | |
| - runner: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| manylinux: "2_17" | |
| # ring's pregenerated aarch64 assembly fails under the manylinux | |
| # cross-gcc ("ARM assembler must define __ARM_ARCH"); build with zig. | |
| zig_target: aarch64-linux-gnu.2.17 | |
| extra_args: "--zig" | |
| - runner: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| manylinux: auto | |
| zig_target: "" | |
| extra_args: "" | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Python | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: "3.12" | |
| - name: Configure aarch64 Linux linker | |
| if: ${{ matrix.platform.zig_target != '' }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| echo "CARGO_ZIG_TARGET=${{ matrix.platform.zig_target }}" >> "$GITHUB_ENV" | |
| echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=$GITHUB_WORKSPACE/tools/zig-cc" >> "$GITHUB_ENV" | |
| echo "CC_aarch64_unknown_linux_gnu=$GITHUB_WORKSPACE/tools/zig-cc" >> "$GITHUB_ENV" | |
| - name: Build abi3 wheel | |
| uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0 | |
| with: | |
| command: build | |
| maturin-version: v1.11.5 | |
| target: ${{ matrix.platform.target }} | |
| manylinux: ${{ matrix.platform.manylinux }} | |
| rust-toolchain: stable | |
| args: --release --locked --compatibility pypi --out dist ${{ matrix.platform.extra_args }} | |
| - name: Upload wheel | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: pypi-wheel-${{ matrix.platform.target }} | |
| path: dist/*.whl | |
| if-no-files-found: error | |
| sdist: | |
| name: source distribution | |
| needs: metadata | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Build source distribution | |
| uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0 | |
| with: | |
| command: sdist | |
| maturin-version: v1.11.5 | |
| rust-toolchain: stable | |
| args: --out dist | |
| - name: Upload source distribution | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: pypi-sdist | |
| path: dist/*.tar.gz | |
| if-no-files-found: error | |
| publish: | |
| name: publish to PyPI | |
| needs: | |
| - wheels | |
| - sdist | |
| if: >- | |
| ${{ | |
| github.repository == 'Skyvern-AI/rustwright' && | |
| github.ref_type == 'tag' && | |
| ( | |
| github.event_name == 'push' || | |
| (github.event_name == 'workflow_dispatch' && !inputs.dry_run) | |
| ) | |
| }} | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/project/rustwright/ | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Download distributions | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| pattern: pypi-* | |
| path: dist | |
| merge-multiple: true | |
| - name: Publish with PyPI Trusted Publishing | |
| uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1 |