|
1 | 1 | name: release-pipeline |
2 | 2 |
|
3 | 3 | on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
4 | 7 | release: |
5 | 8 | types: |
6 | | - - created |
| 9 | + - published |
7 | 10 |
|
8 | 11 | jobs: |
9 | | - release-job: |
| 12 | + build-package: |
10 | 13 | runs-on: ubuntu-latest |
11 | | - env: |
12 | | - PYPI_TOKEN: ${{ secrets.PYPI_TOKEN_PYMC }} |
| 14 | + permissions: |
| 15 | + # write attestations and id-token are necessary for attest-build-provenance-github |
| 16 | + attestations: write |
| 17 | + id-token: write |
13 | 18 | steps: |
14 | | - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 |
15 | | - - name: Set up Python |
16 | | - uses: actions/setup-python@v5 |
17 | | - with: |
18 | | - python-version: 3.7 |
19 | | - # TODO: ideally, this pipeline should run parallelized tests in upstream jobs.. |
20 | | - #- name: Install test tooling |
21 | | - # run: | |
22 | | - # pip install pytest pytest-cov nose nose-parameterized |
23 | | - # pip install -r requirements.txt |
24 | | - #- name: Run tests |
25 | | - # run: | |
26 | | - # pytest --cov=./pymc --cov-report term-missing pymc/ |
27 | | - - name: Install release tooling |
28 | | - run: | |
29 | | - pip install build twine |
30 | | - - name: Build package |
31 | | - run: | |
32 | | - python -m build |
33 | | - - name: Check version number match |
34 | | - run: | |
35 | | - echo "GITHUB_REF: ${GITHUB_REF}" |
36 | | - # The GITHUB_REF should be something like "refs/tags/v1.2.3" |
37 | | - # Make sure the package version is the same as the tag |
38 | | - grep -Rq "^Version: ${GITHUB_REF:11}$" pymc.egg-info/PKG-INFO |
39 | | - - name: Publish to PyPI |
40 | | - run: | |
41 | | - twine check dist/* |
42 | | - twine upload --repository pypi --username __token__ --password ${PYPI_TOKEN} dist/* |
43 | | - test-install-job: |
44 | | - needs: release-job |
| 19 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + persist-credentials: false |
| 23 | + - uses: hynek/build-and-inspect-python-package@14c7e53f5d033cfa99f7af916fa59a6f7f356394 # v2.11.0 |
| 24 | + with: |
| 25 | + # Prove that the packages were built in the context of this workflow. |
| 26 | + attest-build-provenance-github: true |
| 27 | + |
| 28 | + publish-package: |
| 29 | + # Don't publish from forks |
| 30 | + if: github.repository_owner == 'pymc-devs' && github.event_name == 'release' && github.event.action == 'published' |
| 31 | + # Use the `release` GitHub environment to protect the Trusted Publishing (OIDC) |
| 32 | + # workflow by requiring signoff from a maintainer. |
| 33 | + environment: release |
| 34 | + needs: build-package |
45 | 35 | runs-on: ubuntu-latest |
| 36 | + permissions: |
| 37 | + # write id-token is necessary for trusted publishing (OIDC) |
| 38 | + id-token: write |
46 | 39 | steps: |
47 | | - - name: Set up Python |
48 | | - uses: actions/setup-python@v5 |
49 | | - with: |
50 | | - python-version: 3.7 |
51 | | - - name: Give PyPI a chance to update the index |
52 | | - run: sleep 240 |
53 | | - - name: Install from PyPI |
54 | | - run: | |
55 | | - pip install pymc==${GITHUB_REF:11} |
| 40 | + - name: Download Distribution Artifacts |
| 41 | + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 |
| 42 | + with: |
| 43 | + # The build-and-inspect-python-package action invokes upload-artifact. |
| 44 | + # These are the correct arguments from that action. |
| 45 | + name: Packages |
| 46 | + path: dist |
| 47 | + - name: Publish Package to PyPI |
| 48 | + uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.3 |
| 49 | + # Implicitly attests that the packages were uploaded in the context of this workflow. |
0 commit comments