Skip to content

Generate Changelog File and Create Release #2

Generate Changelog File and Create Release

Generate Changelog File and Create Release #2

Workflow file for this run

name: Generate Changelog File and Create Release
on:
push:
tags:
- "v*"
workflow_dispatch:
jobs:
generate-changelog:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Get Latest Non-Pre-Release Tag
id: get_tag
run: |
LATEST_TAG=$(git tag --list | grep -vE "beta|alpha" | sort -V | tail -n 1)
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
- name: Generate Changelog
id: changelog
run: |
COMMITS=$(git log $LATEST_TAG..HEAD --pretty=format:"- [%h](https://github.com/${{ github.repository }}/commit/%H) %s")
echo -e "### Changelog for ${{ github.ref_name }}\n\n$COMMITS" > changelog.md
- name: Commit and Push Changelog
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add changelog.md
git commit -m "Add changelog for ${{ github.ref_name }}"
git push
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ github.ref }}
name: Release ${{ github.ref_name }}
body_path: changelog.md
draft: false
prerelease: false