From fbdcca408937df0d8ccf92c60f6a283f305bb25a Mon Sep 17 00:00:00 2001 From: test Date: Sun, 27 Sep 2026 14:50:30 +0800 Subject: [PATCH] feat: generate release notes from git log --- .gitea/workflows/release.yml | 44 ++++++++++++++---------------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index dcaa74e..37304bd 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -52,39 +52,29 @@ jobs: ls -la target/*.jar echo "Verification completed" - - name: Generate Release Notes - id: notes - run: | - echo "Generating release notes from commits..." - VERSION=$(grep "^version:" src/main/resources/plugin.yml | awk '{print $2}' | tr -d '\r\n ') - TAG="v$VERSION" - echo "tag=$TAG" >> $GITHUB_OUTPUT - - # Get all commits since last tag - COMMITS=$(git log --format="- %s" $(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo HEAD~10)..HEAD 2>/dev/null || git log --format="- %s" -10) - - # Format: include commit hash and date - FULL_LOG=$(git log --format="**%h** - %an (%ad)%n%s" --date=short $(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo HEAD~10)..HEAD 2>/dev/null || git log --format="**%h** - %an (%ad)%n%s" --date=short -10) - - echo "## Changes" > /tmp/release_body.md - echo "" >> /tmp/release_body.md - echo "$FULL_LOG" >> /tmp/release_body.md - echo "" >> /tmp/release_body.md - echo "### Full Changelog" >> /tmp/release_body.md - echo "" >> /tmp/release_body.md - echo "\`$TAG\`" >> /tmp/release_body.md - - echo "Release notes generated:" - cat /tmp/release_body.md - - name: Create Release env: GITEA_TOKEN: 2cb4826439e13d6f80776bf1e5832a88669856e2 run: | set -e - TAG="${{ steps.notes.outputs.tag }}" + # Get version from plugin.yml + VERSION=$(grep "^version:" src/main/resources/plugin.yml | awk '{print $2}' | tr -d '\r\n ') + TAG="v$VERSION" BASE="$GITHUB_API_URL/repos/$GITHUB_REPOSITORY" - echo "Creating release for $TAG" + echo "Version: $VERSION, Tag: $TAG" + + # Generate release notes from git log + echo "## Changes in $TAG" > /tmp/release_body.md + echo "" >> /tmp/release_body.md + git log --format="- **%h** %s (%an, %ad)" --date=short -10 >> /tmp/release_body.md + echo "" >> /tmp/release_body.md + echo "### Full changelog" >> /tmp/release_body.md + echo "" >> /tmp/release_body.md + echo "[View all commits](/youpaishidifu/Sdf1_login/commits/main)" >> /tmp/release_body.md + + echo "=== Release notes ===" + cat /tmp/release_body.md + echo "====================" echo "=== Checking existing tag $TAG ===" HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GITEA_TOKEN" "$BASE/releases/tags/$TAG")