diff --git a/.github/workflows/gitea-release.yml b/.github/workflows/gitea-release.yml index 18e96b4..05f5d78 100644 --- a/.github/workflows/gitea-release.yml +++ b/.github/workflows/gitea-release.yml @@ -66,14 +66,33 @@ jobs: VERSION=$(grep '^version = ' platformio.ini | cut -d'"' -f2) echo "VERSION=$VERSION" >> $GITHUB_OUTPUT - - name: Read CHANGELOG.md - id: changelog + - name: Generate Release Notes + id: release_notes run: | - VERSION=${{ steps.get_version.outputs.VERSION }} - CHANGELOG=$(awk "/## \\[$VERSION\\]/{p=1;print;next} /## \\[/{p=0} p" CHANGELOG.md) - echo "CHANGES<> $GITHUB_OUTPUT - echo "$CHANGELOG" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + + if [ -n "$LAST_TAG" ]; then + echo "CHANGES<> $GITHUB_OUTPUT + echo "Changes since $LAST_TAG:" >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + + # Get commits since last tag and categorize them + echo "### Added" >> $GITHUB_OUTPUT + git log $LAST_TAG..HEAD --pretty=format:%s | grep -iE '^(feat|add|new)' | sed 's/^feat: /- /' >> $GITHUB_OUTPUT || true + echo "" >> $GITHUB_OUTPUT + + echo "### Fixed" >> $GITHUB_OUTPUT + git log $LAST_TAG..HEAD --pretty=format:%s | grep -iE '^fix' | sed 's/^fix: /- /' >> $GITHUB_OUTPUT || true + echo "" >> $GITHUB_OUTPUT + + echo "### Changed" >> $GITHUB_OUTPUT + git log $LAST_TAG..HEAD --pretty=format:%s | grep -ivE '^(feat|fix|add|new)' | sed 's/^/- /' >> $GITHUB_OUTPUT || true + echo "EOF" >> $GITHUB_OUTPUT + else + echo "CHANGES<> $GITHUB_OUTPUT + echo "Initial Release" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + fi - name: Determine Gitea URL id: gitea_url @@ -122,7 +141,7 @@ jobs: # Erstelle zuerst den Release ohne Dateien echo "Debug: Creating release..." - RELEASE_DATA="{\"tag_name\":\"v${VERSION}\",\"name\":\"v${VERSION}\",\"body\":\"${{ steps.changelog.outputs.CHANGES }}\"}" + RELEASE_DATA="{\"tag_name\":\"v${VERSION}\",\"name\":\"v${VERSION}\",\"body\":\"${{ steps.release_notes.outputs.CHANGES }}\"}" RELEASE_RESPONSE=$(curl -s -w "\n%{http_code}" \ -X POST \ diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml index a5fc8d2..24e8c56 100644 --- a/.github/workflows/github-release.yml +++ b/.github/workflows/github-release.yml @@ -73,14 +73,33 @@ jobs: VERSION=$(grep '^version = ' platformio.ini | cut -d'"' -f2) echo "VERSION=$VERSION" >> $GITHUB_OUTPUT - - name: Read CHANGELOG.md - id: changelog + - name: Generate Release Notes + id: release_notes run: | - VERSION=${{ steps.get_version.outputs.VERSION }} - CHANGELOG=$(awk "/## \\[$VERSION\\]/{p=1;print;next} /## \\[/{p=0} p" CHANGELOG.md) - echo "CHANGES<> $GITHUB_OUTPUT - echo "$CHANGELOG" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + + if [ -n "$LAST_TAG" ]; then + echo "CHANGES<> $GITHUB_OUTPUT + echo "Changes since $LAST_TAG:" >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + + # Get commits since last tag and categorize them + echo "### Added" >> $GITHUB_OUTPUT + git log $LAST_TAG..HEAD --pretty=format:%s | grep -iE '^(feat|add|new)' | sed 's/^feat: /- /' >> $GITHUB_OUTPUT || true + echo "" >> $GITHUB_OUTPUT + + echo "### Fixed" >> $GITHUB_OUTPUT + git log $LAST_TAG..HEAD --pretty=format:%s | grep -iE '^fix' | sed 's/^fix: /- /' >> $GITHUB_OUTPUT || true + echo "" >> $GITHUB_OUTPUT + + echo "### Changed" >> $GITHUB_OUTPUT + git log $LAST_TAG..HEAD --pretty=format:%s | grep -ivE '^(feat|fix|add|new)' | sed 's/^/- /' >> $GITHUB_OUTPUT || true + echo "EOF" >> $GITHUB_OUTPUT + else + echo "CHANGES<> $GITHUB_OUTPUT + echo "Initial Release" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + fi - name: Create GitHub Release env: @@ -110,7 +129,7 @@ jobs: if [ -n "$FILES_TO_UPLOAD" ]; then gh release create "v${VERSION}" \ --title "Release ${VERSION}" \ - --notes "${{ steps.changelog.outputs.CHANGES }}" \ + --notes "${{ steps.release_notes.outputs.CHANGES }}" \ $FILES_TO_UPLOAD else echo "Error: No files found to upload"