|
1 | 1 | name: Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - # Sequence of patterns matched against refs/tags |
6 | | - tags: |
7 | | - - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 |
8 | | - pull_request: |
9 | | - paths: |
10 | | - - .github/workflows/release.yml |
| 4 | + release: |
| 5 | + types: [published] |
11 | 6 |
|
12 | 7 | jobs: |
13 | | - release: |
14 | | - # requires that you have put your twine API key in your |
15 | | - # github secrets (see readme for details) |
| 8 | + build-and-inspect-package: |
| 9 | + name: Build & inspect package. |
16 | 10 | runs-on: ubuntu-latest |
17 | | - permissions: |
18 | | - contents: write |
| 11 | + if: startsWith(github.ref, 'refs/tags/v') |
19 | 12 | steps: |
20 | 13 | - uses: actions/checkout@v4 |
21 | | - with: |
22 | | - fetch-depth: 0 |
23 | 14 | - uses: hynek/build-and-inspect-python-package@v2 |
24 | | - id: build_dist |
25 | | - - name: determine tag |
26 | | - run: echo "tag=${GITHUB_REF/refs\/tags\/v/}" >> "$GITHUB_ENV" |
27 | | - - name: debug dist |
28 | | - run: | |
29 | | - set -x |
30 | | - echo "dist=${{ steps.build_dist.outputs.dist }}" |
31 | | - ls -l ${{ steps.build_dist.outputs.dist }} |
32 | | - mkdir -p dist |
33 | | - cp ${{ steps.build_dist.outputs.dist }}/*.whl ./dist/ |
34 | | - cp ${{ steps.build_dist.outputs.dist }}/*.gz ./dist/ |
35 | 15 |
|
36 | | - - name: Create Release |
37 | | - uses: "softprops/action-gh-release@v2" |
38 | | - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 16 | + upload-to-pypi: |
| 17 | + name: Upload package to PyPI |
| 18 | + needs: build-and-inspect-package |
| 19 | + runs-on: ubuntu-latest |
| 20 | + if: startsWith(github.ref, 'refs/tags/v') |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Download built artifact to dist/ |
| 24 | + uses: actions/download-artifact@v4 |
39 | 25 | with: |
40 | | - tag_name: ${{ github.ref }} |
41 | | - name: ${{ env.tag }} |
42 | | - draft: false |
43 | | - prerelease: ${{ contains(env.tag, 'rc') || contains(env.tag, 'a') || contains(env.tag, 'b') }} |
44 | | - target_commitish: ${{ github.sha }} |
45 | | - files: dist/* |
46 | | - - name: Publish PyPI Package |
47 | | - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
48 | | - uses: pypa/gh-action-pypi-publish@release/v1 |
| 26 | + name: Packages |
| 27 | + path: dist |
| 28 | + - uses: pypa/gh-action-pypi-publish@release/v1 |
49 | 29 | with: |
50 | 30 | password: ${{ secrets.TWINE_API_KEY }} |
0 commit comments