|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + |
| 15 | + - name: build sdist and wheel |
| 16 | + run: pipx run build |
| 17 | + |
| 18 | + - uses: actions/upload-artifact@v4 |
| 19 | + with: |
| 20 | + path: dist/* |
| 21 | + |
| 22 | + - name: check metadata |
| 23 | + run: pipx run twine check dist/* |
| 24 | + |
| 25 | + publish_dev_build: |
| 26 | + needs: [build] |
| 27 | + runs-on: ubuntu-latest |
| 28 | + environment: |
| 29 | + name: testpypi |
| 30 | + permissions: |
| 31 | + # IMPORTANT: this permission is mandatory for trusted publishing |
| 32 | + id-token: write |
| 33 | + |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v4 |
| 36 | + |
| 37 | + - uses: actions/download-artifact@v4 |
| 38 | + with: |
| 39 | + name: artifact |
| 40 | + path: dist |
| 41 | + |
| 42 | + - name: publish to test pypi |
| 43 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 44 | + with: |
| 45 | + repository-url: https://test.pypi.org/legacy/ |
| 46 | + skip-existing: true |
| 47 | + |
| 48 | + release: |
| 49 | + needs: [publish_dev_build] |
| 50 | + runs-on: ubuntu-latest |
| 51 | + environment: |
| 52 | + name: pypi |
| 53 | + permissions: |
| 54 | + # IMPORTANT: this permission is mandatory for trusted publishing |
| 55 | + id-token: write |
| 56 | + # see https://github.com/softprops/action-gh-release/issues/236 |
| 57 | + contents: write |
| 58 | + |
| 59 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 60 | + steps: |
| 61 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 62 | + - uses: actions/checkout@v4 |
| 63 | + |
| 64 | + - name: update changelog |
| 65 | + id: changelog |
| 66 | + uses: requarks/changelog-action@v1 |
| 67 | + with: |
| 68 | + token: ${{ github.token }} |
| 69 | + tag: ${{ github.ref_name }} |
| 70 | + if: github.event.ref != 'refs/tags/v0.1.0' |
| 71 | + |
| 72 | + - name: create release |
| 73 | + |
| 74 | + with: |
| 75 | + allowUpdates: true |
| 76 | + draft: false |
| 77 | + makeLatest: true |
| 78 | + name: ${{ github.ref_name }} |
| 79 | + body: ${{ steps.changelog.outputs.changes }} |
| 80 | + token: ${{ github.token }} |
| 81 | + |
| 82 | + - uses: actions/download-artifact@v4 |
| 83 | + with: |
| 84 | + name: artifact |
| 85 | + path: dist |
| 86 | + |
| 87 | + - name: publish to pypi |
| 88 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 89 | + |
| 90 | + - name: pre-commit on changelog |
| 91 | + uses: pre-commit/[email protected] |
| 92 | + with: |
| 93 | + extra_args: --files CHANGELOG.md |
| 94 | + # we only run this to format CHANGELOG.md so pre-commit will fail (yet format it) |
| 95 | + continue-on-error: true |
| 96 | + |
| 97 | + - name: commit changelog |
| 98 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 99 | + with: |
| 100 | + branch: main |
| 101 | + commit_message: 'docs: update CHANGELOG.md for ${{ github.ref_name }} [skip ci]' |
| 102 | + file_pattern: CHANGELOG.md |
0 commit comments