Skip to content

Publish release changelog #42

Publish release changelog

Publish release changelog #42

Workflow file for this run

name: Publish release changelog
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+*
workflow_dispatch:
inputs:
version:
description: 'Version to test (e.g., 3.0.1)'
required: true
default: '3.0.1'
type: string
source_branch:
description: 'Source branch to merge from (default: pmm-version)'
required: false
default: ''
type: string
target_docs_branch:
description: 'Target docs branch (default: v3)'
required: false
default: 'v3'
type: string
permissions:
contents: read
jobs:
release:
permissions:
contents: write # for softprops/action-gh-release to create GitHub release
if: (startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch') && github.repository == 'percona/pmm'
runs-on: ubuntu-22.04
steps:
- name: Set version for testing
id: set_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
echo "source_branch=${{ inputs.source_branch }}" >> $GITHUB_OUTPUT
echo "target_docs_branch=${{ inputs.target_docs_branch }}" >> $GITHUB_OUTPUT
echo "Testing with version: ${{ inputs.version }}"
echo "Target docs branch: ${{ inputs.target_docs_branch }}"
else
version="${{ github.ref }}"
version="${version/refs\/tags\/v/}"
echo "version=$version" >> $GITHUB_OUTPUT
echo "source_branch=" >> $GITHUB_OUTPUT
echo "target_docs_branch=v3" >> $GITHUB_OUTPUT
echo "Release with version: $version"
fi
- name: Build Changelog
id: pmm_release
shell: bash
run: |
version="${{ steps.set_version.outputs.version }}"
source_branch="${{ steps.set_version.outputs.source_branch }}"
target_docs_branch="${{ steps.set_version.outputs.target_docs_branch }}"
echo "Building changelog for version: $version"
echo "Target docs branch: $target_docs_branch"
# Use source branch if provided, otherwise use pmm-$version
if [ -n "$source_branch" ]; then
fallback_branch="$source_branch"
echo "Will fallback to source branch: $fallback_branch"
else
fallback_branch="pmm-$version"
echo "Will fallback to branch: $fallback_branch"
fi
# Try to download from target docs branch first
if ! wget https://raw.githubusercontent.com/percona/pmm/$target_docs_branch/documentation/docs/release-notes/$version.md -O ${{ github.workspace }}-CHANGELOG.txt 2>/dev/null; then
echo "Documentation not found in $target_docs_branch branch, trying $fallback_branch branch..."
if ! wget https://raw.githubusercontent.com/percona/pmm/$fallback_branch/documentation/docs/release-notes/$version.md -O ${{ github.workspace }}-CHANGELOG.txt 2>/dev/null; then
echo "Documentation not found in $fallback_branch branch either."
echo "ERROR: Could not find release notes for version $version"
exit 1
fi
fi
echo "Changelog file size: $(wc -c < ${{ github.workspace }}-CHANGELOG.txt) bytes"
echo "Changelog content preview:"
head -5 ${{ github.workspace }}-CHANGELOG.txt
- name: Convert mkdocs
shell: bash --noprofile --norc -ex {0}
run: |
grep -rl '!!! caution' ${{ github.workspace }}-CHANGELOG.txt | xargs --no-run-if-empty sed -i 's/\!\!\! caution alert alert-warning "\(.*\)"/\> \:warning\: **\1**/g'
grep -rl '!!! caution' ${{ github.workspace }}-CHANGELOG.txt | xargs --no-run-if-empty sed -i 's/\!\!\! caution alert alert-warning/\> \:warning\:/g'
grep -rl '!!! alert alert-info' ${{ github.workspace }}-CHANGELOG.txt | xargs --no-run-if-empty sed -i 's/\!\!\! alert alert-info/\>/g'
grep -rl '!!! note alert alert-primary' ${{ github.workspace }}-CHANGELOG.txt | xargs --no-run-if-empty sed -i 's/\!\!\! note alert alert-primary "\(.*\)"/\> \:memo\: **\1**/g'
grep -rl '!!! note alert alert-primary' ${{ github.workspace }}-CHANGELOG.txt | xargs --no-run-if-empty sed -i 's/\!\!\! note alert alert-primary/\> \:memo\: **Note**/g'
- name: Create Release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
with:
body_path: ${{ github.workspace }}-CHANGELOG.txt
draft: true
tag_name: ${{ github.event_name == 'workflow_dispatch' && format('v{0}-test', steps.set_version.outputs.version) || github.ref_name }}
name: ${{ github.event_name == 'workflow_dispatch' && format('Test Release v{0}', steps.set_version.outputs.version) || format('Release {0}', github.ref_name) }}