#!/usr/bin/env bash set -euo pipefail create_release() { local -r owner="$1" repo="$2" token="$3" version="$4" body_file="$5" local -i max_attempts=3 delay=5 attempt local http status # Release-Body fΓΌr die JSON-Payload einlesen local body_json body_json=$(tail -n +2 "$body_file" | jq -Rs .) for (( attempt=1; attempt<=max_attempts; attempt++ )); do echo "πŸš€ Try $attempt/$max_attempts: creating release v$version …" http=$(curl -sS \ -H "Authorization: token $token" \ -H "Content-Type: application/json" \ -o resp.json -w '%{http_code}' \ -X POST "$GITHUB_API_URL/repos/$owner/$repo/releases" \ -d @- < "$RELEASE_BODY_TMP" # === Schritt 3: Changelog committen === git add "$CHANGELOG_FILE" if git diff --cached --quiet; then echo "βœ… No changes to commit" else echo "πŸ“ Committing updated changelog" git commit -m "chore(changelog): update changelog for v$VERSION" git push origin main fi # === Schritt 4: Tag anlegen, falls nΓΆtig === if git rev-parse "v$VERSION" >/dev/null 2>&1; then echo "πŸ” Tag v$VERSION already exists, skipping." else echo "🏷️ Creating annotated tag v$VERSION" export GIT_AUTHOR_DATE="$(date --iso-8601=seconds)" export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" git tag -a "v$VERSION" -F "$RELEASE_BODY_TMP" --cleanup=verbatim git push origin "v$VERSION" fi # === Schritt 5: Release anlegen (mit Retry) === OWNER="${GITHUB_REPOSITORY%/*}" REPO="${GITHUB_REPOSITORY#*/}" TOKEN="${RELEASE_PUBLISH_TOKEN:-$ACTIONS_RUNTIME_TOKEN}" if [[ -z "${RELEASE_PUBLISH_TOKEN:-}" ]]; then echo "::warning title=Limited Release Propagation::" echo "RELEASE_PUBLISH_TOKEN is not set. Using ACTIONS_RUNTIME_TOKEN instead." echo "⚠️ Release events may not trigger other workflows if created with the runtime token." echo fi create_release "$OWNER" "$REPO" "$TOKEN" "$VERSION" "$RELEASE_BODY_TMP" echo "πŸŽ‰ Workflow finished successfully."