Skip to content

Release Creation

Release Creation #41

name: Release Creation
on:
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Build the changelog
- name: Build Changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v4
with:
configuration: ".github/configs/release-changelog-builder-action.json"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Change the update file
- name: Append changelog to file
id: check_append
run: |
echo "Checking and appending changelog to file if new"
changelog_content="${{ steps.build_changelog.outputs.changelog }}"
current_date=$(date -u +"%Y-%m-%d %H:%M:%S")
new_entry=$(cat <<EOF
# $current_date
$changelog_content
EOF
)
# Ensure the new entry ends with a newline
new_entry="${new_entry}\n"
# Ensure the existing updates file ends with a newline
if [ -s docs/updates.txt ] && [ "$(tail -c 1 docs/updates.txt)" != "" ]; then
echo "" >> docs/updates.txt
fi
# Check if the new entry is already in the file
if grep -Fq "$changelog_content" docs/updates.txt; then
echo "No new changelog content to append."
echo "new_changes=false" >> $GITHUB_ENV
else
# Append the new entry to the updates file
echo -e "$new_entry" | cat - docs/updates.txt > temp
mv temp docs/updates.txt
echo "new_changes=true" >> $GITHUB_ENV
fi
- name: Commit changes
if: env.new_changes == 'true'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add docs/updates.txt
git commit -m 'Update updates.txt'
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}