6161 - name : Run tests
6262 run : poetry run pytest -v
6363
64- build-release :
65- name : Build and release
64+ build :
65+ name : Build distribution
6666 runs-on : ubuntu-latest
6767 needs : [code-quality, run-tests]
6868 steps :
@@ -78,18 +78,76 @@ jobs:
7878 - name : Build package
7979 run : poetry build
8080
81- - name : Publish package to PyPI
81+ - name : Store the distribution packages
8282 if : github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
83- run : poetry publish -n
84- env :
85- POETRY_PYPI_TOKEN_PYPI : ${{ secrets.pypi }}
83+ uses : actions/upload-artifact@v3
84+ with :
85+ name : python-package-distributions
86+ path : dist/
8687
87- - name : Update homebrew formula
88- # if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
88+ pypi-publish :
89+ name : Upload release to PyPI
90+ if : github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
91+ needs : [build]
92+ runs-on : ubuntu-latest
93+ environment :
94+ name : pypi
95+ url : https://pypi.org/p/poethepoet
96+ permissions :
97+ id-token : write
98+ steps :
99+ - name : Download all the dists
100+ uses : actions/download-artifact@v3
101+ with :
102+ name : python-package-distributions
103+ path : dist/
104+
105+ - name : Publish distribution 📦 to PyPI
106+ uses : pypa/gh-action-pypi-publish@release/v1
107+
108+ homebrew-publish :
109+ name : Upload homebrew formula
110+ needs : [pypi-publish]
111+ runs-on : ubuntu-latest
112+ steps :
113+ - name : Trigger update of homebrew formula
89114 run : >
90115 curl -L -X POST
91116 -H "Accept: application/vnd.github+json"
92117 -H "Authorization: Bearer ${{ secrets.homebrew_pat }}"
93118 -H "X-GitHub-Api-Version: 2022-11-28"
94119 https://api.github.com/repos/nat-n/homebrew-poethepoet/actions/workflows/71211730/dispatches
95120 -d '{"ref":"main", "inputs":{}}'
121+
122+ github-release :
123+ name : >-
124+ Sign the Python 🐍 distribution 📦 with Sigstore and upload them to GitHub Release
125+ needs : [pypi-publish]
126+ runs-on : ubuntu-latest
127+
128+ permissions :
129+ contents : write
130+ id-token : write
131+
132+ steps :
133+ - name : Download all the dists
134+ uses : actions/download-artifact@v3
135+ with :
136+ name : python-package-distributions
137+ path : dist/
138+ - name : Sign the dists with Sigstore
139+ uses : sigstore/gh-action-sigstore-python@v1.2.3
140+ with :
141+ inputs : >-
142+ ./dist/*.tar.gz
143+ ./dist/*.whl
144+ - name : Upload artifact signatures to GitHub Release
145+ env :
146+ GITHUB_TOKEN : ${{ github.token }}
147+ # Upload to GitHub Release using the `gh` CLI.
148+ # `dist/` contains the built packages, and the
149+ # sigstore-produced signatures and certificates.
150+ run : >-
151+ gh release upload
152+ '${{ github.ref_name }}' dist/**
153+ --repo '${{ github.repository }}'
0 commit comments