Public: anyone can read this; nobody can change it.
seed-release: jq-free, tag keyed to upstream.json (#263) #266
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
seed-release-jqfree → main 1 commit
1 file
changed +21
−17
.forgejo/workflows/seed-release.yml +21 −17
| @@ -15,7 +15,12 @@ | ||
| 15 | 15 | # |
| 16 | 16 | # The isolated pool's egress reaches in-cluster services ONLY — every API call |
| 17 | 17 | # 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. | |
| 19 | 24 | # workflow_dispatch re-fires for the CURRENT genesis — idempotent (409 = done). |
| 20 | 25 | name: seed-release |
| 21 | 26 | on: |
| @@ -40,20 +45,17 @@ jobs: | ||
| 40 | 45 | [ -n "$PLAT_PAT" ] || { echo "::error::secret PLAT_PAT is not set"; exit 1; } |
| 41 | 46 | curl -fsS -H "Authorization: token $TOKEN" -o seed.tar.gz \ |
| 42 | 47 | "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" | |
| 43 | 50 | tar -xzOf seed.tar.gz ./manifest.yaml > manifest.yaml 2>/dev/null \ |
| 44 | 51 | || tar -xzOf seed.tar.gz manifest.yaml > manifest.yaml |
| 45 | 52 | BASE=$(curl -fsS -H "Authorization: token $TOKEN" \ |
| 46 | 53 | "http://$REGISTRY/api/v1/repos/$GITHUB_REPOSITORY" \ |
| 47 | 54 | | sed -n 's#.*"html_url":"\(https\{0,1\}://[^"/]*\)/.*#\1#p') |
| 48 | 55 | [ -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" | |
| 57 | 59 | { echo "FORGEJO_URL=$BASE"; echo "TAG=$TAG"; } >> "$GITHUB_ENV" |
| 58 | 60 | echo "releasing $TAG from $GITHUB_SHA" |
| 59 | 61 | |
| @@ -62,19 +64,21 @@ jobs: | ||
| 62 | 64 | set -eu |
| 63 | 65 | API="http://$REGISTRY/api/v1" # in-cluster — the pool cannot reach the public host |
| 64 | 66 | 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") | |
| 72 | 73 | case "$code" in |
| 73 | 74 | 201) : ;; |
| 74 | 75 | 409|422) echo "release $TAG already exists — nothing to do"; exit 0 ;; |
| 75 | 76 | *) echo "::error::release create failed (HTTP $code): $(head -c200 /tmp/rel.json)"; exit 1 ;; |
| 76 | 77 | 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; } | |
| 78 | 82 | # Attachments are best-effort: a small [attachment] MAX_SIZE must not |
| 79 | 83 | # sink the release — the body's package link always works. |
| 80 | 84 | for f in seed.tar.gz manifest.yaml; do |
new above
offline