Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mo3et committed Oct 22, 2024
1 parent b21d6dd commit 218b7b5
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- name: Run Go Changelog Generator
run: |
# Run the Go changelog generator, pass the release tag if available
# Run the Go changelog generator, passing 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
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Handle changelog files
run: |
# Remove the 'v' prefix from the tag name and extract Major.Minor version
# Extract Major.Minor version by removing the 'v' prefix from the tag name
TAG_NAME=${{ github.event.release.tag_name }}
CHANGELOG_VERSION_NUMBER=$(echo "$TAG_NAME" | sed 's/^v//' | grep -oP '^\d+\.\d+')
Expand All @@ -36,21 +36,23 @@ jobs:
# Check if the changelog file for the current release already exists
if [ -f "$CHANGELOG_PATH" ]; then
# If the file exists, append the current content to the temporary changelog
# If the file exists, append the new changelog to the existing one
cat "$CHANGELOG_PATH" >> "${TAG_NAME}-changelog.md"
# Overwrite the existing changelog with the updated content
mv "${TAG_NAME}-changelog.md" "$CHANGELOG_PATH"
else
# If it doesn't exist, rename the temp changelog to the new changelog file
# If the changelog file doesn't exist, rename the temp changelog file to the new changelog file
mv "${TAG_NAME}-changelog.md" "$CHANGELOG_PATH"
# Update CHANGELOG/README.md with the new file in reverse order
# Ensure that README.md exists
if [ ! -f "CHANGELOG/README.md" ]; then
echo -e "# CHANGELOGs\n" > CHANGELOG/README.md
fi
# Insert the new changelog at the top of the README.md file
sed -i "2s/^/- [$CHANGELOG_FILENAME](./$CHANGELOG_FILENAME)\n/" CHANGELOG/README.md
# Add the new changelog entry at the top of the README.md
if ! grep -q "\[$CHANGELOG_FILENAME\]" CHANGELOG/README.md; then
sed -i "2i- [$CHANGELOG_FILENAME](./$CHANGELOG_FILENAME)" CHANGELOG/README.md
fi
fi
- name: Clean up
Expand Down

0 comments on commit 218b7b5

Please sign in to comment.