From 77e96c4207611a49fbaf6c9ff5b2705732268e24 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 14 Dec 2024 13:26:00 +0000 Subject: [PATCH] add changelog creator --- .github/workflows/version_increment.yml | 22 ++++++++++++++++------ generate_changelog.py | 4 ++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/version_increment.yml b/.github/workflows/version_increment.yml index 754fd4f9..bb564b37 100644 --- a/.github/workflows/version_increment.yml +++ b/.github/workflows/version_increment.yml @@ -67,9 +67,19 @@ jobs: - name: Update CHANGELOG.md if: env.new_version != '' run: | - echo "## v${{ env.new_version }} - $(date +'%Y-%m-%d')" >> CHANGELOG.md - cat changelog_entry.md >> CHANGELOG.md - echo "" >> CHANGELOG.md + # Write the new version header and generated entry to a temp file + echo "## v${{ env.new_version }} - $(date +'%Y-%m-%d')" > temp_changelog.md + cat changelog_entry.md >> temp_changelog.md + echo "" >> temp_changelog.md + + # Append the old CHANGELOG.md content after the new entry + if [ -f CHANGELOG.md ]; then + cat CHANGELOG.md >> temp_changelog.md + fi + + # Move temp back to CHANGELOG.md + mv temp_changelog.md CHANGELOG.md + git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add CHANGELOG.md @@ -79,9 +89,9 @@ jobs: - name: Read Changelog Entry id: read_changelog run: | - body="$(cat changelog_entry.md)" - # Set the output 'body' to contain the file contents. - echo "::set-output name=body::$body" + echo "body<> $GITHUB_OUTPUT + cat changelog_entry.md >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT - name: Create a new GitHub release if: env.new_version != '' diff --git a/generate_changelog.py b/generate_changelog.py index 0974a4b0..05bb6d8f 100644 --- a/generate_changelog.py +++ b/generate_changelog.py @@ -17,7 +17,7 @@ prompt = f""" You are a helpful assistant who generates changelog entries for the python-amazon-sp-api, a wrapper to access Amazon's Selling Partner API with an easy-to-use interface. This tool helps developers and businesses connect seamlessly with Amazon's vast marketplace, enabling powerful automations and data management. This is a growing changelog entry for the project. Only add changes that are relevant to the end-users, such as new features, changes to existing features, and bug fixes. Categorize and group changes between internal and relevant to the project.. -The current version is {__version__}. Add this to the Changelog header. +The current version is {__version__}. Add this to the Changelog header. Never include dates or release status in the changelog entry. Given the following git diff, generate a concise, well-formatted Markdown changelog entry: @@ -35,7 +35,7 @@ temperature=0.3, max_tokens=500 ) -print (response) + changelog_entry = response.choices[0].message.content.strip() print(changelog_entry) with open('changelog_entry.md', 'w') as out_file: