Skip to content

Commit 3d8a5e8

Browse files
committed
ci: publish the private-drop exporter image to GHCR
Collection switches to AMD's image per the 2026-10-12 channel decision, so the workflow tags the loaded image on the public package and records the digest on the draft release. The squash conversion is skipped when the asset already exists. 中文:按 2026-10-12 频道决定,采集切换到 AMD 镜像;工作流将加载的镜像推送到公开 GHCR 包并把 digest 记录到草稿 release,squash 已存在时跳过转换。
1 parent ba92f2b commit 3d8a5e8

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

‎.github/workflows/amd-exporter-privatedrop.yml‎

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
runs-on: ubuntu-24.04
3232
permissions:
3333
contents: write # Draft release assets are readable and writable only with write access.
34+
packages: write # Publish the image to the repository-linked GHCR package.
3435
timeout-minutes: 40
3536
env:
3637
ARCHIVE_NAME: device-metrics-exporter-latest.tar.gz
@@ -39,6 +40,8 @@ jobs:
3940
IMAGE_CONFIG_ID: sha256:bb0ffcde637f2ff05c5b2118e19445f9663d7418aa6affbd202d54a0a78880b7
4041
LOCAL_TAG: amd-dme-highres:privatedrop-20261008
4142
SQSH_NAME: amd-exporter-highres-20261008.sqsh
43+
# Collection pulls this tag from the public package that also holds the patched build it replaces.
44+
GHCR_REF: ghcr.io/semianalysisai/amd-device-metrics-exporter:highres-privatedrop-20261008
4245
ENROOT_PACKAGE: enroot_4.2.0-1_amd64.deb
4346
ENROOT_PACKAGE_SHA256: 50bfcf8336bfe1a5d19481081d7800ae80300a27795595757f7d20957e079a62
4447
WORK: ${{ github.workspace }}/.privatedrop
@@ -60,6 +63,10 @@ jobs:
6063
echo "skip=true" >> "$GITHUB_OUTPUT"
6164
exit 0
6265
fi
66+
if python3 .github/scripts/draft_release_asset.py --tag "$RELEASE_TAG" --find "$SQSH_NAME" > /dev/null 2>&1; then
67+
echo "::notice::$SQSH_NAME is already on the draft release; skipping the conversion"
68+
echo "squash_exists=true" >> "$GITHUB_OUTPUT"
69+
fi
6370
python3 .github/scripts/draft_release_asset.py --tag "$RELEASE_TAG" --find "$ARCHIVE_NAME" > "$WORK/archive-asset.json"
6471
asset_url=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["url"])' "$WORK/archive-asset.json")
6572
curl --fail --location --silent --show-error --output "$WORK/$ARCHIVE_NAME" \
@@ -78,7 +85,7 @@ jobs:
7885
echo "version probe unavailable on CPU: $(tail -n 1 "$WORK/version.txt")"
7986
cat "$WORK/version.txt"
8087
- name: Convert to an Enroot squash
81-
if: steps.download.outputs.skip != 'true'
88+
if: steps.download.outputs.skip != 'true' && steps.download.outputs.squash_exists != 'true'
8289
run: |
8390
set -eo pipefail
8491
curl --fail --location --output "$WORK/$ENROOT_PACKAGE" \
@@ -111,7 +118,7 @@ jobs:
111118
sha256sum "$SQSH_NAME" provenance.json > SHA256SUMS
112119
cat SHA256SUMS
113120
- name: Store the squash on the draft release
114-
if: steps.download.outputs.skip != 'true'
121+
if: steps.download.outputs.skip != 'true' && steps.download.outputs.squash_exists != 'true'
115122
env:
116123
GITHUB_TOKEN: ${{ github.token }}
117124
RELEASE_TAG: ${{ inputs.release-tag || 'amd-dme-highres-privatedrop-20261008' }}
@@ -121,3 +128,27 @@ jobs:
121128
python3 .github/scripts/draft_release_asset.py --tag "$RELEASE_TAG" --put "$WORK/$name" --name "$name"
122129
done
123130
python3 .github/scripts/draft_release_asset.py --tag "$RELEASE_TAG" --list
131+
- name: Publish the image to GHCR
132+
if: steps.download.outputs.skip != 'true'
133+
env:
134+
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135+
GITHUB_TOKEN: ${{ github.token }}
136+
RELEASE_TAG: ${{ inputs.release-tag || 'amd-dme-highres-privatedrop-20261008' }}
137+
run: |
138+
set -eo pipefail
139+
printf '%s' "$GHCR_TOKEN" | docker login ghcr.io --username "$GITHUB_ACTOR" --password-stdin
140+
if docker manifest inspect "$GHCR_REF" > "$WORK/ghcr-manifest.json" 2> /dev/null; then
141+
echo "::notice::$GHCR_REF already exists; the tag is not re-pushed so its digest stays stable"
142+
else
143+
docker tag "$LOCAL_TAG" "$GHCR_REF"
144+
docker push "$GHCR_REF"
145+
docker manifest inspect "$GHCR_REF" > "$WORK/ghcr-manifest.json"
146+
fi
147+
digest=$(docker manifest inspect -v "$GHCR_REF" | python3 -c 'import json, sys
148+
doc = json.load(sys.stdin)
149+
doc = doc[0] if isinstance(doc, list) else doc
150+
print(doc["Descriptor"]["digest"])')
151+
printf '%s@%s\n' "${GHCR_REF%%:*}" "$digest" > "$WORK/ghcr-digest.txt"
152+
cat "$WORK/ghcr-digest.txt"
153+
printf '### GHCR\n`%s`\n' "$(cat "$WORK/ghcr-digest.txt")" >> "$GITHUB_STEP_SUMMARY"
154+
python3 .github/scripts/draft_release_asset.py --tag "$RELEASE_TAG" --put "$WORK/ghcr-digest.txt" --name ghcr-digest.txt

0 commit comments

Comments
 (0)