Skip to content

Commit ca4ace3

Browse files
fix: use deploy- tag prefix and fix oras resolve for artifact digest (#49)
Two issues in publish.sh: 1. Deploy artifacts were pushed to the same OCI tag as container images (e.g. ghcr.io/<owner>/agents-ui:v0.18.11), causing the deploy artifact push to overwrite the container image. Changed to deploy-<version> tag (e.g. deploy-v0.18.11) so both coexist in the same GHCR repository. 2. oras 1.2.3 does not support --digest-file. Removed that flag and instead resolve the digest via `oras resolve` after push. Co-authored-by: JorisJonkers Agent <agents@jorisjonkers.dev>
1 parent dc006b0 commit ca4ace3

1 file changed

Lines changed: 17 additions & 18 deletions

File tree

actions/deploy-artifact/publish.sh

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ main() {
4646
local artifact_version="${ARTIFACT_VERSION:?ARTIFACT_VERSION is required}"
4747
local render_hash="${RENDER_HASH:?RENDER_HASH is required}"
4848
local artifact_ref
49-
artifact_ref="ghcr.io/jorisjonkers-dev/${artifact_name}:${artifact_version}"
49+
# Use a "deploy-" tag prefix to avoid colliding with the container image tag.
50+
# Container images are pushed as ghcr.io/<owner>/<name>:<version> by
51+
# container-publish.yml; deploy artifacts use ghcr.io/<owner>/<name>:deploy-<version>
52+
# so they coexist in the same GHCR repository without overwriting each other.
53+
artifact_ref="ghcr.io/jorisjonkers-dev/${artifact_name}:deploy-${artifact_version}"
5054

5155
# (0) Authenticate to GHCR so oras push and cosign sign can write packages.
5256
# GITHUB_TOKEN is always injected by GitHub Actions (packages: write on the
@@ -72,13 +76,10 @@ main() {
7276

7377
local artifact_digest
7478

75-
# (2) Check if a deploy artifact tag already exists (idempotent publish).
76-
# Use --media-type to distinguish deploy artifacts from container images that
77-
# share the same tag (container images have a different manifest media type
78-
# and will not match, preventing false-positive idempotency hits).
79-
if oras manifest fetch "$artifact_ref" \
80-
--media-type "application/vnd.jorisjonkers.deployment.artifact.v1+tar" \
81-
> /dev/null 2>&1; then
79+
# (2) Check if the deploy artifact tag already exists (idempotent publish).
80+
# The "deploy-" tag prefix (e.g. "deploy-v1.2.3") ensures this tag can only
81+
# ever point to a deploy artifact — container images use a plain version tag.
82+
if oras manifest fetch "$artifact_ref" > /dev/null 2>&1; then
8283
# Deploy artifact tag exists: verify render-hash; fail on mismatch.
8384
local existing_digest
8485
existing_digest=$(oras resolve "$artifact_ref" 2>/dev/null)
@@ -102,21 +103,19 @@ main() {
102103
warn "artifact already exists with matching render-hash; skipping push (idempotent)"
103104
else
104105
# (3) Push artifact
106+
# oras 1.x does not support --digest-file; capture digest via oras resolve
107+
# after push, which also serves as the post-push verification (step 4).
105108
oras push "$artifact_ref" \
106109
--artifact-type "application/vnd.jorisjonkers.deployment.artifact.v1+tar" \
107-
artifact.tar \
108-
--digest-file pushed.digest
110+
artifact.tar
109111

112+
# (4) Resolve digest after push (also detects tag-move races)
110113
local pushed_digest
111-
pushed_digest=$(cat pushed.digest)
112-
113-
# (4) Post-push resolve verification (detect tag-move race)
114-
local resolved_digest
115-
resolved_digest=$(oras resolve "$artifact_ref" 2>/dev/null)
116-
if [[ "$resolved_digest" != "$pushed_digest" ]]; then
114+
pushed_digest=$(oras resolve "$artifact_ref" 2>/dev/null)
115+
if [[ -z "$pushed_digest" || "$pushed_digest" != sha256:* ]]; then
117116
emit_gate_summary "deploy-artifact" "Deploy Artifact" "fail" \
118-
"publish-race-tag-moved" "none"
119-
fail "E_PUBLISH_RACE_TAG_MOVED: pushed=${pushed_digest} resolved=${resolved_digest} (concurrent push moved tag)"
117+
"publish-resolve-failed" "none"
118+
fail "E_PUBLISH_RESOLVE_FAILED: could not resolve digest for ${artifact_ref} after push"
120119
fi
121120

122121
artifact_digest="$pushed_digest"

0 commit comments

Comments
 (0)