diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 175e4f6..1e0d505 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,16 +1,21 @@ -name: Docs +name: Publish Docs on: push: - branches: [main] - workflow_dispatch: + tags: + - "v*" permissions: contents: write jobs: + test: + uses: ./.github/workflows/test.yml + deploy: runs-on: ubuntu-latest + needs: test + steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/ci.yml b/.github/workflows/pr.yml similarity index 98% rename from .github/workflows/ci.yml rename to .github/workflows/pr.yml index 76b5567..2366eb3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/pr.yml @@ -1,4 +1,4 @@ -name: CI +name: PR Tests on: pull_request: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..7696760 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,117 @@ +name: Publish to PyPI + +on: + push: + tags: + - "v*" + +permissions: + contents: read + id-token: write + +jobs: + test: + uses: ./.github/workflows/test.yml + + docs: + uses: ./.github/workflows/docs.yml + + build-wheels: + runs-on: ${{ matrix.os }} + needs: + - test + - docs + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.11"] + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Install uv + uses: astral-sh/setup-uv@v3 + + - name: Build wheels (Rust-enabled) + uses: PyO3/maturin-action@v1 + with: + command: build + args: --release --out dist + working-directory: rust-base32 + manylinux: auto + + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-${{ matrix.os }} + path: rust-base32/dist/*.whl + + build-sdist: + runs-on: ubuntu-latest + needs: + - test + - docs + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install uv + uses: astral-sh/setup-uv@v3 + + - name: Sync deps (including build tools) + run: | + uv sync --all-extras --dev + + - name: Build sdist + run: | + make build-sdist + + - name: Upload sdist + uses: actions/upload-artifact@v4 + with: + name: sdist + path: dist/*.tar.gz + + publish: + runs-on: ubuntu-latest + needs: + - build-wheels + - build-sdist + permissions: + contents: read + id-token: write + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: dist + + - name: Flatten dist directory + shell: bash + run: | + mkdir -p out + find dist -type f \( -name "*.whl" -o -name "*.tar.gz" \) -maxdepth 4 -print -exec cp {} out/ \; + ls -la out + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: out diff --git a/.github/workflows/test-rust-accel.yml b/.github/workflows/test-rust-accel.yml new file mode 100644 index 0000000..dc8254c --- /dev/null +++ b/.github/workflows/test-rust-accel.yml @@ -0,0 +1,47 @@ +name: Test Rust Acceleration + +on: + workflow_call: + workflow_dispatch: + pull_request: + push: + branches: [main] + +jobs: + test-rust-accel: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.11"] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Install uv + uses: astral-sh/setup-uv@v3 + + - name: Sync deps (locked) + run: | + uv sync --locked --all-groups --all-extras + + - name: Build & install Rust extension (maturin develop) + uses: PyO3/maturin-action@v1 + with: + command: develop + args: --release + working-directory: rust-base32 + + - name: Sanity check (import extension) + run: | + uv run python -c "import typeid_base32; print('typeid_base32 OK')" diff --git a/.github/workflows/setup.yml b/.github/workflows/test.yml similarity index 93% rename from .github/workflows/setup.yml rename to .github/workflows/test.yml index 6564672..265f7b3 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Build +name: Run Tests on: release: @@ -7,14 +7,13 @@ on: branches: - main paths-ignore: - - README.md - - CHANGELOG.md + - '**.md' env: PROJECT_NAME: typeid-python jobs: - build: + test: runs-on: ubuntu-latest strategy: fail-fast: false