99 description : ' DEB version; leave blank for an automatic CI or tag version'
1010 required : false
1111 type : string
12+ release_tag :
13+ description : ' Existing vX.Y.Z tag to rebuild and publish; leave blank for artifact only'
14+ required : false
15+ type : string
1216
1317permissions :
1418 contents : read
1822 runs-on : ubuntu-latest
1923 steps :
2024 - uses : actions/checkout@v5
25+ with :
26+ ref : ${{ inputs.release_tag || github.ref }}
2127 - name : Build userspace and tools
2228 run : make userspace
2329 - name : Test readiness checker
3137 KERNEL_RELEASE : 4.15.0-60-generic
3238 steps :
3339 - uses : actions/checkout@v5
40+ with :
41+ ref : ${{ inputs.release_tag || github.ref }}
3442
3543 - name : Build target-kernel module without a bind mount
3644 shell : bash
@@ -68,13 +76,17 @@ jobs:
6876 needs : kernel-4-15
6977 outputs :
7078 version : ${{ steps.version.outputs.version }}
79+ source_revision : ${{ steps.version.outputs.source_revision }}
7180 env :
7281 KERNEL_RELEASE : 4.15.0-60-generic
7382 KERNEL_ARCHITECTURE : i386
7483 PCCT_IMAGE : ghcr.io/iotsharp/pcct-build-x86:latest
7584 REQUESTED_VERSION : ${{ inputs.version }}
85+ RELEASE_TAG : ${{ inputs.release_tag }}
7686 steps :
7787 - uses : actions/checkout@v5
88+ with :
89+ ref : ${{ inputs.release_tag || github.ref }}
7890
7991 - name : Download target-kernel module
8092 uses : actions/download-artifact@v4
8799 shell : bash
88100 run : |
89101 set -eu
90- if [ -n "$REQUESTED_VERSION" ]; then
102+ if [ -n "$RELEASE_TAG" ]; then
103+ case "$RELEASE_TAG" in
104+ v[0-9]*) ;;
105+ *)
106+ printf 'Invalid release tag: %s\n' "$RELEASE_TAG" >&2
107+ exit 2
108+ ;;
109+ esac
110+ version="${RELEASE_TAG#v}"
111+ if [ -n "$REQUESTED_VERSION" ] && [ "$REQUESTED_VERSION" != "$version" ]; then
112+ printf 'Version %s does not match release tag %s\n' \
113+ "$REQUESTED_VERSION" "$RELEASE_TAG" >&2
114+ exit 2
115+ fi
116+ elif [ -n "$REQUESTED_VERSION" ]; then
91117 version="$REQUESTED_VERSION"
92118 elif [[ "$GITHUB_REF" == refs/tags/v* ]]; then
93119 version="${GITHUB_REF_NAME#v}"
@@ -102,6 +128,7 @@ jobs:
102128 *) ;;
103129 esac
104130 printf 'version=%s\n' "$version" >> "$GITHUB_OUTPUT"
131+ printf 'source_revision=%s\n' "$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
105132 printf 'Building USBDisplayStack version %s\n' "$version"
106133
107134 - name : Build and package with PCCT
@@ -149,7 +176,9 @@ jobs:
149176
150177 publish-tag :
151178 name : publish tagged Debian package
152- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
179+ if : >-
180+ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) ||
181+ (github.event_name == 'workflow_dispatch' && inputs.release_tag != '')
153182 runs-on : ubuntu-latest
154183 needs : debian-package
155184 permissions :
@@ -158,6 +187,8 @@ jobs:
158187 env :
159188 OCI_PACKAGE : ghcr.io/iotsharp/usbdisplaystack-deb
160189 PACKAGE_VERSION : ${{ needs.debian-package.outputs.version }}
190+ RELEASE_TAG : ${{ inputs.release_tag || github.ref_name }}
191+ SOURCE_REVISION : ${{ needs.debian-package.outputs.source_revision }}
161192 steps :
162193 - name : Download Debian package
163194 uses : actions/download-artifact@v4
@@ -181,13 +212,13 @@ jobs:
181212 printf 'Expected three release assets, found %s\n' "${#assets[@]}" >&2
182213 exit 1
183214 fi
184- if ! gh release view "$GITHUB_REF_NAME " >/dev/null 2>&1; then
185- gh release create "$GITHUB_REF_NAME " \
215+ if ! gh release view "$RELEASE_TAG " >/dev/null 2>&1; then
216+ gh release create "$RELEASE_TAG " \
186217 --verify-tag \
187- --title "$GITHUB_REF_NAME " \
218+ --title "$RELEASE_TAG " \
188219 --generate-notes
189220 fi
190- gh release upload "$GITHUB_REF_NAME " "${assets[@]}" --clobber
221+ gh release upload "$RELEASE_TAG " "${assets[@]}" --clobber
191222
192223 - name : Install ORAS
193224 uses : oras-project/setup-oras@v1
@@ -207,10 +238,10 @@ jobs:
207238 printf '%s' "$GHCR_TOKEN" | oras login ghcr.io \
208239 --username "$GITHUB_ACTOR" \
209240 --password-stdin
210- oras push "$OCI_PACKAGE:$GITHUB_REF_NAME " \
241+ oras push "$OCI_PACKAGE:$RELEASE_TAG " \
211242 --artifact-type application/vnd.iotsharp.usbdisplaystack.debian.v1 \
212243 --annotation "org.opencontainers.image.source=https://github.com/$GITHUB_REPOSITORY" \
213- --annotation "org.opencontainers.image.revision=$GITHUB_SHA " \
244+ --annotation "org.opencontainers.image.revision=$SOURCE_REVISION " \
214245 --annotation "org.opencontainers.image.version=$PACKAGE_VERSION" \
215246 --annotation "org.opencontainers.image.title=USBDisplayStack Debian package" \
216247 "$package:application/vnd.debian.binary-package" \
0 commit comments