|
1 | 1 | name: build |
2 | 2 |
|
3 | 3 | on: |
| 4 | + pull_request: |
4 | 5 | release: |
5 | | - types: |
6 | | - - published |
| 6 | + types: [released] |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 11 | + cancel-in-progress: true |
7 | 12 |
|
8 | 13 | jobs: |
9 | | - build_and_publish: |
10 | | - name: build and publish package |
| 14 | + build: |
11 | 15 | runs-on: ubuntu-latest |
12 | 16 | steps: |
13 | | - - uses: actions/checkout@main |
14 | | - - uses: actions/setup-python@main |
| 17 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 18 | + with: |
| 19 | + fetch-tags: true |
| 20 | + persist-credentials: false |
| 21 | + - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 22 | + with: |
| 23 | + python-version: "3" |
| 24 | + - run: pip install build |
| 25 | + - run: python -m build --sdist --wheel |
| 26 | + - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
15 | 27 | with: |
16 | | - python-version: "3.x" |
17 | | - - uses: actions/cache@main |
| 28 | + name: dist |
| 29 | + path: ./dist/ |
| 30 | + publish: |
| 31 | + if: (github.event_name == 'release') && (github.event.action == 'released') |
| 32 | + needs: [build] |
| 33 | + runs-on: ubuntu-latest |
| 34 | + permissions: |
| 35 | + id-token: write |
| 36 | + attestations: write |
| 37 | + # Requires environment protection rules in GitHub Settings: |
| 38 | + # Settings > Environments > release > Add required reviewers |
| 39 | + environment: |
| 40 | + name: release |
| 41 | + url: https://pypi.org/p/searvey |
| 42 | + steps: |
| 43 | + - uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 |
18 | 44 | with: |
19 | | - path: ${{ env.pythonLocation }} |
20 | | - key: build-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'setup.*') }} |
21 | | - - run: pip wheel . --no-deps -w dist |
22 | | - - uses: pypa/gh-action-pypi-publish@release/v1 |
| 45 | + pattern: dist* |
| 46 | + path: dist/ |
| 47 | + merge-multiple: true |
| 48 | + - uses: actions/attest-build-provenance@96278af6caaf10aea03fd8d33a09a777ca52d62f # v3.2.0 |
23 | 49 | with: |
24 | | - user: __token__ |
25 | | - password: ${{ secrets.PYPI_TOKEN }} |
| 50 | + subject-path: "dist/*" |
| 51 | + # To upload to PyPI without a token, add this workflow file as a Trusted Publisher in the project settings on the PyPI website |
| 52 | + - uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 |
0 commit comments