|
1 | | -name: Publish Python 🐍 distribution 📦 to PyPI |
| 1 | +name: Release Drafter and Publish Python 🐍 distribution 📦 to PyPI |
2 | 2 |
|
3 | | -on: push |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + release: |
| 8 | + types: [published] |
4 | 9 |
|
5 | 10 | jobs: |
6 | | - build: |
7 | | - name: Build distribution 📦 |
| 11 | + release-drafter: |
| 12 | + name: Draft Release Notes |
8 | 13 | runs-on: ubuntu-latest |
9 | | - |
| 14 | + if: github.event_name == 'push' |
| 15 | + permissions: |
| 16 | + contents: write |
| 17 | + pull-requests: write |
10 | 18 | steps: |
11 | | - - uses: actions/checkout@v4 |
12 | | - with: |
13 | | - persist-credentials: false |
14 | | - - name: Set up Python |
15 | | - uses: actions/setup-python@v5 |
16 | | - with: |
17 | | - python-version: "3.x" |
18 | | - - name: Install pypa/build |
19 | | - run: >- |
20 | | - python3 -m |
21 | | - pip install |
22 | | - build |
23 | | - --user |
24 | | - - name: Build a binary wheel and a source tarball |
25 | | - run: python3 -m build |
26 | | - - name: Store the distribution packages |
27 | | - uses: actions/upload-artifact@v4 |
| 19 | + - name: Draft Release |
| 20 | + uses: release-drafter/release-drafter@v6 |
28 | 21 | with: |
29 | | - name: python-package-distributions |
30 | | - path: dist/ |
| 22 | + publish: false |
| 23 | + env: |
| 24 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
31 | 25 |
|
32 | | - publish-to-pypi: |
33 | | - name: >- |
34 | | - Publish Python 🐍 distribution 📦 to PyPI |
35 | | - if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
36 | | - needs: |
37 | | - - build |
| 26 | + build-and-publish: |
| 27 | + name: Build, Sign, and Publish to PyPI 📦 |
38 | 28 | runs-on: ubuntu-latest |
| 29 | + if: github.event_name == 'release' |
39 | 30 | environment: |
40 | 31 | name: pypi |
41 | 32 | url: https://pypi.org/p/camelot-py |
42 | 33 | permissions: |
43 | | - id-token: write # IMPORTANT: mandatory for trusted publishing |
44 | | - |
| 34 | + id-token: write |
| 35 | + contents: write |
45 | 36 | steps: |
46 | | - - name: Download all the dists |
47 | | - uses: actions/download-artifact@v4 |
| 37 | + - name: Checkout repository |
| 38 | + uses: actions/checkout@v4 |
48 | 39 | with: |
49 | | - name: python-package-distributions |
50 | | - path: dist/ |
51 | | - - name: Publish distribution 📦 to PyPI |
52 | | - uses: pypa/gh-action-pypi-publish@release/v1 |
| 40 | + ref: ${{ github.event.release.tag_name }} |
| 41 | + fetch-depth: 0 |
53 | 42 |
|
54 | | - github-release: |
55 | | - name: >- |
56 | | - Sign the Python 🐍 distribution 📦 with Sigstore |
57 | | - and upload them to GitHub Release |
58 | | - needs: |
59 | | - - publish-to-pypi |
60 | | - runs-on: ubuntu-latest |
| 43 | + - name: Set up Python |
| 44 | + uses: actions/setup-python@v5 |
| 45 | + with: |
| 46 | + python-version: "3.10" |
61 | 47 |
|
62 | | - permissions: |
63 | | - contents: write # IMPORTANT: mandatory for making GitHub Releases |
64 | | - id-token: write # IMPORTANT: mandatory for sigstore |
| 48 | + - name: Install build dependencies |
| 49 | + run: python -m pip install build |
| 50 | + |
| 51 | + - name: Build a binary wheel and a source tarball |
| 52 | + run: python -m build |
65 | 53 |
|
66 | | - steps: |
67 | | - - name: Download all the dists |
68 | | - uses: actions/download-artifact@v4 |
69 | | - with: |
70 | | - name: python-package-distributions |
71 | | - path: dist/ |
72 | 54 | - name: Sign the dists with Sigstore |
73 | | - uses: sigstore/[email protected].0 |
| 55 | + uses: sigstore/[email protected].1 |
74 | 56 | with: |
75 | 57 | inputs: >- |
76 | 58 | ./dist/*.tar.gz |
77 | 59 | ./dist/*.whl |
78 | | - - name: Create GitHub Release |
79 | | - env: |
80 | | - GITHUB_TOKEN: ${{ github.token }} |
81 | | - run: >- |
82 | | - gh release create |
83 | | - "$GITHUB_REF_NAME" |
84 | | - --repo "$GITHUB_REPOSITORY" |
85 | | - --notes "" |
| 60 | +
|
86 | 61 | - name: Upload artifact signatures to GitHub Release |
87 | 62 | env: |
88 | 63 | GITHUB_TOKEN: ${{ github.token }} |
89 | | - # Upload to GitHub Release using the `gh` CLI. |
90 | | - # `dist/` contains the built packages, and the |
91 | | - # sigstore-produced signatures and certificates. |
92 | 64 | run: >- |
93 | 65 | gh release upload |
94 | | - "$GITHUB_REF_NAME" dist/** |
| 66 | + "${{ github.event.release.tag_name }}" ./dist/* |
95 | 67 | --repo "$GITHUB_REPOSITORY" |
| 68 | +
|
| 69 | + - name: Remove Sigstore files |
| 70 | + run: rm -f dist/*.sig dist/*.crt dist/*.sigstore.json |
| 71 | + |
| 72 | + - name: Publish Python 🐍 distribution 📦 to PyPI |
| 73 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 74 | + with: |
| 75 | + packages-dir: "dist" |
0 commit comments