swadhinbiswas ⚡ dx: switch CI to uv for faster dep resolution + OIDC publish · 7/25/2026
7a63124
105 lines · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Publish to PyPI

on:
  release:
    types: [published]
  workflow_dispatch:

permissions:
  contents: read
  id-token: write

jobs:
  check-version:
    name: Check Version
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.version.outputs.version }}
    steps:
      - uses: actions/checkout@v4
      - id: version
        run: echo "version=$(grep '^version = ' crates/justapi-py/Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')" >> "$GITHUB_OUTPUT"

  test-rust:
    name: Cargo Test & Lint
    runs-on: ubuntu-latest
    needs: check-version
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy, rustfmt
      - name: Install cargo-deny
        uses: taiki-e/install-action@v2
        with:
          tool: cargo-deny
      - name: Security & License Check
        run: cargo deny check
      - name: Run Tests
        run: cargo test --workspace
      - name: Clippy & Formatting
        run: |
          cargo clippy --workspace --tests -- -D warnings
          cargo fmt --check

  build-wheels:
    name: Build (${{ matrix.target }})
    runs-on: ${{ matrix.os }}
    needs: test-rust
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64
            args: --manylinux 2_28
          - os: ubuntu-latest
            target: aarch64
            args: --manylinux 2_28
          - os: macos-latest
            target: x86_64
          - os: macos-latest
            target: aarch64
          - os: windows-latest
            target: x64
    steps:
      - uses: actions/checkout@v4
      - uses: astral-sh/setup-uv@v5
        with:
          python-version: '3.12'
          enable-cache: true
          cache-dependency-glob: crates/justapi-py/pyproject.toml
      - uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist ${{ matrix.args }}
          manifest-path: crates/justapi-py/Cargo.toml
      - name: Smoke test
        shell: bash
        run: |
          uv pip install dist/*.whl
          python -c "import justapi; print(justapi.__version__)"
      - uses: actions/upload-artifact@v4
        with:
          name: wheels-${{ matrix.target }}
          path: dist/*.whl

  publish:
    name: Publish to PyPI
    runs-on: ubuntu-latest
    needs: build-wheels
    environment: pypi
    permissions:
      id-token: write
    steps:
      - uses: actions/checkout@v4
      - uses: astral-sh/setup-uv@v5
        with:
          python-version: '3.12'
      - uses: actions/download-artifact@v4
        with:
          pattern: wheels-*
          merge-multiple: true
          path: dist
      - name: Publish
        run: uv publish --package-dir crates/justapi-py --trusted-publishing always --verbose