v0.0.38 #11
Workflow file for this run
This file contains 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: Update Changelog | |
on: | |
release: | |
types: [released] # Trigger the workflow when a new release is published | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
update-changelog: | |
runs-on: ubuntu-latest # Use the latest Ubuntu environment | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 # Checkout the repository code | |
- name: Get release notes via curl | |
run: | | |
# Use curl to fetch the release body from GitHub API | |
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.event.release.tag_name }} \ | |
| jq -r '.body' > release_notes.txt | |
- name: Debug release info | |
run: | | |
echo "Release tag: ${{ github.event.release.tag_name }}" | |
echo "Release body:" | |
cat release_notes.txt # Output the fetched release notes for debugging | |
- name: Prepend release notes to CHANGELOG.md and clean up | |
run: | | |
# If CHANGELOG.md does not exist, create an empty one | |
if [ ! -f CHANGELOG.md ]; then | |
touch CHANGELOG.md | |
fi | |
# Write the new release notes into a temporary file 'new_changelog.md' | |
echo "## ${{ github.event.release.tag_name }} - $(date '+%Y-%m-%d')" > new_changelog.md | |
echo "" >> new_changelog.md | |
cat release_notes.txt >> new_changelog.md | |
echo "" >> new_changelog.md | |
# Append the current CHANGELOG.md content to the temporary file | |
cat CHANGELOG.md >> new_changelog.md | |
# Replace the original CHANGELOG.md with the updated one | |
mv new_changelog.md CHANGELOG.md | |
# Delete the release notes temporary file | |
rm release_notes.txt | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v7.0.5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} # Use the repository token to authenticate | |
commit-message: "Update CHANGELOG.md for release ${{ github.event.release.tag_name }}" # Commit message for the PR | |
title: "Update CHANGELOG for release ${{ github.event.release.tag_name }}" # Title of the PR | |
body: "This PR updates the CHANGELOG.md with the notes for release ${{ github.event.release.tag_name }}" # Description of the PR | |
base: main # Target the 'main' branch for the PR | |
delete-branch: true # Delete the branch after the PR is merged | |
labels: changelog # Add a label to the PR |