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