|
| 1 | +name: build |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
| 8 | + pull_request: |
| 9 | + branches: [main] # PR verification only (base=main) |
| 10 | + push: |
| 11 | + branches: [main] # releases on merges to main |
| 12 | + |
| 13 | +jobs: |
| 14 | + # Build job for PR verification |
| 15 | + build: |
| 16 | + if: github.event_name == 'pull_request' |
| 17 | + name: Build |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v5 |
| 24 | + with: |
| 25 | + ref: ${{ github.event.pull_request.head.sha || github.sha }} |
| 26 | + - uses: ./.github/actions/python-init |
| 27 | + - name: Build sdist and wheel |
| 28 | + run: uv build |
| 29 | + - uses: ./.github/actions/python-post |
| 30 | + |
| 31 | + # Publish releases on changes to main |
| 32 | + release: |
| 33 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'paddy74/python-usajobsapi' |
| 34 | + name: Create a Release |
| 35 | + runs-on: ubuntu-latest |
| 36 | + permissions: |
| 37 | + contents: write # tags + GitHub Release |
| 38 | + id-token: write # PyPI Trusted Publishing |
| 39 | + environment: |
| 40 | + name: pypi |
| 41 | + url: https://pypi.org/p/python-usajobsapi |
| 42 | + |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v5 |
| 45 | + with: |
| 46 | + fetch-depth: 0 |
| 47 | + |
| 48 | + - name: Python Semantic Release |
| 49 | + id: release |
| 50 | + uses: python-semantic-release/python-semantic-release@v10 |
| 51 | + with: |
| 52 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + |
| 54 | + - name: Publish pkg to GitHub Releases |
| 55 | + uses: python-semantic-release/publish-action@v10 |
| 56 | + if: steps.release.outputs.released == 'true' |
| 57 | + with: |
| 58 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + |
| 60 | + - name: Publish pkg to PyPI |
| 61 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 62 | + if: steps.release.outputs.released == 'true' |
| 63 | + with: |
| 64 | + packages-dir: dist |
| 65 | + skip-existing: true |
0 commit comments