@@ -195,13 +195,19 @@ jobs:
195195 - name : Run Bandit
196196 run : bandit -c pyproject.toml -r typed_stream examples
197197
198+ is_on_main :
199+ name : Run this if on main
200+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
201+ runs-on : ubuntu-latest
202+ steps : []
203+
198204 github-pages :
199205 name : GitHub Pages
200- if : github.event_name == 'push' && github.ref == 'refs/heads/main'
201206 runs-on : ubuntu-latest
202207 timeout-minutes : 5
203208 needs :
204209 - test
210+ - is_on_main
205211 permissions :
206212 contents : read
207213 id-token : write
@@ -240,3 +246,110 @@ jobs:
240246 - name : Deploy GitHub Pages site
241247 id : deployment
242248 uses : actions/deploy-pages@v4
249+
250+ get_version :
251+ name : Get version
252+ runs-on : ubuntu-latest
253+ outputs :
254+ version : ${{ steps.version.outputs.version }}
255+ latest_version : ${{ steps.version.outputs.latest_version }}
256+ steps :
257+ - name : Checkout repository
258+ uses : actions/checkout@v4
259+ with :
260+ fetch-depth : 0
261+ fetch-tags : true
262+ filter : blob:none
263+ - name : Setup Python
264+ uses : actions/setup-python@v5
265+ with :
266+ python-version : " 3.10"
267+ - name : Get current version
268+ id : version
269+ run : |
270+ echo -n "version=" >> $GITHUB_OUTPUT
271+ ./typed_stream/version.py >> $GITHUB_OUTPUT
272+ - name : Get latest version
273+ id : latest_version
274+ run : |
275+ echo -n "latest_version=" >> $GITHUB_OUTPUT
276+ git describe --tags --abbrev=0 >> $GITHUB_OUTPUT
277+
278+ build_release :
279+ name : Build release
280+ runs-on : ubuntu-latest
281+ if : needs.get_version.outputs.version != needs.get_version.outputs.latest_version
282+ needs :
283+ - fix_stupid_mistakes
284+ - test
285+ - test-rustpython
286+ - mypy
287+ - pytype
288+ - flake8
289+ - pylint
290+ - bandit
291+ - is_on_main
292+ - get_version
293+ steps :
294+ - name : Checkout repository
295+ uses : actions/checkout@v4
296+ - name : Setup Python
297+ uses : actions/setup-python@v5
298+ with :
299+ python-version : " 3.10"
300+ - name : Install build frontend
301+ run : grep "^build==" requirements-dev.txt | xargs pip install
302+ - name : Build
303+ run : make build
304+ - name : Upload as build artifact
305+ uses : actions/upload-artifact@v4
306+ with :
307+ name : release_build
308+ path : dist
309+
310+ pypi :
311+ name : Upload to PyPI
312+ runs-on : ubuntu-latest
313+ needs :
314+ - build_release
315+ permissions : {}
316+ steps :
317+ - name : Setup Python
318+ uses : actions/setup-python@v5
319+ with :
320+ python-version : " 3.10"
321+ - name : Download artifact
322+ uses : actions/download-artifact@v4
323+ with :
324+ name : release_build
325+ - name : Install Twine
326+ run : pip install "twine==4.*"
327+ - name : Run Twine
328+ run : |
329+ twine check --strict *.tar.gz *.whl
330+ twine upload --verbose --disable-progress-bar *.tar.gz *.whl
331+ env :
332+ TWINE_USERNAME : __token__
333+ TWINE_PASSWORD : ${{ secrets.PYPI_TOKEN }}
334+
335+ release :
336+ name : Create release
337+ runs-on : ubuntu-latest
338+ permissions :
339+ contents : write
340+ needs :
341+ - build_release
342+ - get_version
343+ steps :
344+ - name : Download artifact
345+ uses : actions/download-artifact@v4
346+ with :
347+ name : release_build
348+ - name : Create release
349+ uses : softprops/action-gh-release@v2
350+ with :
351+ tag_name : ${{ needs.get_version.outputs.version }}
352+ generate_release_notes : true
353+ files : |
354+ *.tar.gz
355+ *.whl
0 commit comments