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
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
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" \
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