codetracer-python-recorder/pyproject.toml: Update version string #15
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: Recorder Release | |
| on: | |
| push: | |
| tags: | |
| - recorder-v* | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| id-token: write | |
| concurrency: | |
| group: recorder-release-${{ github.ref }} | |
| cancel-in-progress: false | |
| env: | |
| CRATE_DIR: codetracer-python-recorder | |
| jobs: | |
| verify: | |
| name: Verify Tests (Linux) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: cachix/install-nix-action@v27 | |
| with: | |
| nix_path: nixpkgs=channel:nixos-25.05 | |
| extra_nix_config: | | |
| experimental-features = nix-command flakes | |
| - name: Prepare dev environment (Python 3.13) | |
| run: nix develop ./nix --command bash -lc 'just venv 3.13 dev' | |
| - name: Run test suite | |
| run: nix develop ./nix --command bash -lc 'just test' | |
| - name: Check recorder version parity | |
| run: nix develop ./nix --command bash -lc 'python3 scripts/check_recorder_version.py' | |
| build: | |
| name: Build Artefacts (${{ matrix.name }}) | |
| needs: verify | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: linux-x86_64 | |
| os: ubuntu-latest | |
| build-sdist: true | |
| publish-args: --release --sdist --interpreter python3.12 python3.13 --out dist | |
| manylinux: 2014 | |
| target: "" | |
| - name: linux-aarch64 | |
| os: ubuntu-latest | |
| build-sdist: false | |
| publish-args: --release --interpreter python3.12 python3.13 --target aarch64-unknown-linux-gnu --out dist | |
| manylinux: 2014 | |
| target: "" | |
| - name: macos-x86_64 | |
| os: macos-13 | |
| build-sdist: false | |
| publish-args: --release --out dist --interpreter python3.12 python3.13 | |
| target: x86_64 | |
| - name: macos-aarch64 | |
| os: macos-14 | |
| build-sdist: false | |
| publish-args: --release --out dist --interpreter python3.12 python3.13 | |
| target: aarch64 | |
| - name: windows-amd64 | |
| os: windows-latest | |
| build-sdist: false | |
| publish-args: --release --out dist | |
| target: "" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check recorder version parity | |
| shell: bash | |
| run: | | |
| PYTHON=$(command -v python3 || command -v python) | |
| "$PYTHON" scripts/check_recorder_version.py | |
| - name: Extract package version | |
| id: version | |
| shell: bash | |
| run: | | |
| PYTHON=$(command -v python3 || command -v python) | |
| VERSION=$("$PYTHON" - <<'PY' | |
| from pathlib import Path | |
| version = None | |
| in_project = False | |
| for line in Path("codetracer-python-recorder/pyproject.toml").read_text(encoding="utf-8").splitlines(): | |
| stripped = line.strip() | |
| if stripped.startswith("["): | |
| in_project = stripped == "[project]" | |
| continue | |
| if in_project and stripped.startswith("version"): | |
| _, _, value = stripped.partition("=") | |
| version = value.strip().strip('"') | |
| break | |
| if not version: | |
| raise SystemExit("Unable to find [project].version in pyproject.toml") | |
| print(version) | |
| PY | |
| ) | |
| echo "package_version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Assert tag matches version | |
| if: startsWith(github.ref, 'refs/tags/') | |
| shell: bash | |
| run: | | |
| TAG="${GITHUB_REF##*/}" | |
| EXPECTED="recorder-v${{ steps.version.outputs.package_version }}" | |
| if [ "$TAG" != "$EXPECTED" ]; then | |
| echo "::error::Tag '$TAG' does not match package version '$EXPECTED'" | |
| exit 1 | |
| fi | |
| - name: Build artefacts (Linux targets) | |
| if: startsWith(matrix.name, 'linux-') | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| command: build | |
| args: ${{ matrix.publish-args }} | |
| manylinux: ${{ matrix.manylinux }} | |
| sccache: true | |
| before-script-linux: | | |
| set -eux | |
| if command -v yum >/dev/null 2>&1; then | |
| yum install -y capnproto | |
| elif command -v dnf >/dev/null 2>&1; then | |
| dnf install -y capnproto | |
| elif command -v microdnf >/dev/null 2>&1; then | |
| microdnf install -y capnproto | |
| elif command -v apt-get >/dev/null 2>&1; then | |
| apt-get update | |
| apt-get install -y capnproto | |
| else | |
| echo "Unable to install capnproto: no supported package manager found" >&2 | |
| exit 1 | |
| fi | |
| working-directory: codetracer-python-recorder | |
| - name: Install Python 3.12 (macOS) | |
| if: startsWith(matrix.name, 'macos-') | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install Python 3.13 (macOS) | |
| if: startsWith(matrix.name, 'macos-') | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - name: Install Python 3.12 (Windows) | |
| if: matrix.name == 'windows-amd64' | |
| id: win_py312 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| architecture: 'x64' | |
| - name: Install Python 3.13 (Windows) | |
| if: matrix.name == 'windows-amd64' | |
| id: win_py313 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| architecture: 'x64' | |
| - name: Install Cap'n Proto (macOS) | |
| if: startsWith(matrix.name, 'macos-') | |
| run: brew install capnp | |
| - name: Install Cap'n Proto (Windows) | |
| if: matrix.name == 'windows-amd64' | |
| run: choco install -y capnproto | |
| - name: Install maturin (Windows) | |
| if: matrix.name == 'windows-amd64' | |
| shell: pwsh | |
| run: | | |
| & "${{ steps.win_py312.outputs.python-path }}" -m pip install --upgrade pip | |
| & "${{ steps.win_py312.outputs.python-path }}" -m pip install "maturin>=1.5,<2" | |
| - name: Build artefacts (macOS targets) | |
| if: startsWith(matrix.name, 'macos-') | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| command: build | |
| args: ${{ matrix.publish-args }} | |
| target: ${{ matrix.target }} | |
| working-directory: ${{ env.CRATE_DIR }} | |
| - name: Build cp312 wheel (Windows) | |
| if: matrix.name == 'windows-amd64' | |
| env: | |
| PYTHON: ${{ steps.win_py312.outputs.python-path }} | |
| working-directory: ${{ env.CRATE_DIR }} | |
| run: maturin build --release --out dist --interpreter "$env:PYTHON" | |
| - name: Build cp313 wheel (Windows) | |
| if: matrix.name == 'windows-amd64' | |
| env: | |
| PYTHON: ${{ steps.win_py313.outputs.python-path }} | |
| working-directory: ${{ env.CRATE_DIR }} | |
| run: maturin build --release --out dist --interpreter "$env:PYTHON" | |
| - name: Upload artefacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-${{ matrix.name }} | |
| path: | | |
| codetracer-python-recorder/dist/* | |
| if-no-files-found: error | |
| publish-testpypi: | |
| name: Publish to TestPyPI | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: testpypi | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Download artefacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: dist-* | |
| path: dist | |
| merge-multiple: true | |
| - name: Inspect artefacts | |
| run: ls -R dist | |
| - name: Install maturin | |
| run: | | |
| python3 -m pip install --upgrade pip "maturin>=1.5,<2" | |
| - name: Python smoke install (Linux wheel) | |
| run: | | |
| python3 scripts/check_recorder_version.py | |
| FILE=$(python3 scripts/select_recorder_artifact.py --wheel-dir dist --mode wheel --platform linux) | |
| python3 -m venv .smoke | |
| . .smoke/bin/activate | |
| pip install --upgrade pip | |
| pip install "$FILE" | |
| python -m codetracer_python_recorder --help | |
| - name: Publish to TestPyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| packages-dir: dist | |
| publish-pypi: | |
| name: Publish to PyPI | |
| needs: publish-testpypi | |
| if: startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi-production | |
| url: https://pypi.org/project/codetracer-python-recorder/ | |
| permissions: | |
| contents: read | |
| id-token: write | |
| attestations: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Download artefacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: dist-* | |
| path: dist | |
| merge-multiple: true | |
| - name: Generate artifact attestation | |
| uses: actions/attest-build-provenance@v2 | |
| with: | |
| subject-path: 'dist/*' | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist |