Revision: 1 Last modified: 2026-12-04T18:15:21Z
One entry point for the release API of every forge this project pushes to: GitHub, GitLab,
Gitea/Forgejo (git.m3w.org, Codeberg), GitFlic and GitVerse. It speaks REST over curl and uses
API tokens only — never a browser, never a CLI such as gh or glab.
You call it when you need to ask a forge about a repository, a tag or a release, or when you need a release
object to exist for a tag that is already pushed. The important asymmetry: tags arrive by git push; this
tool never creates, moves or deletes a tag, never pushes, and never force-pushes. It only reads tags and
creates/updates the release that hangs off a tag.
release-ensure is idempotent. An absent release is created and then read back; a present release that
matches is kept; one that differs is a FAIL unless --update is given. The whole design is built around one
rule that is easy to get wrong: a release target the tool itself sent is never proof of which commit the
release is on. A target is only trusted when the forge derives it from the tag (GitLab's commit.id), or
when the tag's own commit was separately confirmed to equal --sha. Otherwise the run ends
RESULT: UNVERIFIED-COMMIT (exit 5) rather than claiming success it cannot evidence.
bash(4+ — uses arrays,compgen,${var,,}),curl,jq,timeout(coreutils). A missing one is a GAP (tool_missing, exit 3), not a crash.- Linux
/proc— the tool re-executes itself once with an empty environment and then verifies that state by reading/proc/$$/cmdlineand/proc/$$/environ. Without/procit refuses withGAP environment_unverifiable. config/forge/hosts.tsv(override with the env varFORGE_HOSTS_FILE). TAB-separatedhost · provider · api_base · token_vars · note. This map is a trust boundary: it decides which origin receives which token variable. It must be a regular non-symlink file owned by you or root, not writable by others, and its directory must not be writable by others either (a sticky-bit directory such as/tmpis accepted). Any violation is refused:hosts_file_insecure/hosts_file_invalid.- A token, found by name in this order: the process environment, then the keys file
(
FORGE_KEYS_FILE, default~/api_keys.sh, mode 0600), then the project.env(FORGE_ENV_FILE). The default.envis used only whenforge.shitself sits inside that repository; from any other checkout the notedotenv_not_trustedis printed and the.envis not read. - Optional env vars:
FORGE_KEYS_TIMEOUT(default 10 s),FORGE_HTTP_TIMEOUT(default 60 s),FORGE_GITFLIC_MAX_PAGES(default 20),FORGE_TRACE_PEER=1(prints aPEER:line per request).
Variable names are configured; their values are never printed, never put in argv, never in a URL, never
in a child environment.
# what forge answers for a remote, and where the token would go — no network at all
bash scripts/forge/forge.sh detect --remote origin
# read-only GETs; prints HTTP status and JSON KEY NAMES only, never a value
bash scripts/forge/forge.sh probe --remote origin
# does the repository answer 200 for this token?
bash scripts/forge/forge.sh repo-exists --url git@github.com:HelixDevelopment/constitution.git
# what commit does the forge say the tag points at?
bash scripts/forge/forge.sh tag-get --remote origin --tag v1.2.3
# is there a release for the tag?
bash scripts/forge/forge.sh release-get --remote origin --tag v1.2.3
# idempotent: create if absent, keep if matching, FAIL if it differs
bash scripts/forge/forge.sh release-ensure --remote origin --tag v1.2.3 \
--sha 0123456789abcdef0123456789abcdef01234567 \
--notes-file docs/changelogs/v1.2.3.md
# what would happen, with GETs only
bash scripts/forge/forge.sh release-ensure --remote origin --tag v1.2.3 --sha <sha40> \
--notes-file notes.md --dry-run
# change a differing release instead of failing
bash scripts/forge/forge.sh release-ensure --remote origin --tag v1.2.3 --sha <sha40> \
--notes-file notes.md --update
# a Codeberg repository whose Releases unit is off: make the one reversible settings change
bash scripts/forge/forge.sh release-ensure --url git@codeberg.org:org/repo.git --tag v1.2.3 \
--sha <sha40> --notes-file notes.md --enable-releases
# GitVerse, whose release list 404s even for an existing repo: try the create, the read-back decides
bash scripts/forge/forge.sh release-ensure --url git@gitverse.ru:org/repo.git --tag v1.2.3 \
--sha <sha40> --notes-file notes.md --try-create-on-ambiguous
# help == the header block of the script itself
bash scripts/forge/forge.sh --helpCommands: detect, probe, repo-exists, release-get, tag-get, release-ensure.
Target selection: --remote NAME or --url URL (never both). --asset is parsed but deliberately
refused: not_implemented, exit 2.
| Code | RESULT: |
Meaning |
|---|---|---|
| 0 | OK |
the requested read succeeded, or release-ensure proved the release is on --sha |
| 1 | FAIL |
read-back or state mismatch (tag_sha_mismatch, present_mismatch, readback_mismatch, enable_releases_not_confirmed, internal_state) |
| 2 | USAGE |
bad arguments, a bad hosts file (hosts_file_invalid / hosts_file_insecure), a refused notes file, install_broken, not_implemented |
| 3 | GAP |
a precondition or forge-state gap — credentials_absent:<vars>, credentials_invalid:<var>, unknown_forge, not_accessible, releases_disabled, releases_unsupported_or_empty, tag_absent_on_forge, readback_page_cap, tool_missing, environment_unverifiable, tmp_unavailable, keys_file_unreadable |
| 4 | API |
no answer or an unexpected answer — auth_failed, redirect_refused, unexpected_status_<code>, network_<class>, unsafe_id |
| 5 | UNVERIFIED-COMMIT |
commit_unverified — release-ensure could not prove which commit the release is on |
| 129 / 130 / 143 | INTERRUPTED |
HUP / INT / TERM; REASON: interrupted |
Every run ends with RESULT: <WORD>, preceded by REASON: <code> when there is one.
- No token. Reads run unauthenticated and print
AUTH: none.release-ensurerefuses withGAP credentials_absent:<names>— a write always needs a credential. - A malformed token value (outside
[A-Za-z0-9._~+/=-], or longer than 400 characters) iscredentials_invalid:<var>and is never sent. The search stops there: a lower-priority source is never silently substituted for a value the operator set. - A placeholder token (
changeme,xxx,your-token,<...>,todo,none,null,dummy,test, one repeated character, or shorter than 8 characters) counts as absent. - Notes file that is the keys file or the
.env(same device:inode, symlinks and hard links included) is refused:notes_is_credentials_file. Notes or title containing any known token value are refused:notes_contain_token/title_contains_token. The scanned copy is what is sent, so a later edit cannot slip a token in. - Notes file that is a FIFO, device or socket is refused (
notes_not_regular) because reading it could block forever. Exactly/dev/nullis allowed, for callers that publish no text. Larger than 1,000,000 bytes isnotes_too_large. - A 3xx is never followed. It is answered as an error (
redirect_refused), so a redirect can never carry the token to another origin. - Offline / DNS failure / TLS failure are distinct
network_<class>API errors:timeout,dns,refused,tls,protocol,other.curl's own message is withheld because it can contain a URL. - A tag that is not on the forge is
GAP tag_absent_on_forge— push it withgit pushfirst; this tool will not create it. - GitFlic has no get-by-tag, so lookups page through the list. Reaching the page cap without a match is
GAP readback_page_cap, never "absent" — gitflic.ru allows 500 requests per hour and "unknown" must not be reported as "not there". - GitVerse's release list answers 404 for repositories that exist. That state cannot be told apart from
"no release yet", so it is
GAP releases_unsupported_or_empty, and creating there needs the explicit--try-create-on-ambiguousopt-in — only the read-back decides. - Codeberg with the Releases unit off is
GAP releases_disabled;--enable-releasesperforms the single reversiblePATCH {"has_releases":true}and confirms it by reading the repository back. - GitLab has no pre-release flag. Requesting
--prereleaseprintsNOTE: prerelease_unsupportedrather than pretending. - A renamed GitHub repository answers
301; the one hop to/repositories/<id>on the same API origin is followed internally and reported asNOTE: repo_moved. - A GitHub draft release is invisible to
GET /releases/tags/{tag}. On a 404 there, the first page of the release list is searched for a draft of the tag; a miss with 100 items listed isNOTE: draft_lookup_first_page_only, an unreadable list isNOTE: draft_lookup_unavailable. - A dry run never writes, but it still ends
UNVERIFIED-COMMITwhen the commit could not be proven — a dry run and a real run of the same state reach the same verdict.
set +x +a,set -u, then clears every repository-locatingGIT_*variable so an inheritedGIT_DIRcannot redirect thegitcalls.- Sources
lib/common.sh, callsfg_env_clean "$@", which re-executes the script once with an empty environment and restores only a fixed allow-list plus*TOKEN/FORGE_*names as unexported shell variables. Early signal traps are installed before the slow reads. - Sources
lib/credentials.shandlib/http.sh; parses the command and options. - Loads and validates the whole hosts map, then selects the row for the remote's host. A host with no row
is
unknown_forge— nothing is guessed. - Parses the remote URL into host and owner/repo, refusing a URL that carries userinfo/password and refusing unsafe path segments.
- Resolves the token by name; loads every candidate secret value for the output sanitiser; creates a private
temporary directory (
mktemp -d, mode 700, removed on exit). - For
release-ensure: refuses a credential-bearing notes file, reads the notes with a byte cap, scans notes and title for token values, then writes the scanned copy to the temp dir. - Sources
providers/<provider>.shand callsprov_init. - Runs the command. For
release-ensurethe commit verdict is fixed from read-only state before any write; creates/updates, then reads back, then re-checks tag/draft/prerelease/target. - Every printed line passes
fg_scrub, which replaces any word containing a 12-character window of a known token value withunsafe(keeping a cleankey=prefix).
scripts/forge/lib/common.sh— clean-environment re-exec, output sanitiser, exit helpers, validators.scripts/forge/lib/credentials.sh— token discovery, file-safety checks, the secret-value set.scripts/forge/lib/http.sh— the single HTTP client, origin pinning, peer identity, temp dir, traps.scripts/forge/providers/{github,gitlab,gitea,gitflic,gitverse}.sh— per-forge REST adapters.scripts/forge/live_probe.sh— LIVE read-only proof of this tool against the real forges.scripts/release/tag_and_release.sh— keeps its owngh/glablegs by design decision; that is a separate path, not a duplicate of this one.docs/guides/multiforge_release_guide.mdanddocs/manuals/forge_tool_manual.md— the long-form guides.config/forge/hosts.tsv— the hosts map this tool trusts.
2026-12-04 — bash -n scripts/forge/forge.sh → exit 0. bash scripts/forge/forge.sh --help → exit 0 and
prints lines 2–47 of the script (its own header block, which is the usage text).
Cross-check available without a token: bash scripts/forge/forge.sh detect --remote origin prints
PROVIDER: / HOST: / REPO: / API: / TOKEN_VARS: and ends RESULT: OK, entirely offline.