Files
emcli/.gitea/workflows/release.yml
T
steve ffdbb6131e ci(release): re-fetch the tag object before reading its annotation
actions/checkout recreates the pushed tag ref from the commit SHA,
which discards the annotation — v0.7.0's release body ended up being
the commit message. Fetch the real tag object before formatting it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 14:40:53 +01:00

61 lines
2.4 KiB
YAML

# Builds cross-platform binaries and publishes a Gitea release when a version tag
# (e.g. v0.4.0) is pushed. Produces the same assets as `make release` and uploads
# them — so the skill installer (skills/emcli/scripts/install.sh) can fetch them.
#
# Requires: Gitea Actions enabled with a runner that has Go, make, curl, and jq
# (the actions/checkout + actions/setup-go steps need the instance's Actions proxy).
# Verified: this workflow published v0.4.0 on this instance. If a step is ever
# unavailable on your runner, the same result comes from `make release && make
# publish` locally (see RELEASING.md).
name: release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build release artifacts
run: make release VERSION="${GITHUB_REF_NAME}"
- name: Create release and upload assets
env:
TOKEN: ${{ github.token }}
SERVER: ${{ github.server_url }}
REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
# Create the release for the pushed tag. The annotated tag's message
# becomes the release description (empty for lightweight tags).
# Re-fetch the real tag object first: checkout creates the tag ref
# from the commit SHA, which silently discards the annotation.
git fetch --force --no-tags origin "refs/tags/${TAG}:refs/tags/${TAG}"
body=$(git tag -l --format='%(contents)' "${TAG}")
payload=$(jq -n --arg tag "${TAG}" --arg body "${body}" \
'{tag_name: $tag, name: $tag, body: $body}')
id=$(curl -fsSL -X POST \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
"${SERVER}/api/v1/repos/${REPO}/releases" \
-d "${payload}" | jq -r '.id')
echo "release id: ${id}"
# Upload every built asset (binaries + checksums.txt).
for f in dist/*; do
name=$(basename "$f")
echo "uploading ${name}"
curl -fsSL -X POST \
-H "Authorization: token ${TOKEN}" \
-F "attachment=@${f}" \
"${SERVER}/api/v1/repos/${REPO}/releases/${id}/assets?name=${name}" >/dev/null
done
echo "published ${TAG}"