-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(deps): improve changelog generate. (#79)
- Loading branch information
Showing
4 changed files
with
59 additions
and
62 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,63 @@ | ||
name: Update Changelog | ||
name: Release Changelog | ||
|
||
on: | ||
release: | ||
types: [released] # Trigger the workflow when a new release is published | ||
|
||
types: [released] | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
update-changelog: | ||
runs-on: ubuntu-latest # Use the latest Ubuntu environment | ||
runs-on: ubuntu-latest | ||
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 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Debug release info | ||
- name: Run Go Changelog Generator | ||
run: | | ||
echo "Release tag: ${{ github.event.release.tag_name }}" | ||
echo "Release body:" | ||
cat release_notes.txt # Output the fetched release notes for debugging | ||
# Run the Go changelog generator, pass the release tag if available | ||
if [ "${{ github.event.release.tag_name }}" = "latest" ]; then | ||
go run tools/changelog.go > "${{ github.event.release.tag_name }}-changelog.md" | ||
else | ||
go run tools/changelog.go "${{ github.event.release.tag_name }}" > "${{ github.event.release.tag_name }}-changelog.md" | ||
fi | ||
- name: Prepend release notes to CHANGELOG.md and clean up | ||
- name: Handle changelog files | ||
run: | | ||
# If CHANGELOG.md does not exist, create an empty one | ||
if [ ! -f CHANGELOG.md ]; then | ||
touch CHANGELOG.md | ||
# Remove the 'v' prefix from the tag name | ||
TAG_NAME=${{ github.event.release.tag_name }} | ||
NAME_WITHOUT_V=$(echo "$TAG_NAME" | sed 's/^v//') | ||
# Create the CHANGELOG directory if it doesn't exist | ||
mkdir -p CHANGELOG | ||
# Define the new changelog file path | ||
NEW_CHANGELOG_PATH="CHANGELOG/CHANGELOG-$NAME_WITHOUT_V.md" | ||
# Check if the changelog file for the current release already exists | ||
if [ -f "$NEW_CHANGELOG_PATH" ]; then | ||
# If the file exists, append the current content to the temporary changelog | ||
cat "$NEW_CHANGELOG_PATH" >> "${TAG_NAME}-changelog.md" | ||
# Overwrite the existing changelog with the updated content | ||
mv "${TAG_NAME}-changelog.md" "$NEW_CHANGELOG_PATH" | ||
else | ||
# If it doesn't exist, rename the temp changelog to the new changelog file | ||
mv "${TAG_NAME}-changelog.md" "$NEW_CHANGELOG_PATH" | ||
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: Clean up | ||
run: | | ||
# Remove any temporary files that were created during the process | ||
rm -f "${{ github.event.release.tag_name }}-changelog.md" | ||
- name: Create Pull Request | ||
uses: peter-evans/[email protected] | ||
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 | ||
commit-message: "Update CHANGELOG 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 | ||
body: "This PR updates the CHANGELOG files for release ${{ github.event.release.tag_name }}" # Description of the PR | ||
base: main | ||
delete-branch: true | ||
labels: changelog # Add a label to the PR |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## [v0.0.39-alpha-1](https://github.com/openimsdk/actions-test/releases/tag/v0.0.39-alpha-1) 2024-10-21 | ||
|
||
### New Features | ||
* feat: Update version to v0.0.19 [#30](https://github.com/openimsdk/actions-test/pull/30) | ||
|
||
### Bug Fixes | ||
* fix: swm [#34](https://github.com/openimsdk/actions-test/pull/34) | ||
|
||
### Others | ||
* Update version to v0.0.21 [#32](https://github.com/openimsdk/actions-test/pull/32) | ||
* T1 [#35](https://github.com/openimsdk/actions-test/pull/35) | ||
* update teset [#36](https://github.com/openimsdk/actions-test/pull/36) | ||
* hello [#39](https://github.com/openimsdk/actions-test/pull/39) | ||
* rm [#51](https://github.com/openimsdk/actions-test/pull/51) | ||
* 21321 [#53](https://github.com/openimsdk/actions-test/pull/53) | ||
* 1x [#54](https://github.com/openimsdk/actions-test/pull/54) | ||
* Update CHANGELOG for release v0.0.34 [#74](https://github.com/openimsdk/actions-test/pull/74) | ||
|
||
**Full Changelog**: [vv0.0.20...v0.0.39-alpha-1](https://github.com/openimsdk/actions-test/compare/v0.0.20...v0.0.39-alpha-1) | ||
|