|
1 | | -name: Build and Publish |
| 1 | +name: Publish to PyPI |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | release: |
5 | 5 | types: [published] |
6 | | - workflow_dispatch: |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + id-token: write |
7 | 10 |
|
8 | 11 | jobs: |
9 | | - build: |
| 12 | + build-wheels: |
10 | 13 | name: Build wheels on ${{ matrix.os }} |
11 | 14 | runs-on: ${{ matrix.os }} |
12 | 15 | strategy: |
13 | 16 | matrix: |
14 | 17 | os: [ubuntu-latest, windows-latest, macos-latest] |
15 | 18 |
|
16 | 19 | steps: |
17 | | - - uses: actions/checkout@v4 |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Set up Python |
| 23 | + uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + python-version: '3.10' |
| 26 | + |
| 27 | + - name: Install Rust |
| 28 | + uses: dtolnay/rust-toolchain@stable |
18 | 29 |
|
19 | | - - name: Set up Python |
20 | | - uses: actions/setup-python@v4 |
21 | | - with: |
22 | | - python-version: '3.11' |
| 30 | + - name: Install maturin |
| 31 | + run: pip install maturin |
23 | 32 |
|
24 | | - - name: Set up Rust |
25 | | - uses: actions-rs/toolchain@v1 |
26 | | - with: |
27 | | - toolchain: stable |
28 | | - override: true |
| 33 | + - name: Build wheels |
| 34 | + run: maturin build --release --out dist --find-interpreter |
29 | 35 |
|
30 | | - - name: Install maturin |
31 | | - run: pip install maturin |
| 36 | + - name: Upload wheels |
| 37 | + uses: actions/upload-artifact@v4 |
| 38 | + with: |
| 39 | + name: wheels-${{ matrix.os }} |
| 40 | + path: dist |
| 41 | + |
| 42 | + build-sdist: |
| 43 | + name: Build source distribution |
| 44 | + runs-on: ubuntu-latest |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
32 | 47 |
|
33 | | - - name: Build wheels |
34 | | - run: maturin build --release --out dist |
| 48 | + - name: Set up Python |
| 49 | + uses: actions/setup-python@v5 |
| 50 | + with: |
| 51 | + python-version: '3.10' |
35 | 52 |
|
36 | | - - name: Upload wheels |
37 | | - uses: actions/upload-artifact@v4 |
38 | | - with: |
39 | | - name: wheels-${{ matrix.os }} |
40 | | - path: dist/ |
| 53 | + - name: Install Rust |
| 54 | + uses: dtolnay/rust-toolchain@stable |
| 55 | + |
| 56 | + - name: Install maturin |
| 57 | + run: pip install maturin |
| 58 | + |
| 59 | + - name: Build sdist |
| 60 | + run: maturin sdist --out dist |
| 61 | + |
| 62 | + - name: Upload sdist |
| 63 | + uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: sdist |
| 66 | + path: dist |
41 | 67 |
|
42 | 68 | publish: |
43 | 69 | name: Publish to PyPI |
44 | | - needs: build |
| 70 | + needs: [build-wheels, build-sdist] |
45 | 71 | runs-on: ubuntu-latest |
46 | | - if: github.event_name == 'release' && github.event.action == 'published' |
47 | | - |
| 72 | + environment: |
| 73 | + name: pypi |
| 74 | + url: https://pypi.org/p/externkit |
| 75 | + permissions: |
| 76 | + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing |
| 77 | + |
48 | 78 | steps: |
49 | | - - name: Download all wheels |
50 | | - uses: actions/download-artifact@v4 |
51 | | - with: |
52 | | - path: dist/ |
53 | | - pattern: wheels-* |
54 | | - merge-multiple: true |
55 | | - |
56 | | - - name: Flatten wheels directory |
57 | | - run: | |
58 | | - mkdir -p wheels |
59 | | - find dist/ -name "*.whl" -exec cp {} wheels/ \; |
60 | | - find dist/ -name "*.tar.gz" -exec cp {} wheels/ \; |
61 | | - ls -la wheels/ |
62 | | -
|
63 | | - - name: Publish to PyPI |
64 | | - uses: PyO3/maturin-action@v1 |
65 | | - with: |
66 | | - command: upload |
67 | | - args: --skip-existing wheels/* |
68 | | - env: |
69 | | - MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} |
| 79 | + - name: Download all artifacts |
| 80 | + uses: actions/download-artifact@v4 |
| 81 | + with: |
| 82 | + pattern: '*' |
| 83 | + path: dist |
| 84 | + merge-multiple: true |
| 85 | + |
| 86 | + - name: Publish to PyPI |
| 87 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 88 | + with: |
| 89 | + # Using trusted publishing - no API token needed! |
| 90 | + # Make sure you've configured trusted publishing on PyPI: |
| 91 | + # https://docs.pypi.org/trusted-publishers/ |
| 92 | + verbose: true |
0 commit comments