Skip to content

Commit b4be7c6

Browse files
committed
ci: allow tagged package recovery
1 parent ca8de52 commit b4be7c6

3 files changed

Lines changed: 44 additions & 11 deletions

File tree

.github/workflows/build.yml

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
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

1317
permissions:
1418
contents: read
@@ -18,6 +22,8 @@ jobs:
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
@@ -31,6 +37,8 @@ jobs:
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
@@ -87,7 +99,21 @@ jobs:
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" \

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,9 @@ workflow artifact. A `vX.Y.Z` tag uses `X.Y.Z` and also publishes those files to
217217
the matching GitHub Release. The same tagged files are mirrored in GitHub
218218
Packages as the OCI artifact `ghcr.io/iotsharp/usbdisplaystack-deb:vX.Y.Z`;
219219
GitHub Packages does not provide a native Debian/APT package registry. The
220-
manual workflow dispatch can override the artifact version but does not publish
221-
a release or package.
220+
manual workflow dispatch can override the artifact version without publishing.
221+
Maintainers can instead set `release_tag` to an existing `vX.Y.Z` tag to rebuild
222+
that tag and recover its Release and Package assets.
222223

223224
The package contains its Debian lifecycle hooks and all project installation
224225
scripts. It deliberately does not activate the module or select the physical

README.zh-CN.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ GitHub Actions 会在每次 push 和 pull request 时执行同一套 PCCT 打包
193193
标签时使用 `X.Y.Z` 作为包版本,并把这三个文件上传到同名 GitHub Release;同时
194194
以 OCI artifact `ghcr.io/iotsharp/usbdisplaystack-deb:vX.Y.Z` 镜像到 GitHub
195195
Packages。GitHub Packages 本身不提供原生 Debian/APT 软件源类型。手动运行
196-
workflow 可以填写 artifact 版本号,但不会发布 Release 或 Package。
196+
workflow 时只填写版本号不会发布;维护者也可以把 `release_tag` 设为已有的
197+
`vX.Y.Z` 标签,从该标签重建并恢复对应的 Release 和 Package 资产。
197198

198199
DEB 已包含 Debian 生命周期脚本和项目的全部安装/卸载脚本。出于现场安全和
199200
replay 授权边界,安装后仍不会自动加载模块、选择实体后端或启动服务。离线安装、

0 commit comments

Comments
 (0)