|
1 | | -name: Publish to PyPI and GitHub Packages |
| 1 | +name: Publish |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | tags: |
6 | 6 | - 'v*' |
| 7 | + workflow_dispatch: {} |
7 | 8 |
|
8 | 9 | jobs: |
9 | | - deploy: |
| 10 | + publish: |
10 | 11 | runs-on: ubuntu-latest |
11 | | - |
| 12 | + |
12 | 13 | permissions: |
13 | | - contents: read |
14 | | - packages: write |
15 | | - |
| 14 | + contents: write |
| 15 | + id-token: write |
| 16 | + |
16 | 17 | steps: |
17 | | - - uses: actions/checkout@v3 |
18 | | - |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
19 | 21 | - name: Set up Python |
20 | | - uses: actions/setup-python@v4 |
| 22 | + uses: actions/setup-python@v5 |
21 | 23 | with: |
22 | 24 | python-version: '3.11' |
23 | | - |
24 | | - - name: Install dependencies |
| 25 | + cache: pip |
| 26 | + |
| 27 | + - name: Install |
25 | 28 | run: | |
26 | 29 | python -m pip install --upgrade pip |
27 | | - pip install build wheel twine |
28 | | - |
29 | | - - name: Build package |
| 30 | + pip install ".[dev]" build |
| 31 | +
|
| 32 | + - name: Test |
| 33 | + run: pytest |
| 34 | + |
| 35 | + - name: Build |
30 | 36 | run: python -m build |
31 | | - |
32 | | - - name: Publish to PyPI |
33 | | - env: |
34 | | - TWINE_USERNAME: __token__ |
35 | | - TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
36 | | - run: twine upload dist/* |
37 | | - |
38 | | - - name: Publish to GitHub Packages |
39 | | - env: |
40 | | - TWINE_USERNAME: __token__ |
41 | | - TWINE_PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
42 | | - run: | |
43 | | - twine upload dist/* \ |
44 | | - --repository-url https://upload.pypi.org/legacy/ || true |
45 | | - |
46 | | - - name: Create Release |
47 | | - uses: actions/create-release@v1 |
48 | | - env: |
49 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + |
| 38 | + - name: Publish to PyPI (token) |
| 39 | + if: ${{ secrets.PYPI_API_TOKEN != '' }} |
| 40 | + uses: pypa/gh-action-pypi-publish@release/v1 |
50 | 41 | with: |
51 | | - tag_name: ${{ github.ref }} |
52 | | - release_name: Release ${{ github.ref }} |
53 | | - body: | |
54 | | - # Release ${{ github.ref }} |
55 | | - |
56 | | - **PyPI:** https://pypi.org/project/hexarch-guardrails/ |
57 | | - |
58 | | - ## Installation |
59 | | - ```bash |
60 | | - pip install hexarch-guardrails |
61 | | - ``` |
62 | | - |
63 | | - ## Changes |
64 | | - See CHANGELOG.md for details. |
65 | | - draft: false |
66 | | - prerelease: false |
67 | | - |
68 | | - - name: Upload Release Assets |
69 | | - uses: softprops/action-gh-release@v1 |
| 42 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 43 | + |
| 44 | + - name: Publish to PyPI (trusted publishing) |
| 45 | + if: ${{ secrets.PYPI_API_TOKEN == '' }} |
| 46 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 47 | + |
| 48 | + - name: GitHub Release |
| 49 | + uses: softprops/action-gh-release@v2 |
70 | 50 | with: |
71 | 51 | files: dist/* |
72 | | - env: |
73 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments