Files
zack3d dea5049be5 ci(workflows): add git --stat to AI release notes
Use git log --stat since last tag (fallback to last 10) so the AI sees
file change stats, echo the log for visibility, and update the prompt to
reference "commits and changes" for more accurate, user-facing notes.
2025-09-24 00:50:53 -07:00

170 lines
5.6 KiB
YAML

name: Multi-Platform CI
on:
push:
pull_request:
jobs:
# Test on platforms with native builds only
test-platforms:
strategy:
fail-fast: false
matrix:
include:
# Linux native
- os: ubuntu-22.04
# Windows native
- os: windows-latest
uses: ./.gitea/workflows/ci-reusable.yml
with:
os: ${{ matrix.os }}
upload-artifacts: false
# Package for distribution (only on master)
package:
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')
needs: [test-platforms]
# Both jobs run on ubuntu, but with different targets
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
# Configuration for the native Linux build
- name: Linux x86_64
target: 'x86_64-unknown-linux-gnu' # An empty target means native build
# Configuration for the Windows cross-compile build
- name: Windows x86_64
target: 'x86_64-pc-windows-gnu'
name: Package for ${{ matrix.name }}
uses: ./.gitea/workflows/ci-reusable.yml
with:
# Both jobs are sent to an ubuntu runner
os: ubuntu-22.04
# The target is passed to the reusable workflow
target: ${{ matrix.target }}
upload-artifacts: true
package-only: true
# Create GitHub release with all artifacts
create-release:
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')
needs: [package]
runs-on: ubuntu-22.04
name: Create GitHub Release
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history for release notes generation
- name: Download all artifacts
uses: https://github.com/christopherHX/gitea-download-artifact@v4
with:
path: artifacts/
- name: Extract version from Cargo.toml
id: version
run: |
VERSION=$(sed -n 's/^version\s*=\s*"\([^"]\+\)"/\1/p' Cargo.toml | head -n1)
echo "version=v$VERSION" >> $GITHUB_OUTPUT
echo "Version: v$VERSION"
- name: Get last release tag
id: last_tag
run: |
LAST_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
LAST_TAG=$(git rev-list --max-parents=0 HEAD)
fi
echo "last_tag=$LAST_TAG" >> $GITHUB_OUTPUT
echo "Last tag/commit: $LAST_TAG"
- name: Generate release notes
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
# Get git log with actual changes since last release
if [ -n "${{ steps.last_tag.outputs.last_tag }}" ]; then
GIT_LOG=$(git log --pretty=format:"**%s** (%an)" --stat ${{ steps.last_tag.outputs.last_tag }}..HEAD)
else
GIT_LOG=$(git log --pretty=format:"**%s** (%an)" --stat HEAD~10..HEAD)
fi
echo "Git changes for release notes:"
echo "$GIT_LOG"
# Try to generate AI-powered release notes
if [ -n "$OPENAI_API_KEY" ]; then
echo "Generating AI release notes..."
PROMPT="Generate professional release notes for version ${{ steps.version.outputs.version }} based on these git commits and file changes. Focus on user-facing changes and improvements. Use markdown formatting with sections like ## What's New, ## Improvements, ## Bug Fixes. Keep it concise and under 500 words.
Commits and Changes:
$GIT_LOG"
RESPONSE=$(curl -s -X POST "https://api.openai.com/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d "{
\"model\": \"gpt-5\",
\"input\": $(echo "$PROMPT" | jq -Rs .)
}")
# Check if the API call was successful and extract the response
if echo "$RESPONSE" | jq -e '.output[1].content[0].text' > /dev/null 2>&1; then
echo "$RESPONSE" | jq -r '.output[1].content[0].text' > release_notes.md
echo "Generated AI release notes successfully"
else
echo "AI generation failed, falling back to simple notes"
echo "API Response: $RESPONSE"
# Fallback to simple notes
cat > release_notes.md << EOF
## Release ${{ steps.version.outputs.version }}
### Changes
$GIT_LOG
---
*Generated automatically from commit history*
EOF
fi
else
echo "No OpenAI API key provided, generating simple release notes"
# Fallback to simple notes
cat > release_notes.md << EOF
## Release ${{ steps.version.outputs.version }}
### Changes
$GIT_LOG
---
*Generated automatically from commit history*
EOF
fi
echo "Final release notes:"
cat release_notes.md
- name: Prepare release assets
run: |
mkdir -p release_assets
find artifacts/ -name "*.tar.gz" -o -name "*.zip" | while read file; do
cp "$file" release_assets/
done
ls -la release_assets/
- name: Create GitHub Release with Assets
uses: akkuman/gitea-release-action@v1
env:
NODE_OPTIONS: '--experimental-fetch'
with:
server_url: ${{ github.server_url }}
token: ${{ secrets.RELEASE_TOKEN }}
tag_name: ${{ steps.version.outputs.version }}
body_path: release_notes.md
files: |-
release_assets/**