name: Create GitHub Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Extract tag name
id: tag_name
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Generate simple changelog
run: |
# Get the latest tag before this one
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$PREVIOUS_TAG" ]; then
# If no previous tag exists, get all commits
git log --pretty=format:"- %s" > changelog.md
else
# Get commits between the previous tag and this one
git log --pretty=format:"- %s" ${PREVIOUS_TAG}..HEAD > changelog.md
fi
- name: Create Release
uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag'
with:
name: Release ${{ github.ref_name }}
body_path: changelog.md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}