Public: anyone can read this; nobody can change it.

seed-release: jq-free, tag keyed to upstream.json (#263) #266

Merged opened this view on origin

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

seed-release-jqfree → main 1 commit

  • Merged. seed-release-jqfree was merged into main.

Review

Sign in to review this change.
1 file changed +21 −17
.forgejo/workflows/seed-release.yml +21 −17
@@ -15,7 +15,12 @@
1515 #
1616 # The isolated pool's egress reaches in-cluster services ONLY — every API call
1717 # goes through $REGISTRY; the public $FORGEJO_URL is for printed links, never
18 # for calling (issue #263: every firing failed while the API base was public).
18 # for calling. The runner image ships NO jq (issue #263: every firing since
19 # birth died on `jq: command not found`) — this workflow uses nothing beyond
20 # curl/sed/tr/grep/tar, and it must stay that way.
21 # The tag comes from genesis/upstream.json `.release` (r<N>, the reseed run
22 # number — the same id the seed package is versioned by), never from parsing
23 # merge-commit prose or the manifest's seedVersion timestamp.
1924 # workflow_dispatch re-fires for the CURRENT genesis — idempotent (409 = done).
2025 name: seed-release
2126 on:
@@ -40,20 +45,17 @@ jobs:
4045 [ -n "$PLAT_PAT" ] || { echo "::error::secret PLAT_PAT is not set"; exit 1; }
4146 curl -fsS -H "Authorization: token $TOKEN" -o seed.tar.gz \
4247 "http://$REGISTRY/api/v1/repos/$GITHUB_REPOSITORY/raw/genesis/seed.tar.gz?ref=$GITHUB_SHA"
48 curl -fsS -H "Authorization: token $TOKEN" -o upstream.json \
49 "http://$REGISTRY/api/v1/repos/$GITHUB_REPOSITORY/raw/genesis/upstream.json?ref=$GITHUB_SHA"
4350 tar -xzOf seed.tar.gz ./manifest.yaml > manifest.yaml 2>/dev/null \
4451 || tar -xzOf seed.tar.gz manifest.yaml > manifest.yaml
4552 BASE=$(curl -fsS -H "Authorization: token $TOKEN" \
4653 "http://$REGISTRY/api/v1/repos/$GITHUB_REPOSITORY" \
4754 | sed -n 's#.*"html_url":"\(https\{0,1\}://[^"/]*\)/.*#\1#p')
4855 [ -n "$BASE" ] || { echo "::error::could not derive public base"; exit 1; }
49 # Tag from the reseed run number in the merge commit ("reseed r<N>"),
50 # falling back to the manifest's seedVersion stamp.
51 MSG=$(curl -fsS -H "Authorization: token $TOKEN" \
52 "http://$REGISTRY/api/v1/repos/$GITHUB_REPOSITORY/git/commits/$GITHUB_SHA" \
53 | sed -n 's/.*"message":"\([^"]*\)".*/\1/p')
54 RNUM=$(printf '%s' "$MSG" | grep -oE 'reseed r[0-9]+' | head -1 | grep -oE '[0-9]+' || true)
55 [ -n "$RNUM" ] || RNUM=$(sed -n 's/^seedVersion:[[:space:]]*r//p' manifest.yaml | head -1)
56 TAG="seed-r${RNUM:-$(printf '%.7s' "$GITHUB_SHA")}"
56 RNUM=$(sed -n 's/.*"release":[[:space:]]*"r\([0-9][0-9]*\)".*/\1/p' upstream.json | head -1)
57 [ -n "$RNUM" ] || { echo "::error::genesis/upstream.json carries no release id — a seed without one is broken"; exit 1; }
58 TAG="seed-r$RNUM"
5759 { echo "FORGEJO_URL=$BASE"; echo "TAG=$TAG"; } >> "$GITHUB_ENV"
5860 echo "releasing $TAG from $GITHUB_SHA"
5961
@@ -62,19 +64,21 @@ jobs:
6264 set -eu
6365 API="http://$REGISTRY/api/v1" # in-cluster — the pool cannot reach the public host
6466 AUTH="Authorization: token $PLAT_PAT"
65 PROFILE=$(sed -n 's/^profile:[[:space:]]*//p' manifest.yaml | head -1)
66 BODY=$(printf 'Gate-validated genesis seed (profile %s).\n\nManifest refs:\n```\n%s\n```\nPackage: %s/%s/-/packages\nFetch: SEED=latest bin/germinate (resolve_seed)' \
67 "${PROFILE:-lean}" "$(grep -E '^\s+(name|ref):' manifest.yaml | head -20)" "$FORGEJO_URL" "${GITHUB_REPOSITORY%%/*}")
68 code=$(jq -n --arg t "$TAG" --arg c "$GITHUB_SHA" --arg b "$BODY" \
69 '{tag_name:$t, target_commitish:$c, name:$t, body:$b}' \
70 | curl -s -o /tmp/rel.json -w '%{http_code}' -X POST -H "$AUTH" \
71 -H 'Content-Type: application/json' -d @- "$API/repos/$GITHUB_REPOSITORY/releases")
67 PROFILE=$(sed -n 's/^profile:[[:space:]]*//p' manifest.yaml | head -1 | tr -cd 'a-z0-9-')
68 BODY="Gate-validated genesis seed (profile ${PROFILE:-lean}). Package: $FORGEJO_URL/${GITHUB_REPOSITORY%%/*}/-/packages — fetch: SEED=latest bin/germinate (resolve_seed)."
69 printf '{"tag_name":"%s","target_commitish":"%s","name":"%s","body":"%s"}' \
70 "$TAG" "$GITHUB_SHA" "$TAG" "$BODY" > /tmp/rel-req.json
71 code=$(curl -s -o /tmp/rel.json -w '%{http_code}' -X POST -H "$AUTH" \
72 -H 'Content-Type: application/json' -d @/tmp/rel-req.json "$API/repos/$GITHUB_REPOSITORY/releases")
7273 case "$code" in
7374 201) : ;;
7475 409|422) echo "release $TAG already exists — nothing to do"; exit 0 ;;
7576 *) echo "::error::release create failed (HTTP $code): $(head -c200 /tmp/rel.json)"; exit 1 ;;
7677 esac
77 ID=$(jq -r .id /tmp/rel.json)
78 # First "id" in the response is the release's own (Go marshals struct
79 # order; ID is the Release struct's first field). Assert numeric.
80 ID=$(tr ',' '\n' < /tmp/rel.json | sed -n 's/.*"id":[[:space:]]*\([0-9][0-9]*\).*/\1/p' | head -1)
81 [ -n "$ID" ] || { echo "::error::could not read release id from response"; exit 1; }
7882 # Attachments are best-effort: a small [attachment] MAX_SIZE must not
7983 # sink the release — the body's package link always works.
8084 for f in seed.tar.gz manifest.yaml; do

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs