|
1 | 1 | ---
|
2 |
| -name: Build & maybe upload PyPI package |
| 2 | + name: Build & maybe upload PyPI package |
3 | 3 |
|
4 |
| -on: |
5 |
| - push: |
6 |
| - branches: [main] |
7 |
| - tags: ["*"] |
8 |
| - release: |
9 |
| - types: |
10 |
| - - published |
11 |
| - workflow_dispatch: |
| 4 | + on: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + tags: ["*"] |
| 8 | + release: |
| 9 | + types: |
| 10 | + - published |
| 11 | + workflow_dispatch: |
12 | 12 |
|
13 |
| -permissions: |
14 |
| - contents: read |
15 |
| - id-token: write |
| 13 | + permissions: |
| 14 | + contents: read |
| 15 | + id-token: write |
16 | 16 |
|
17 |
| -env: |
18 |
| - FORCE_COLOR: "1" # Make tools pretty. |
19 |
| - PIP_DISABLE_PIP_VERSION_CHECK: "1" |
20 |
| - PIP_NO_PYTHON_VERSION_WARNING: "1" |
| 17 | + env: |
| 18 | + FORCE_COLOR: "1" # Make tools pretty. |
| 19 | + PIP_DISABLE_PIP_VERSION_CHECK: "1" |
| 20 | + PIP_NO_PYTHON_VERSION_WARNING: "1" |
21 | 21 |
|
22 |
| -jobs: |
23 |
| - # Always build & lint package. |
24 |
| - build-package: |
25 |
| - name: Build & verify package |
26 |
| - runs-on: ubuntu-latest |
27 | 22 |
|
28 |
| - steps: |
29 |
| - - name: Set version |
30 |
| - if: github.event_name == 'push' && github.ref == 'refs/head/main' |
31 |
| - run: | |
32 |
| - echo "SETUPTOOLS_SCM_PRETEND_VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV |
| 23 | + jobs: |
| 24 | + # Always build & lint package. |
| 25 | + build-package: |
| 26 | + name: Build & verify package |
| 27 | + runs-on: ubuntu-latest |
33 | 28 |
|
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + fetch-depth: 0 |
34 | 33 |
|
35 |
| - - uses: actions/checkout@v4 |
36 |
| - with: |
37 |
| - fetch-depth: 0 |
| 34 | + - uses: hynek/build-and-inspect-python-package@v2 |
38 | 35 |
|
39 |
| - - uses: hynek/build-and-inspect-python-package@v2 |
| 36 | + # Upload to Test PyPI on every commit on main. |
| 37 | + release-test-pypi: |
| 38 | + name: Publish in-dev package to test.pypi.org |
| 39 | + if: github.repository_owner == 'alexrudy' && github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 40 | + environment: test-pypi-release |
| 41 | + runs-on: ubuntu-latest |
| 42 | + needs: build-package |
40 | 43 |
|
41 |
| - # Upload to Test PyPI on every commit on main. |
42 |
| - release-test-pypi: |
43 |
| - name: Publish in-dev package to test.pypi.org |
44 |
| - if: github.repository_owner == 'alexrudy' && github.ref == 'refs/head/main' |
45 |
| - environment: test-pypi-release |
46 |
| - runs-on: ubuntu-latest |
47 |
| - needs: build-package |
| 44 | + steps: |
| 45 | + - name: Download packages built by build-and-inspect-python-package |
| 46 | + uses: actions/download-artifact@v4 |
| 47 | + with: |
| 48 | + name: Packages |
| 49 | + path: dist |
48 | 50 |
|
49 |
| - steps: |
50 |
| - - name: Download packages built by build-and-inspect-python-package |
51 |
| - uses: actions/download-artifact@v4 |
52 |
| - with: |
53 |
| - name: Packages |
54 |
| - path: dist |
| 51 | + - name: Upload package to Test PyPI |
| 52 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 53 | + with: |
| 54 | + repository-url: https://test.pypi.org/legacy/ |
55 | 55 |
|
56 |
| - - name: Upload package to Test PyPI |
57 |
| - uses: pypa/gh-action-pypi-publish@release/v1 |
58 |
| - with: |
59 |
| - repository-url: https://test.pypi.org/legacy/ |
| 56 | + # Upload to real PyPI on GitHub Releases. |
| 57 | + release-pypi: |
| 58 | + name: Publish released package to pypi.org |
| 59 | + if: github.repository_owner == 'alexrudy' && github.event.action == 'published' |
| 60 | + environment: pypi-release |
| 61 | + runs-on: ubuntu-latest |
| 62 | + needs: build-package |
60 | 63 |
|
61 |
| - # Upload to real PyPI on GitHub Releases. |
62 |
| - release-pypi: |
63 |
| - name: Publish released package to pypi.org |
64 |
| - if: github.repository_owner == 'alexrudy' && github.event.action == 'published' |
65 |
| - environment: pypi-release |
66 |
| - runs-on: ubuntu-latest |
67 |
| - needs: build-package |
| 64 | + steps: |
| 65 | + - name: Download packages built by build-and-inspect-python-package |
| 66 | + uses: actions/download-artifact@v4 |
| 67 | + with: |
| 68 | + name: Packages |
| 69 | + path: dist |
68 | 70 |
|
69 |
| - steps: |
70 |
| - - name: Download packages built by build-and-inspect-python-package |
71 |
| - uses: actions/download-artifact@v4 |
72 |
| - with: |
73 |
| - name: Packages |
74 |
| - path: dist |
75 |
| - |
76 |
| - - name: Upload package to PyPI |
77 |
| - uses: pypa/gh-action-pypi-publish@release/v1 |
| 71 | + - name: Upload package to PyPI |
| 72 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments