|
1 | | -name: Build and Publish to PyPI |
| 1 | +name: Publish to PyPI |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: [ main, master ] |
6 | 5 | tags: |
7 | 6 | - 'v*' |
8 | | - pull_request: |
9 | | - branches: [ main, master ] |
| 7 | + workflow_dispatch: # Allow manual triggering |
10 | 8 |
|
11 | 9 | jobs: |
12 | | - test: |
| 10 | + publish: |
| 11 | + name: Build and Publish to PyPI |
13 | 12 | runs-on: ubuntu-latest |
14 | | - strategy: |
15 | | - matrix: |
16 | | - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] |
17 | 13 |
|
18 | | - steps: |
19 | | - - uses: actions/checkout@v3 |
20 | | - |
21 | | - - name: Set up Python ${{ matrix.python-version }} |
22 | | - uses: actions/setup-python@v4 |
23 | | - with: |
24 | | - python-version: ${{ matrix.python-version }} |
25 | | - |
26 | | - - name: Install dependencies |
27 | | - run: | |
28 | | - python -m pip install --upgrade pip |
29 | | - pip install build wheel |
30 | | - pip install -e . |
31 | | - |
32 | | - - name: Test installation |
33 | | - run: | |
34 | | - gtfo --version |
35 | | - gtfo bash || true # Allow failure for demo |
36 | | -
|
37 | | - build-and-publish: |
38 | | - needs: test |
39 | | - runs-on: ubuntu-latest |
40 | | - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) |
| 14 | + permissions: |
| 15 | + id-token: write # Required for trusted publishing |
41 | 16 |
|
42 | 17 | steps: |
43 | | - - uses: actions/checkout@v3 |
| 18 | + - uses: actions/checkout@v4 |
44 | 19 |
|
45 | 20 | - name: Set up Python |
46 | | - uses: actions/setup-python@v4 |
| 21 | + uses: actions/setup-python@v5 |
47 | 22 | with: |
48 | | - python-version: '3.10' |
| 23 | + python-version: '3.11' |
49 | 24 |
|
50 | | - - name: Install build dependencies |
| 25 | + - name: Install build tools |
51 | 26 | run: | |
52 | 27 | python -m pip install --upgrade pip |
53 | | - pip install build wheel twine |
| 28 | + pip install build |
54 | 29 | |
55 | 30 | - name: Build package |
56 | 31 | run: python -m build |
57 | 32 |
|
58 | | - - name: Check package |
59 | | - run: twine check dist/* |
60 | | - |
61 | | - - name: Publish to Test PyPI |
62 | | - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') |
63 | | - env: |
64 | | - TWINE_USERNAME: __token__ |
65 | | - TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} |
66 | | - run: | |
67 | | - twine upload --repository testpypi dist/* --skip-existing || true |
68 | | - continue-on-error: true |
| 33 | + - name: Check distribution |
| 34 | + run: ls -lah dist/ |
69 | 35 |
|
70 | 36 | - name: Publish to PyPI |
71 | | - if: startsWith(github.ref, 'refs/tags/') |
72 | | - env: |
73 | | - TWINE_USERNAME: __token__ |
74 | | - TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
75 | | - run: | |
76 | | - twine upload dist/* |
| 37 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments