Skip to content

Create GitHub Release #11

Create GitHub Release

Create GitHub Release #11

Workflow file for this run

name: Create GitHub Release
on:
workflow_run:
workflows: ["Build and Push Docker Image"]
types:
- completed
branches:
- main
push:
tags:
- '*' # Also trigger on manual tag pushes
jobs:
release:
runs-on: ubuntu-latest
# Only run if the triggering workflow succeeded
if: ${{ github.event_name == 'push' || github.event.workflow_run.conclusion == 'success' }}
permissions:
packages: write
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0 # Fetch all history for all tags and branches
fetch-tags: true # Fetch all tags
ref: ${{ github.event.workflow_run.head_branch || github.ref }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install openai pydantic
- name: Get current tag
id: get-tag
run: |
# If triggered by workflow_run, read version from version.py
if [ "${{ github.event_name }}" = "workflow_run" ]; then
# Read version from version.py (same as CI workflow did)
VERSION=$(grep -oP '__version__\s*=\s*"\K[^"]*' app/core/version.py || echo "")
if [ -z "${VERSION}" ]; then
# Fallback: try Python import
VERSION=$(python -c "import sys; sys.path.insert(0, '.'); from app.core.version import __version__; print(__version__)" 2>/dev/null || echo "")
fi
if [ -z "${VERSION}" ]; then
echo "Error: Could not read version from version.py"
exit 1
fi
echo "TAG_NAME=${VERSION}" >> $GITHUB_OUTPUT
echo "Tag from version.py: ${VERSION}"
else
# If triggered by tag push, get from GITHUB_REF
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_OUTPUT
echo "Current tag from push: ${TAG_NAME}"
fi
- name: Checkout tag commit
run: |
TAG_NAME="${{ steps.get-tag.outputs.TAG_NAME }}"
git checkout ${TAG_NAME} || git checkout -b temp-${TAG_NAME} ${TAG_NAME}
echo "Checked out tag: ${TAG_NAME}"
- name: Run Python script to generate release notes
id: generate_release_notes
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CURRENT_TAG: ${{ steps.get-tag.outputs.TAG_NAME }}
run: |
echo "Running generate_release_notes.py"
python scripts/generate_release_notes.py
echo "Script completed"
- name: Debug Outputs
run: |
echo "Version: ${{ steps.generate_release_notes.outputs.version }}"
echo "Release Notes: ${{ steps.generate_release_notes.outputs.release_notes }}"
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get-tag.outputs.TAG_NAME }}
release_name: Release ${{ steps.get-tag.outputs.TAG_NAME }} - ${{ steps.generate_release_notes.outputs.version_name }}
body: ${{ steps.generate_release_notes.outputs.release_notes }}
draft: false
prerelease: ${{ contains(steps.get-tag.outputs.TAG_NAME, 'beta') || contains(steps.get-tag.outputs.TAG_NAME, 'alpha') || contains(steps.get-tag.outputs.TAG_NAME, 'rc') || contains(steps.get-tag.outputs.TAG_NAME, 'pre') }}