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

workbenchthis machine

seed-release: tag + Forgejo Release per merged seed; auto-link the package #129

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

feat/seed-release → main 1 commit

  • Merged. feat/seed-release was merged into main.

Review

Sign in to review this change.
1 file changed +93 −0
.forgejo/workflows/seed-release.yml added +93
@@ -0,0 +1,93 @@
1 # seed-release.yml — the HUMAN half of seed history (packages are the machine
2 # half). Fires exactly when a gate-validated reseed merges (a main push
3 # touching genesis/seed.tar.gz) and:
4 # 1. tags that commit `seed-r<N>` and creates a Forgejo RELEASE with the
5 # tarball + manifest attached — the repo's Releases tab becomes the
6 # browsable catalog of every seed that ever became genesis, pinned to
7 # the exact git state;
8 # 2. links the `seed` generic package to THIS repo (idempotent) so the
9 # package also shows on the repo's Packages tab, not only under the
10 # plat user's package space.
11 # Only merged, coldstart-gated seeds get a release; candidate packages
12 # published at build time (publish_seed) never do.
13 #
14 # Needs the same PLAT_PAT repo secret reseed.yml uses.
15 name: seed-release
16 on:
17 push:
18 branches: [main]
19 paths:
20 - "genesis/seed.tar.gz"
21
22 jobs:
23 release:
24 runs-on: isolated
25 env:
26 REGISTRY: forgejo-http.forgejo.svc.cluster.local:3000
27 PLAT_PAT: ${{ secrets.PLAT_PAT }}
28 steps:
29 - name: fetch seed + derive identity
30 env:
31 TOKEN: ${{ github.token }}
32 run: |
33 set -eu
34 [ -n "$PLAT_PAT" ] || { echo "::error::secret PLAT_PAT is not set"; exit 1; }
35 curl -fsS -H "Authorization: token $TOKEN" -o seed.tar.gz \
36 "http://$REGISTRY/api/v1/repos/$GITHUB_REPOSITORY/raw/genesis/seed.tar.gz?ref=$GITHUB_SHA"
37 tar -xzOf seed.tar.gz ./manifest.yaml > manifest.yaml 2>/dev/null \
38 || tar -xzOf seed.tar.gz manifest.yaml > manifest.yaml
39 BASE=$(curl -fsS -H "Authorization: token $TOKEN" \
40 "http://$REGISTRY/api/v1/repos/$GITHUB_REPOSITORY" \
41 | sed -n 's#.*"html_url":"\(https\{0,1\}://[^"/]*\)/.*#\1#p')
42 [ -n "$BASE" ] || { echo "::error::could not derive public base"; exit 1; }
43 # Tag from the reseed run number in the merge commit ("reseed r<N>"),
44 # falling back to the manifest's seedVersion stamp.
45 MSG=$(curl -fsS -H "Authorization: token $TOKEN" \
46 "http://$REGISTRY/api/v1/repos/$GITHUB_REPOSITORY/git/commits/$GITHUB_SHA" \
47 | sed -n 's/.*"message":"\([^"]*\)".*/\1/p')
48 RNUM=$(printf '%s' "$MSG" | grep -oE 'reseed r[0-9]+' | head -1 | grep -oE '[0-9]+' || true)
49 [ -n "$RNUM" ] || RNUM=$(sed -n 's/^seedVersion:[[:space:]]*r//p' manifest.yaml | head -1)
50 TAG="seed-r${RNUM:-$(printf '%.7s' "$GITHUB_SHA")}"
51 { echo "FORGEJO_URL=$BASE"; echo "TAG=$TAG"; } >> "$GITHUB_ENV"
52 echo "releasing $TAG from $GITHUB_SHA"
53
54 - name: create release + attach seed
55 run: |
56 set -eu
57 API="$FORGEJO_URL/api/v1"
58 AUTH="Authorization: token $PLAT_PAT"
59 PROFILE=$(sed -n 's/^profile:[[:space:]]*//p' manifest.yaml | head -1)
60 BODY=$(printf 'Gate-validated genesis seed (profile %s).\n\nManifest refs:\n```\n%s\n```\nPackage: %s/plat/-/packages\nFetch: SEED=latest bin/germinate (resolve_seed)' \
61 "${PROFILE:-lean}" "$(grep -E '^\s+(name|ref):' manifest.yaml | head -20)" "$FORGEJO_URL")
62 code=$(jq -n --arg t "$TAG" --arg c "$GITHUB_SHA" --arg b "$BODY" \
63 '{tag_name:$t, target_commitish:$c, name:$t, body:$b}' \
64 | curl -s -o /tmp/rel.json -w '%{http_code}' -X POST -H "$AUTH" \
65 -H 'Content-Type: application/json' -d @- "$API/repos/$GITHUB_REPOSITORY/releases")
66 case "$code" in
67 201) : ;;
68 409|422) echo "release $TAG already exists — nothing to do"; exit 0 ;;
69 *) echo "::error::release create failed (HTTP $code): $(head -c200 /tmp/rel.json)"; exit 1 ;;
70 esac
71 ID=$(jq -r .id /tmp/rel.json)
72 # Attachments are best-effort: a small [attachment] MAX_SIZE must not
73 # sink the release — the body's package link always works.
74 for f in seed.tar.gz manifest.yaml; do
75 a=$(curl -s -o /dev/null -w '%{http_code}' -X POST -H "$AUTH" \
76 -F "attachment=@$f" "$API/repos/$GITHUB_REPOSITORY/releases/$ID/assets?name=$f")
77 [ "$a" = "201" ] && echo " attached $f" \
78 || echo "::warning::could not attach $f (HTTP $a) — check [attachment] MAX_SIZE; the package registry still serves it"
79 done
80 echo "release: $FORGEJO_URL/$GITHUB_REPOSITORY/releases/tag/$TAG"
81
82 - name: link seed package to this repo (idempotent)
83 run: |
84 set -eu
85 REPO_NAME="${GITHUB_REPOSITORY##*/}"
86 code=$(curl -s -o /tmp/link.out -w '%{http_code}' -X POST \
87 -H "Authorization: token $PLAT_PAT" \
88 "$FORGEJO_URL/api/v1/packages/plat/generic/seed/-/link/$REPO_NAME")
89 case "$code" in
90 201|204) echo "package plat/seed linked to $GITHUB_REPOSITORY" ;;
91 409) echo "package already linked" ;;
92 *) echo "::warning::package link API returned HTTP $code — link manually: package Settings -> Link to repository ($(head -c120 /tmp/link.out))" ;;
93 esac

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs