Skip to content

Commit 79d5c20

Browse files
adding a workflow dispatch for creating images without releases
1 parent b72151b commit 79d5c20

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

.github/workflows/pypi.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
jobs:
88
test-pypi:
99
name: Publish to TestPyPI
10+
if: github.event.release.prerelease == false
1011
runs-on: ubuntu-latest
1112
environment:
1213
name: release
@@ -21,6 +22,7 @@ jobs:
2122
UV_PUBLISH_URL: https://test.pypi.org/legacy/
2223
pypi:
2324
name: Publish to PyPI
25+
if: github.event.release.prerelease == false
2426
needs:
2527
- test-pypi
2628
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,24 @@ name: 'Release a new version to Github Packages'
33
on:
44
release:
55
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
image_tag:
9+
description: "Docker tag to publish (e.g. 2.0.0-test)"
10+
required: true
11+
type: string
12+
update_latest:
13+
description: "Also overwrite the :latest tag"
14+
required: false
15+
type: boolean
16+
default: false
617

718
env:
819
REGISTRY: ghcr.io
920

1021
jobs:
1122
push_to_registry:
12-
name: Push Docker image to GitHub Packages tagged with "latest" and version number.
23+
name: Push Docker image to GitHub Packages.
1324
runs-on: ubuntu-latest
1425
permissions:
1526
contents: read
@@ -23,16 +34,29 @@ jobs:
2334
registry: ${{ env.REGISTRY }}
2435
username: ${{ github.actor }}
2536
password: ${{ secrets.GITHUB_TOKEN }}
26-
- name: Extract metadata (tags, labels) for Docker
27-
id: meta
37+
- name: Extract metadata (release path)
38+
if: github.event_name == 'release'
39+
id: meta_release
2840
uses: docker/metadata-action@v5
2941
with:
3042
images:
3143
ghcr.io/${{ github.repository }}
44+
- name: Extract metadata (manual path)
45+
if: github.event_name == 'workflow_dispatch'
46+
id: meta_manual
47+
uses: docker/metadata-action@v5
48+
with:
49+
images:
50+
ghcr.io/${{ github.repository }}
51+
tags: |
52+
type=raw,value=${{ inputs.image_tag }}
53+
type=raw,value=latest,enable=${{ inputs.update_latest }}
54+
flavor: |
55+
latest=false
3256
- name: Push to GitHub Packages
3357
uses: docker/build-push-action@v6
3458
with:
3559
context: .
3660
push: true
37-
tags: ${{ steps.meta.outputs.tags }}
38-
labels: ${{ steps.meta.outputs.labels }}
61+
tags: ${{ steps.meta_release.outputs.tags || steps.meta_manual.outputs.tags }}
62+
labels: ${{ steps.meta_release.outputs.labels || steps.meta_manual.outputs.labels }}

0 commit comments

Comments
 (0)