Skip to content

.github/workflows/recorder-release.yml: fix github action #3

.github/workflows/recorder-release.yml: fix github action

.github/workflows/recorder-release.yml: fix github action #3

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 --command bash -lc 'just venv 3.13 dev'
- name: Run test suite
run: nix develop --command bash -lc 'just test'
- name: Check recorder version parity
run: nix develop --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
manylinux: 2014
- name: linux-aarch64
os: ubuntu-latest
build-sdist: false
publish-args: --release --interpreter python3.12 python3.13 --target aarch64-unknown-linux-gnu
manylinux: 2014
- name: macos-universal2
os: macos-13
build-sdist: false
publish-args: --release --universal2
- name: windows-amd64
os: windows-latest
build-sdist: false
publish-args: --release
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" -c "import importlib, pathlib; tomllib = importlib.import_module('tomllib'); data = tomllib.loads(pathlib.Path('codetracer-python-recorder/pyproject.toml').read_text()); print(data['project']['version'])")
echo "package_version=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Assert tag matches version
if: startsWith(github.ref, 'refs/tags/')
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: messense/maturin-action@v1
with:
command: build
args: ${{ matrix.publish-args }}
manylinux: ${{ matrix.manylinux }}
working-directory: codetracer-python-recorder
- name: Install Python 3.12 (macOS)
if: startsWith(matrix.name, 'macos')
id: mac_py312
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Python 3.13 (macOS)
if: startsWith(matrix.name, 'macos')
id: mac_py313
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 maturin (macOS)
if: startsWith(matrix.name, 'macos')
run: python3 -m pip install --upgrade pip maturin>=1.5,<2
- name: Install maturin (Windows)
if: matrix.name == 'windows-amd64'
run: python -m pip install --upgrade pip maturin>=1.5,<2
- name: Build artefacts (macOS universal2)
if: startsWith(matrix.name, 'macos')
env:
PYTHON312: ${{ steps.mac_py312.outputs.python-path }}
PYTHON313: ${{ steps.mac_py313.outputs.python-path }}
working-directory: ${{ env.CRATE_DIR }}
run: maturin build ${{ matrix.publish-args }} --interpreter "$PYTHON312" "$PYTHON313"
- 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 --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 --interpreter "$env:PYTHON"
- name: Upload artefacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.name }}
path: |
codetracer-python-recorder/target/wheels/*
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/
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: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist