From 58e10a0bc01b46617320fc40d34c59a1e36e43d8 Mon Sep 17 00:00:00 2001 From: Sirius DevOps Date: Sat, 12 Sep 2026 00:55:18 -0400 Subject: [PATCH] ci(release): honor dry_run input and send JSON Content-Type Forgejo dispatch passes string inputs; boolean dry_run stayed false and tried to mint v0.1.0. Strip PAT newlines so Authorization does not eat the next header (422 Empty Content-Type). --- .forgejo/workflows/release.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index 17975ca..3b9f22a 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -23,10 +23,10 @@ on: required: false type: string dry_run: - description: Build and checksum without creating a tag or publishing + description: Build and checksum without creating a tag or publishing (true/false) required: false - type: boolean - default: false + type: string + default: "false" concurrency: group: onionwire-release @@ -59,22 +59,24 @@ jobs: run: | set -euo pipefail : "${FORGEJO_TOKEN:?FORGEJO_TOKEN secret is not set}" + FORGEJO_TOKEN=$(printf '%s' "$FORGEJO_TOKEN" | tr -d '\r\n') dry_run=false if [ "$EVENT_NAME" = "workflow_dispatch" ]; then case "${INPUT_DRY_RUN:-false}" in - true|True|TRUE) dry_run=true ;; + true|True|TRUE|1|yes|YES) dry_run=true ;; esac fi + echo "event=$EVENT_NAME sha=$EVENT_SHA input_tag=${INPUT_TAG-} input_dry_run=${INPUT_DRY_RUN-} dry_run=$dry_run" api_curl() { curl -sS --http1.1 --retry 5 --retry-all-errors --retry-delay 3 \ - --connect-timeout 20 --max-time 60 "$@" + --connect-timeout 20 --max-time 60 \ + -H "Authorization: Bearer $FORGEJO_TOKEN" "$@" } input_tag="${INPUT_TAG:-}" if [ -n "$input_tag" ]; then code=$(api_curl -o /tmp/tag.json -w '%{http_code}' \ - -H "Authorization: Bearer $FORGEJO_TOKEN" \ "$REPO_API/tags/$input_tag") if [ "$code" != "200" ]; then echo "dispatch tag $input_tag not found (HTTP $code)" >&2 @@ -86,8 +88,7 @@ jobs: created=false echo "re-publish existing tag $tag at $sha (dry_run=$dry_run)" else - api_curl -H "Authorization: Bearer $FORGEJO_TOKEN" \ - "$REPO_API/tags?limit=50" -o /tmp/tags.json + api_curl "$REPO_API/tags?limit=50" -o /tmp/tags.json tag=$(python3 -c "import json,re; tags=json.load(open('/tmp/tags.json')); assert isinstance(tags, list), tags; semver=[]; [semver.append((int(m[1]), int(m[2]), int(m[3]))) for t in tags for m in [re.fullmatch(r'v([0-9]+)\.([0-9]+)\.([0-9]+)', t.get('name') or '')] if m]; print('v0.1.0' if not semver else 'v%d.%d.%d' % (max(semver)[0], max(semver)[1], max(semver)[2] + 1))") sha="$EVENT_SHA" created=false @@ -95,7 +96,6 @@ jobs: echo "dry_run: would use $tag on $sha (no tag created)" else code=$(api_curl -o /tmp/tag.json -w '%{http_code}' \ - -H "Authorization: Bearer $FORGEJO_TOKEN" \ "$REPO_API/tags/$tag") if [ "$code" = "200" ]; then existing=$(python3 -c "import json; print(json.load(open('/tmp/tag.json'))['commit']['sha'])") @@ -107,10 +107,10 @@ jobs: elif [ "$code" = "404" ]; then python3 -c "import json,sys; json.dump({'tag_name':sys.argv[1],'target':sys.argv[2],'message':'OnionWire '+sys.argv[1]}, sys.stdout)" \ "$tag" "$sha" > /tmp/tag-create.json + echo "tag-create payload $(wc -c < /tmp/tag-create.json) bytes" create_code=$(api_curl -o /tmp/tag-created.json -w '%{http_code}' \ - -X POST -H "Authorization: Bearer $FORGEJO_TOKEN" \ - -H "Content-Type: application/json" \ - --data @/tmp/tag-create.json \ + -X POST -H "Content-Type: application/json" \ + --data-binary @/tmp/tag-create.json \ "$REPO_API/tags") if [ "$create_code" = "201" ]; then created=true