|
1 | 1 | name: Release Workflow |
| 2 | +permissions: {} |
2 | 3 |
|
3 | 4 | on: |
4 | 5 | push: |
5 | 6 | tags: |
6 | 7 | - "*" |
7 | 8 |
|
8 | 9 | jobs: |
9 | | - build: |
10 | | - name: Build wheel and create release |
| 10 | + lint: |
| 11 | + name: Linters |
11 | 12 | runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: read # Fetch repository |
| 15 | + security-events: write # Required for upload-sarif (used by zizmor-action) to upload SARIF files. |
12 | 16 | steps: |
13 | 17 | - name: Checkout code |
14 | 18 | uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + persist-credentials: false |
| 21 | + |
| 22 | + - name: zizmor |
| 23 | + uses: zizmorcore/zizmor-action@e639db99335bc9038abc0e066dfcd72e23d26fb4 # v0.3.0 |
| 24 | + |
| 25 | + - name: typos |
| 26 | + uses: crate-ci/typos@2d0ce569feab1f8752f1dde43cc2f2aa53236e06 # v1.40.0 |
15 | 27 |
|
16 | | - - name: Linter |
17 | | - uses: astral-sh/ruff-action@v3 |
| 28 | + - name: Ruff |
| 29 | + uses: astral-sh/ruff-action@57714a7c8a2e59f32539362ba31877a1957dded1 # v3.5.1 |
18 | 30 |
|
19 | | - - name: Get tag name |
20 | | - id: get_tag |
21 | | - run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 31 | + build: |
| 32 | + name: Build distribution |
| 33 | + runs-on: ubuntu-latest |
| 34 | + needs: lint |
| 35 | + permissions: |
| 36 | + contents: read # Fetch repository |
| 37 | + actions: write # Upload artifact |
| 38 | + steps: |
| 39 | + - name: Checkout code |
| 40 | + uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + persist-credentials: false |
22 | 43 |
|
23 | 44 | - name: Install uv |
24 | | - uses: astral-sh/setup-uv@v5 |
| 45 | + uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4 |
25 | 46 | with: |
26 | 47 | version: "latest" |
| 48 | + enable-cache: false |
27 | 49 |
|
28 | | - - name: Build wheel |
| 50 | + - name: Build wheel and sdist |
29 | 51 | run: uv build |
30 | 52 |
|
31 | | - - name: Upload artifacts |
32 | | - uses: actions/upload-artifact@v4 |
| 53 | + - name: Upload dists |
| 54 | + uses: actions/upload-artifact@v5 |
33 | 55 | with: |
34 | | - name: dist-${{ matrix.os }} |
35 | | - path: ./dist/* |
| 56 | + name: python-package-distributions |
| 57 | + path: dist/ |
36 | 58 |
|
37 | | - - name: Create Release |
38 | | - env: |
39 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
40 | | - TAG: ${{ steps.get_tag.outputs.TAG_NAME }} |
41 | | - run: gh release create "$TAG" ./dist/* |
| 59 | + publish-to-pypi: |
| 60 | + name: Publish to PyPI |
| 61 | + runs-on: ubuntu-latest |
| 62 | + needs: build |
| 63 | + environment: |
| 64 | + name: publish-to-pypi |
| 65 | + permissions: |
| 66 | + actions: read # Download artifact |
| 67 | + id-token: write # Needed for trusted publishing |
| 68 | + steps: |
| 69 | + - name: Download all dists |
| 70 | + uses: actions/download-artifact@v6 |
| 71 | + with: |
| 72 | + name: python-package-distributions |
| 73 | + path: dist/ |
| 74 | + |
| 75 | + - name: Install uv |
| 76 | + uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4 |
| 77 | + with: |
| 78 | + version: "latest" |
| 79 | + enable-cache: false |
42 | 80 |
|
43 | 81 | - name: Upload to PyPI |
44 | | - run: uv publish -t ${{ secrets.UV_PUBLISH_TOKEN }} |
| 82 | + run: uv publish --trusted-publishing always |
| 83 | + |
| 84 | + |
| 85 | + github-release: |
| 86 | + name: GitHub release |
| 87 | + runs-on: ubuntu-latest |
| 88 | + needs: build |
| 89 | + permissions: |
| 90 | + actions: read # Download artifact |
| 91 | + contents: write # Create GitHub release |
| 92 | + steps: |
| 93 | + - name: Checkout code |
| 94 | + uses: actions/checkout@v4 |
| 95 | + with: |
| 96 | + persist-credentials: false |
45 | 97 |
|
| 98 | + - name: Download all dists |
| 99 | + uses: actions/download-artifact@v6 |
| 100 | + with: |
| 101 | + name: python-package-distributions |
| 102 | + path: ./dist/ |
| 103 | + |
| 104 | + - name: Create release |
| 105 | + env: |
| 106 | + GITHUB_TOKEN: ${{ github.token }} |
| 107 | + run: gh release create "${GITHUB_REF#refs/tags/}" ./dist/* |
0 commit comments