@@ -2,44 +2,26 @@ name: release
22on :
33 push :
44 tags : ['v*']
5- workflow_dispatch :
6- inputs :
7- tag :
8- description : ' Tag to publish (v*)'
9- required : false
5+
106permissions :
11- contents : write
7+ contents : read
128 packages : write
139
14- jobs :
15- build-publish :
16- runs-on : ubuntu-latest
17- steps :
18- - uses : actions/checkout@v4
19- - uses : actions/setup-python@v5
20- with : { python-version: '3.12' }
21- - name : Build
22- run : |
23- python -m pip install -U pip build
24- python -m build
25- - uses : actions/upload-artifact@v4
26- with : { name: dist, path: dist/* }
27- - name : Publish to PyPI (guarded)
28- if : startsWith(github.ref, 'refs/tags/v') && secrets.PYPI_API_TOKEN != ''
29- uses : pypa/gh-action-pypi-publish@release/v1
30- with :
31- user : __token__
32- password : ${{ secrets.PYPI_API_TOKEN }}
10+ concurrency :
11+ group : release-${{ github.ref }}
12+ cancel-in-progress : true
3313
34- publish-ghcr :
35- needs : build-publish
14+ jobs :
15+ ghcr :
16+ name : Publish GHCR
3617 runs-on : ubuntu-latest
37- permissions : { contents: read, packages: write }
3818 steps :
3919 - uses : actions/checkout@v4
4020 - name : Compute image name (lowercase)
4121 shell : bash
4222 run : echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY@L}" >> "$GITHUB_ENV"
23+ - uses : docker/setup-qemu-action@v3
24+ - uses : docker/setup-buildx-action@v3
4325 - uses : docker/login-action@v3
4426 with :
4527 registry : ghcr.io
4830 - uses : docker/build-push-action@v6
4931 with :
5032 context : .
33+ platforms : linux/amd64
5134 push : true
35+ provenance : false
5236 tags : ${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ github.ref_name }}
37+
38+ pypi :
39+ name : Publish PyPI (guarded)
40+ if : ${{ secrets.PYPI_API_TOKEN != '' }}
41+ needs : ghcr
42+ runs-on : ubuntu-latest
43+ permissions :
44+ contents : read
45+ steps :
46+ - uses : actions/checkout@v4
47+ - uses : actions/setup-python@v5
48+ with : { python-version: '3.12' }
49+ - name : Build sdist/wheel
50+ run : |
51+ python -m pip install -U pip build
52+ python -m build
53+ - uses : pypa/gh-action-pypi-publish@release/v1
54+ with :
55+ user : __token__
56+ password : ${{ secrets.PYPI_API_TOKEN }}
0 commit comments