Skip to content

Commit 5fb125e

Browse files
ci(release): lowercase GHCR image; keep PyPI guarded; add manual trigger (#52)
1 parent 775ea96 commit 5fb125e

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

.github/workflows/release.yml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,31 @@
11
name: release
22
on:
3+
push:
4+
tags: ['v*']
35
workflow_dispatch:
46
inputs:
57
tag:
6-
description: 'Tag a publicar (e.g. v0.4.31)'
8+
description: 'Tag to publish (v*)'
79
required: false
8-
push:
9-
tags:
10-
- 'v*'
11-
1210
permissions:
1311
contents: write
1412
packages: write
1513

16-
env:
17-
TAG: ${{ github.ref_type == 'tag' && github.ref_name || inputs.tag }}
18-
1914
jobs:
2015
build-publish:
2116
runs-on: ubuntu-latest
2217
steps:
2318
- uses: actions/checkout@v4
24-
with: { fetch-depth: 0 }
2519
- uses: actions/setup-python@v5
2620
with: { python-version: '3.12' }
27-
- name: Build sdist/wheel
21+
- name: Build
2822
run: |
2923
python -m pip install -U pip build
3024
python -m build
3125
- uses: actions/upload-artifact@v4
3226
with: { name: dist, path: dist/* }
3327
- name: Publish to PyPI (guarded)
34-
if: ${{ env.TAG != '' && startsWith(env.TAG, 'v') && secrets.PYPI_API_TOKEN != '' }}
28+
if: startsWith(github.ref, 'refs/tags/v') && secrets.PYPI_API_TOKEN != ''
3529
uses: pypa/gh-action-pypi-publish@release/v1
3630
with:
3731
user: __token__
@@ -40,11 +34,12 @@ jobs:
4034
publish-ghcr:
4135
needs: build-publish
4236
runs-on: ubuntu-latest
43-
permissions:
44-
contents: read
45-
packages: write
37+
permissions: { contents: read, packages: write }
4638
steps:
4739
- uses: actions/checkout@v4
40+
- name: Compute image name (lowercase)
41+
shell: bash
42+
run: echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY@L}" >> "$GITHUB_ENV"
4843
- uses: docker/login-action@v3
4944
with:
5045
registry: ghcr.io
@@ -54,6 +49,4 @@ jobs:
5449
with:
5550
context: .
5651
push: true
57-
tags: |
58-
ghcr.io/${{ github.repository }}:latest
59-
ghcr.io/${{ github.repository }}:${{ env.TAG || github.ref_name }}
52+
tags: ${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ github.ref_name }}

0 commit comments

Comments
 (0)