Skip to content

Update changlog.yaml #5

Update changlog.yaml

Update changlog.yaml #5

Workflow file for this run

name: Update Changelog
on:
push:
tags: # Triggers on pushing any tag
release:
types: [published, edited, created, released, prereleased] # Triggers on various release events
jobs:
update-changelog:
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get previous tag
id: previousTag
run: |
# Fetch all tags
git fetch --tags
# Get the current tag from the release event, if available
if [ "${{ github.event.release.tag_name }}" != "" ]; then
current_tag="${{ github.event.release.tag_name }}"
else
# If not triggered by a release event, use the latest tag
current_tag=$(git describe --tags --abbrev=0)
fi
# Get the previous tag
previous_tag=$(git tag --sort=-creatordate | grep -v "^${current_tag}$" | head -n 1)
# Ensure the previous tag is not empty
if [ -z "$previous_tag" ]; then
echo "No previous tag found, possibly first release."
previous_tag=$(git rev-list --max-parents=0 HEAD) # Use initial commit if no previous tag
fi
echo "previousTag: $previous_tag"
echo "previousTag=$previous_tag" >> $GITHUB_ENV
- name: Update CHANGELOG
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
fromTag: ${{ env.previousTag }}
toTag: ${{ github.ref_name }}
writeToFile: true
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4 # Commit the updated changelog
with:
file_pattern: CHANGELOG.md
commit_message: 'Update CHANGELOG.md for ${{ github.ref_name }} [skip ci]'