From fa055c08869b05b60cc96f0b3ee066aae46d854c Mon Sep 17 00:00:00 2001 From: Nils Andreas Svee Date: Wed, 26 Aug 2026 16:54:40 +0700 Subject: [PATCH] ci: support manual backfilling of past releases in Docker workflow Add a tag input to manual triggers to allow building and publishing specific past versions without clobbering the "latest" image tag. --- .gitea/workflows/docker-publish.yml | 37 +++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/docker-publish.yml b/.gitea/workflows/docker-publish.yml index 40d507e..c31698f 100644 --- a/.gitea/workflows/docker-publish.yml +++ b/.gitea/workflows/docker-publish.yml @@ -7,6 +7,13 @@ on: # ...); only the app package's tag corresponds to this image. - "irtt-rs/v*" workflow_dispatch: + inputs: + tag: + description: >- + Existing irtt-rs/vX.Y.Z tag to build and publish (backfill a past + release). Leave empty to build the ref this run was dispatched from. + required: false + type: string env: IMAGE_NAME: irtt-server @@ -22,19 +29,35 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.tag || github.ref }} - name: Determine image tags id: meta run: | - if [ "${GITHUB_REF_TYPE}" = "tag" ]; then - version="${GITHUB_REF_NAME#irtt-rs/v}" - echo "version=${version}" >> "$GITHUB_OUTPUT" + backfill_tag="${{ github.event.inputs.tag }}" + if [ -n "${backfill_tag}" ]; then + ref_name="${backfill_tag}" + # Backfilling a past release must never move "latest" onto an + # older build just because it's being published after the fact. + push_latest=false + else + ref_name="${GITHUB_REF_NAME}" + push_latest=true + fi + + if [[ "${ref_name}" == irtt-rs/v* ]]; then + version="${ref_name#irtt-rs/v}" + else + # Manual dispatch off a branch, no tag given: tag by commit only. + version="sha-$(git rev-parse --short HEAD)" + push_latest=false + fi + + echo "version=${version}" >> "$GITHUB_OUTPUT" + if [ "${push_latest}" = true ]; then echo "tags=${version},latest" >> "$GITHUB_OUTPUT" else - # Manual dispatch off a branch: tag by commit only, never touch - # "latest", so an ad-hoc build can't clobber the last release. - version="sha-$(git rev-parse --short HEAD)" - echo "version=${version}" >> "$GITHUB_OUTPUT" echo "tags=${version}" >> "$GITHUB_OUTPUT" fi