Skip to content

Commit 775ea96

Browse files
ci(release): add workflow_dispatch; guard PyPI; push GHCR (#51)
1 parent 728cea1 commit 775ea96

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

.github/workflows/release.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,42 @@
11
name: release
22
on:
3+
workflow_dispatch:
4+
inputs:
5+
tag:
6+
description: 'Tag a publicar (e.g. v0.4.31)'
7+
required: false
38
push:
4-
tags: ['v*']
9+
tags:
10+
- 'v*'
11+
512
permissions:
613
contents: write
714
packages: write
15+
16+
env:
17+
TAG: ${{ github.ref_type == 'tag' && github.ref_name || inputs.tag }}
18+
819
jobs:
920
build-publish:
1021
runs-on: ubuntu-latest
1122
steps:
1223
- uses: actions/checkout@v4
24+
with: { fetch-depth: 0 }
1325
- uses: actions/setup-python@v5
1426
with: { python-version: '3.12' }
15-
- name: Build
27+
- name: Build sdist/wheel
1628
run: |
1729
python -m pip install -U pip build
1830
python -m build
1931
- uses: actions/upload-artifact@v4
2032
with: { name: dist, path: dist/* }
21-
- name: Publish to PyPI
22-
if: startsWith(github.ref, 'refs/tags/v') && secrets.PYPI_API_TOKEN != ''
33+
- name: Publish to PyPI (guarded)
34+
if: ${{ env.TAG != '' && startsWith(env.TAG, 'v') && secrets.PYPI_API_TOKEN != '' }}
2335
uses: pypa/gh-action-pypi-publish@release/v1
2436
with:
2537
user: __token__
2638
password: ${{ secrets.PYPI_API_TOKEN }}
39+
2740
publish-ghcr:
2841
needs: build-publish
2942
runs-on: ubuntu-latest
@@ -41,4 +54,6 @@ jobs:
4154
with:
4255
context: .
4356
push: true
44-
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ github.ref_name }}
57+
tags: |
58+
ghcr.io/${{ github.repository }}:latest
59+
ghcr.io/${{ github.repository }}:${{ env.TAG || github.ref_name }}

0 commit comments

Comments
 (0)