Generate Changelog for Release #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Generate Changelog for Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Release version (e.g., 1.0.1)" | |
| required: true | |
| type: string | |
| date: | |
| description: "Release date (YYYY-MM-DD format, defaults to today)" | |
| required: false | |
| type: string | |
| default: "" | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| generate-changelog: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Install dependencies | |
| working-directory: pipecat | |
| run: | | |
| uv sync --group dev | |
| - name: Set release date | |
| id: set_date | |
| run: | | |
| if [ -z "${{ inputs.date }}" ]; then | |
| RELEASE_DATE=$(date +%Y-%m-%d) | |
| echo "Using today's date: $RELEASE_DATE" | |
| else | |
| RELEASE_DATE="${{ inputs.date }}" | |
| echo "Using provided date: $RELEASE_DATE" | |
| fi | |
| echo "release_date=$RELEASE_DATE" >> $GITHUB_OUTPUT | |
| - name: Validate inputs | |
| run: | | |
| if ! [[ "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then | |
| echo "Error: Version must be in format X.Y.Z (e.g., 1.0.1)" | |
| exit 1 | |
| fi | |
| if [ -n "${{ inputs.date }}" ]; then | |
| if ! date -d "${{ inputs.date }}" >/dev/null 2>&1; then | |
| if ! date -j -f "%Y-%m-%d" "${{ inputs.date }}" >/dev/null 2>&1; then | |
| echo "Error: Date must be in YYYY-MM-DD format" | |
| exit 1 | |
| fi | |
| fi | |
| fi | |
| - name: Check for changelog fragments | |
| id: check_fragments | |
| run: | | |
| FRAGMENT_COUNT=$(find changelog -name "*.md" ! -name "_template.md.j2" | wc -l | tr -d ' ') | |
| echo "fragment_count=$FRAGMENT_COUNT" >> $GITHUB_OUTPUT | |
| if [ "$FRAGMENT_COUNT" -eq "0" ]; then | |
| echo "Error: No changelog fragments found in changelog/" | |
| exit 1 | |
| fi | |
| VALID_TYPES="added changed deprecated removed fixed performance security other" | |
| INVALID_FRAGMENTS="" | |
| for file in changelog/*.md; do | |
| if [[ "$file" == "changelog/_template.md.j2" ]]; then | |
| continue | |
| fi | |
| filename=$(basename "$file") | |
| type=$(echo "$filename" | sed -E 's/^[0-9]+\.([a-z]+)(\.[0-9]+)?\.md$/\1/') | |
| if ! echo "$VALID_TYPES" | grep -wq "$type"; then | |
| INVALID_FRAGMENTS="$INVALID_FRAGMENTS\n - $filename (type: '$type')" | |
| fi | |
| done | |
| if [ -n "$INVALID_FRAGMENTS" ]; then | |
| echo "Error: Invalid changelog fragment types found:" | |
| echo -e "$INVALID_FRAGMENTS" | |
| echo "Valid types are: $VALID_TYPES" | |
| exit 1 | |
| fi | |
| echo "Found $FRAGMENT_COUNT changelog fragment(s)" | |
| echo "has_fragments=true" >> $GITHUB_OUTPUT | |
| - name: Preview changelog | |
| working-directory: pipecat | |
| run: | | |
| echo "## Preview of changelog for version ${{ inputs.version }}" | |
| echo "" | |
| uv run towncrier build --draft --version "${{ inputs.version }}" --date "${{ steps.set_date.outputs.release_date }}" | |
| - name: Build changelog | |
| working-directory: pipecat | |
| run: | | |
| uv run towncrier build --version "${{ inputs.version }}" --date "${{ steps.set_date.outputs.release_date }}" --yes | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "Update changelog for version ${{ inputs.version }}" | |
| title: "Release ${{ inputs.version }} - Changelog Update" | |
| body: | | |
| ## Changelog Update for Release ${{ inputs.version }} | |
| This PR updates the CHANGELOG.md with all changes for version **${{ inputs.version }}**. | |
| - **Version:** ${{ inputs.version }} | |
| - **Date:** ${{ steps.set_date.outputs.release_date }} | |
| - **Fragments processed:** ${{ steps.check_fragments.outputs.fragment_count }} | |
| branch: changelog-${{ inputs.version }} | |
| delete-branch: true | |
| labels: | | |
| changelog | |
| release |