Files
iroh-forward/.gitea/workflows/release.yaml
T
skoandClaude Opus 4.8 de4adc7b1d
Release / build-and-release (push) Successful in 2m19s
ci: Gitea-Actions-Workflow für SemVer-Release-Builds
Bei push eines Tags v*.*.* wird ein statisches musl-Binary gebaut und als
Gitea-Release veröffentlicht (Asset + .sha256, Notes aus Commits). Suffix-Tags
(v1.2.3-rc1) werden als Pre-Release markiert; Cargo-Version wird an den Tag
angeglichen. README um Releases-Abschnitt ergänzt.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 04:37:15 +02:00

98 lines
3.3 KiB
YAML

name: Release
# Löst aus, wenn ein SemVer-Tag gepusht wird, z.B. v1.2.3 oder v1.2.3-rc1.
on:
push:
tags:
- 'v*.*.*'
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout (mit voller History für Changelog)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build-Tools installieren
run: |
sudo apt-get update
sudo apt-get install -y musl-tools jq
- name: Rust + musl-Target installieren
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --default-toolchain stable --profile minimal \
--target x86_64-unknown-linux-musl
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
- name: Version aus Tag setzen
run: |
TAG="${GITHUB_REF_NAME}"
VERSION="${TAG#v}"
echo "TAG=$TAG" >> "$GITHUB_ENV"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
# Cargo-Paketversion an den Tag angleichen, damit --version stimmt.
sed -i -E "0,/^version = \".*\"/s//version = \"$VERSION\"/" Cargo.toml
- name: Statisches Binary bauen (musl)
run: cargo build --release --target x86_64-unknown-linux-musl
- name: Artefakt + Checksumme vorbereiten
run: |
ASSET="iroh-forward-${VERSION}-x86_64-unknown-linux-musl"
cp target/x86_64-unknown-linux-musl/release/iroh-forward "$ASSET"
sha256sum "$ASSET" > "$ASSET.sha256"
echo "ASSET=$ASSET" >> "$GITHUB_ENV"
- name: Release-Notes aus Commits generieren
run: |
PREV=$(git describe --tags --abbrev=0 "${TAG}^" 2>/dev/null || echo "")
if [ -n "$PREV" ]; then
NOTES=$(git log --no-merges --pretty='- %s' "$PREV..$TAG")
else
NOTES=$(git log --no-merges --pretty='- %s' "$TAG")
fi
{
echo "NOTES<<EOF"
echo "$NOTES"
echo "EOF"
} >> "$GITHUB_ENV"
- name: Gitea-Release anlegen und Assets hochladen
env:
# Automatischer Token von Gitea Actions; alternativ Repo-Secret RELEASE_TOKEN.
TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
run: |
API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
case "$TAG" in
*-*) PRERELEASE=true ;; # v1.2.3-rc1 etc. = Vorabversion
*) PRERELEASE=false ;;
esac
PAYLOAD=$(jq -n \
--arg tag "$TAG" \
--arg notes "$NOTES" \
--argjson pre "$PRERELEASE" \
'{tag_name: $tag, name: $tag, body: $notes, draft: false, prerelease: $pre}')
RELEASE_ID=$(curl -fsSL -X POST "$API/releases" \
-H "Authorization: token $TOKEN" \
-H "Content-Type: application/json" \
-d "$PAYLOAD" | jq -r '.id')
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then
echo "Release konnte nicht angelegt werden" >&2
exit 1
fi
for f in "$ASSET" "$ASSET.sha256"; do
curl -fsSL -X POST \
"$API/releases/$RELEASE_ID/assets?name=$f" \
-H "Authorization: token $TOKEN" \
-F "attachment=@$f;type=application/octet-stream"
done
echo "Release $TAG veröffentlicht (prerelease=$PRERELEASE)."