|
1 | | -name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI |
| 1 | +name: Release & Publish 🚀 |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - main |
7 | 7 |
|
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + id-token: write |
| 11 | + |
8 | 12 | jobs: |
| 13 | + release: |
| 14 | + name: Semantic Release 📦 |
| 15 | + runs-on: ubuntu-latest |
| 16 | + concurrency: release |
| 17 | + outputs: |
| 18 | + released: ${{ steps.release.outputs.released }} |
| 19 | + version: ${{ steps.release.outputs.version }} |
| 20 | + tag: ${{ steps.release.outputs.tag }} |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 27 | + |
| 28 | + - uses: actions/setup-python@v5 |
| 29 | + with: |
| 30 | + python-version: "3.12" |
| 31 | + |
| 32 | + - name: Python Semantic Release |
| 33 | + id: release |
| 34 | + uses: python-semantic-release/python-semantic-release@v9.21.0 |
| 35 | + with: |
| 36 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + |
9 | 38 | build: |
10 | 39 | name: Build distribution 📦 |
| 40 | + needs: release |
| 41 | + if: needs.release.outputs.released == 'true' |
11 | 42 | runs-on: ubuntu-latest |
12 | 43 |
|
13 | 44 | steps: |
14 | | - - uses: actions/checkout@v6 |
| 45 | + - uses: actions/checkout@v4 |
| 46 | + with: |
| 47 | + ref: ${{ needs.release.outputs.tag }} |
| 48 | + fetch-depth: 0 |
15 | 49 |
|
16 | | - - uses: actions/setup-python@v6 |
| 50 | + - uses: actions/setup-python@v5 |
17 | 51 | with: |
18 | | - python-version: "3.10" |
| 52 | + python-version: "3.12" |
19 | 53 |
|
20 | | - - name: Install pypa/build |
21 | | - run: pip install build |
| 54 | + - name: Install build dependencies |
| 55 | + run: pip install build setuptools-scm |
22 | 56 |
|
23 | 57 | - name: Build a binary wheel and a source tarball |
24 | 58 | run: python -m build |
25 | 59 |
|
26 | | - - uses: actions/upload-artifact@v5 |
| 60 | + - uses: actions/upload-artifact@v4 |
27 | 61 | with: |
28 | 62 | name: python-package-distributions |
29 | 63 | path: dist/ |
30 | 64 |
|
31 | 65 | publish-to-pypi: |
32 | | - name: Publish Python 🐍 distribution 📦 to PyPI |
33 | | - if: startsWith(github.ref, 'refs/tags/') |
34 | | - needs: build |
| 66 | + name: Publish to PyPI 🐍 |
| 67 | + needs: [release, build] |
| 68 | + if: needs.release.outputs.released == 'true' |
35 | 69 | runs-on: ubuntu-latest |
36 | 70 | environment: |
37 | 71 | name: pypi |
38 | 72 | url: https://pypi.org/p/cssinj |
39 | 73 | permissions: |
40 | 74 | id-token: write |
| 75 | + |
41 | 76 | steps: |
42 | | - - uses: actions/download-artifact@v6 |
| 77 | + - uses: actions/download-artifact@v4 |
43 | 78 | with: |
44 | 79 | name: python-package-distributions |
45 | 80 | path: dist/ |
| 81 | + |
46 | 82 | - uses: pypa/gh-action-pypi-publish@release/v1 |
47 | 83 |
|
48 | | - publish-to-testpypi: |
49 | | - name: Publish Python 🐍 distribution 📦 to TestPyPI |
50 | | - if: github.ref == 'refs/heads/main' |
51 | | - needs: build |
| 84 | + github-release: |
| 85 | + name: GitHub Release 🏷️ |
| 86 | + needs: [release, build] |
| 87 | + if: needs.release.outputs.released == 'true' |
52 | 88 | runs-on: ubuntu-latest |
53 | | - environment: |
54 | | - name: testpypi |
55 | | - url: https://test.pypi.org/p/cssinj |
56 | 89 | permissions: |
57 | | - id-token: write |
| 90 | + contents: write |
| 91 | + |
58 | 92 | steps: |
59 | | - - uses: actions/download-artifact@v6 |
| 93 | + - uses: actions/download-artifact@v4 |
60 | 94 | with: |
61 | 95 | name: python-package-distributions |
62 | 96 | path: dist/ |
63 | | - - uses: pypa/gh-action-pypi-publish@release/v1 |
| 97 | + |
| 98 | + - name: Upload to GitHub Release |
| 99 | + uses: softprops/action-gh-release@v2 |
64 | 100 | with: |
65 | | - repository-url: https://test.pypi.org/legacy/ |
| 101 | + tag_name: ${{ needs.release.outputs.tag }} |
| 102 | + files: dist/* |
| 103 | + generate_release_notes: true |
0 commit comments