ci: Gitea-Actions-Workflow für SemVer-Release-Builds
Release / build-and-release (push) Successful in 2m19s
Release / build-and-release (push) Successful in 2m19s
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>
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
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)."
|
||||
@@ -78,6 +78,26 @@ Systemweit installieren (nach `~/.cargo/bin`):
|
||||
cargo install --path .
|
||||
```
|
||||
|
||||
## Releases (Gitea Actions)
|
||||
|
||||
Der Workflow `.gitea/workflows/release.yaml` baut bei einem **SemVer-Tag** ein statisches
|
||||
musl-Binary und veröffentlicht es als Release-Asset (inkl. `.sha256` und auto-generierten
|
||||
Release-Notes aus den Commits seit dem letzten Tag).
|
||||
|
||||
```bash
|
||||
# nach SemVer taggen und pushen — das löst den Build + Release aus:
|
||||
git tag v0.1.0
|
||||
git push origin v0.1.0
|
||||
```
|
||||
|
||||
Tags mit Suffix (`v1.2.3-rc1`) werden automatisch als **Pre-Release** markiert. Die Paketversion
|
||||
in `Cargo.toml` wird im Build an den Tag angeglichen, sodass `iroh-forward --version` passt.
|
||||
|
||||
**Voraussetzungen:** In den Repo-Einstellungen müssen *Actions* aktiviert und ein
|
||||
[`act_runner`](https://docs.gitea.com/usage/actions/act-runner) registriert sein. Der Workflow nutzt
|
||||
den automatischen `GITHUB_TOKEN`; falls dieser keine Release-Schreibrechte hat, ein Repo-Secret
|
||||
`RELEASE_TOKEN` (Personal Access Token mit `write:repository`) anlegen.
|
||||
|
||||
### Statisches Binary fürs Deployment (optional)
|
||||
|
||||
Für ein weitgehend abhängigkeitsfreies Binary, das auf jedem Linux-Host ohne passende glibc läuft,
|
||||
|
||||
Reference in New Issue
Block a user