|
9 | 9 | name: Upload package |
10 | 10 |
|
11 | 11 | on: |
12 | | - release: |
13 | | - types: [created] |
14 | 12 | push: |
15 | | - tags: |
16 | | - - '*' |
| 13 | + pull_request: |
| 14 | + release: |
| 15 | + types: |
| 16 | + - published |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + |
| 22 | +env: |
| 23 | + FORCE_COLOR: 1 |
17 | 24 |
|
18 | 25 | jobs: |
19 | | - deploy: |
| 26 | + build-package: |
| 27 | + name: Build & verify package |
| 28 | + runs-on: ubuntu-latest |
| 29 | + |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 32 | + with: |
| 33 | + persist-credentials: false |
| 34 | + |
| 35 | + - uses: hynek/build-and-inspect-python-package@fe0a0fb1925ca263d076ca4f2c13e93a6e92a33e # v2.17.0 |
| 36 | + |
| 37 | + test-package: |
| 38 | + name: Test package |
| 39 | + if: | |
| 40 | + github.event.repository.fork == false |
| 41 | + && ( |
| 42 | + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) |
| 43 | + || github.event.action == 'published' |
| 44 | + ) |
| 45 | + needs: build-package |
| 46 | + uses: ./.github/workflows/tests.yml |
| 47 | + |
| 48 | + # Publish to TestPyPI for every tag. |
| 49 | + release-test-pypi: |
| 50 | + name: Publish to TestPyPI |
| 51 | + if: | |
| 52 | + github.event.repository.fork == false |
| 53 | + && github.event_name == 'push' |
| 54 | + && startsWith(github.ref, 'refs/tags/') |
| 55 | + runs-on: ubuntu-latest |
| 56 | + needs: test-package |
| 57 | + |
| 58 | + permissions: |
| 59 | + id-token: write |
| 60 | + |
| 61 | + steps: |
| 62 | + - name: Download packages built by build-and-inspect-python-package |
| 63 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 64 | + with: |
| 65 | + name: Packages |
| 66 | + path: dist |
| 67 | + |
| 68 | + - name: Publish to Test PyPI |
| 69 | + uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 |
| 70 | + with: |
| 71 | + repository-url: https://test.pypi.org/legacy/ |
| 72 | + |
| 73 | + release-pypi: |
| 74 | + name: Publish to PyPI |
| 75 | + # Only run for published releases. |
| 76 | + if: | |
| 77 | + github.event.repository.fork == false |
| 78 | + && github.event.action == 'published' |
20 | 79 | runs-on: ubuntu-latest |
| 80 | + needs: test-package |
| 81 | + |
21 | 82 | environment: |
22 | 83 | name: release |
23 | | - url: https://pypi.org/p/tzdata |
| 84 | + url: >- |
| 85 | + https://pypi.org/project/tzdata/${{ |
| 86 | + github.event.release.tag_name |
| 87 | + }} |
| 88 | +
|
24 | 89 | permissions: |
25 | 90 | id-token: write |
| 91 | + |
26 | 92 | steps: |
27 | | - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
28 | | - with: |
29 | | - persist-credentials: false |
30 | | - - name: Set up Python |
31 | | - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
32 | | - with: |
33 | | - python-version: '3.x' |
34 | | - - name: Install dependencies |
35 | | - run: | |
36 | | - python -m pip install --upgrade pip |
37 | | - pip install -U tox |
38 | | - - name: Create tox environments |
39 | | - run: | |
40 | | - tox -p -e py,build --notest |
41 | | - - name: Run tests |
42 | | - run: | |
43 | | - tox -e py |
44 | | - - name: Build package |
45 | | - run: | |
46 | | - tox -e build |
47 | | - - name: Publish package (TestPyPI) |
48 | | - if: github.event_name == 'push' |
49 | | - uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 |
50 | | - with: |
51 | | - repository-url: https://test.pypi.org/legacy/ |
52 | | - verbose: true |
53 | | - - name: Publish package |
54 | | - if: github.event_name == 'release' |
55 | | - uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 |
56 | | - with: |
57 | | - verbose: true |
| 93 | + - name: Download packages built by build-and-inspect-python-package |
| 94 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 95 | + with: |
| 96 | + name: Packages |
| 97 | + path: dist |
| 98 | + |
| 99 | + - name: Publish to PyPI |
| 100 | + uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 |
0 commit comments