Generating release notifications for #19
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: Release Notes | |
on: | |
push: | |
branches: | |
- main | |
run-name: Generating release notifications for ${{ github.base_ref }} | |
permissions: | |
contents: write | |
jobs: | |
create-publish-release-notes: | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Fetch all tags | |
run: git fetch --tags | |
- name: Get latest and previous tags | |
id: tags | |
run: | | |
all_tags=$(git tag -l --sort=-creatordate) | |
latest_tag=$(echo "$all_tags" | sed -n '1p') | |
previous_tag=$(echo "$all_tags" | sed -n '2p') | |
echo "latest_tag=$latest_tag" >> "$GITHUB_OUTPUT" | |
echo "previous_tag=$previous_tag" >> "$GITHUB_OUTPUT" | |
# Debug output | |
echo "Latest tag: $latest_tag" | |
echo "Second to latest tag: $previous_tag" | |
- name: Generate Release Notes | |
env: | |
PREVIOUS_TAG: ${{ steps.tags.outputs.previous_tag }} | |
LATEST_TAG: ${{ steps.tags.outputs.latest_tag }} | |
run: | | |
echo "Changes between $PREVIOUS_TAG and $LATEST_TAG:" > release-notes.txt | |
git log "$PREVIOUS_TAG..$LATEST_TAG" --oneline >> release-notes.txt | |
RELEASE_NOTES=$(cat release-notes.txt) | |
echo "RELEASE_NOTES<<EOF" >> "$GITHUB_ENV" | |
echo "$RELEASE_NOTES" >> "$GITHUB_ENV" | |
echo "EOF" >> "$GITHUB_ENV" | |
- name: Create or Update Release | |
env: | |
LATEST_TAG: ${{ steps.tags.outputs.latest_tag }} | |
run: | | |
if gh release view "$LATEST_TAG" &>/dev/null; then | |
echo "Release exists. Updating..." | |
gh release edit "$LATEST_TAG" --notes "$RELEASE_NOTES" | |
else | |
echo "Creating new release..." | |
gh release create "$LATEST_TAG" --notes "$RELEASE_NOTES" | |
fi | |
- name: Update Release with Custom Notes | |
env: | |
RELEASE_NOTES: ${{ env.RELEASE_NOTES }} | |
LATEST_TAG: ${{ steps.tags.outputs.latest_tag }} | |
run: | | |
CUSTOM_NOTES=$(echo $RELEASE_NOTES | py ./scripts/sort-release-notes.py) | |
gh release edit "$LATEST_TAG" --notes "$CUSTOM_NOTES" |