.gitea/workflows/ci.yml runs fmt/clippy/test on every master push and PR on the self-hosted mac-arm64 runner (host mode, brew-serviced act_runner). .gitea/workflows/release.yml turns a vX.Y.Z tag into a Gitea release: tools/release.sh --cross (Apple Silicon + x86_64 macOS, musl and RHEL 8 linux-gnu, Windows; both binaries; .vsix; SHA256SUMS), a tag-vs-version check, tools/release_notes.sh (the CHANGELOG section becomes the notes; missing section fails the release) and tools/publish_release.sh (get-or-create + attach, re-run safe). Version bumped to 0.7.1 with a changelog covering directive-split and this flow. Co-Authored-By: Claude Fable 5 <[email protected]>
56 lines
2.1 KiB
Bash
Executable File
56 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Create (or reuse) the Gitea release for a tag and attach every artifact.
|
|
#
|
|
# Usage: tools/publish_release.sh <tag> <dist-dir>
|
|
#
|
|
# Written for the release workflow: expects the CI-provided environment
|
|
# (GITHUB_SERVER_URL, GITHUB_REPOSITORY, GITHUB_TOKEN) and a dist directory
|
|
# holding the artifacts plus RELEASE_NOTES.md (the release body; not
|
|
# attached). A tag containing "-" (v0.8.0-rc1) is marked prerelease.
|
|
# Re-running is safe: an existing release for the tag is reused, and an
|
|
# asset name that is already attached is skipped.
|
|
|
|
set -eu
|
|
|
|
[ $# -eq 2 ] || { echo "usage: $0 <tag> <dist-dir>" >&2; exit 2; }
|
|
tag=$1
|
|
dist=$2
|
|
for var in GITHUB_SERVER_URL GITHUB_REPOSITORY GITHUB_TOKEN; do
|
|
eval "[ -n \"\${$var:-}\" ]" || { echo "$var is not set" >&2; exit 2; }
|
|
done
|
|
notes="$dist/RELEASE_NOTES.md"
|
|
[ -s "$notes" ] || { echo "no release notes at $notes" >&2; exit 2; }
|
|
|
|
api="$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY"
|
|
auth="Authorization: token $GITHUB_TOKEN"
|
|
|
|
prerelease=false
|
|
case $tag in *-*) prerelease=true ;; esac
|
|
|
|
# Reuse the release if a re-run already created it, else create it.
|
|
id=$(curl -sS -H "$auth" "$api/releases/tags/$tag" | jq -r '.id // empty')
|
|
if [ -n "$id" ]; then
|
|
echo "release for $tag exists (id $id), reusing"
|
|
else
|
|
payload=$(jq -n --arg tag "$tag" --rawfile body "$notes" --argjson pre "$prerelease" \
|
|
'{tag_name: $tag, name: $tag, body: $body, draft: false, prerelease: $pre}')
|
|
id=$(curl -sSf -X POST -H "$auth" -H 'Content-Type: application/json' \
|
|
-d "$payload" "$api/releases" | jq -r .id)
|
|
echo "created release $tag (id $id)"
|
|
fi
|
|
|
|
attached=$(curl -sS -H "$auth" "$api/releases/$id/assets" | jq -r '.[].name')
|
|
for f in "$dist"/*; do
|
|
[ -f "$f" ] || continue
|
|
name=$(basename "$f")
|
|
[ "$name" = RELEASE_NOTES.md ] && continue
|
|
if printf '%s\n' "$attached" | grep -qxF "$name"; then
|
|
echo "already attached: $name"
|
|
continue
|
|
fi
|
|
echo "attaching $name"
|
|
curl -sSf -X POST -H "$auth" -F "attachment=@$f" \
|
|
"$api/releases/$id/assets?name=$name" >/dev/null
|
|
done
|
|
echo "release $tag complete: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/$tag"
|