feat(ci): add release workflow step

This commit is contained in:
perf3ct 2025-06-19 21:59:20 +00:00
parent 7066d48e57
commit ae70fe4684
No known key found for this signature in database
GPG Key ID: 569C4EEC436F5232
1 changed files with 58 additions and 0 deletions

58
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,58 @@
name: Create Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
run: |
# Get the previous tag
PREVIOUS_TAG=$(git tag --sort=-version:refname | sed -n '2p')
CURRENT_TAG=${GITHUB_REF#refs/tags/}
echo "## Changes" > changelog.md
echo "" >> changelog.md
if [ -n "$PREVIOUS_TAG" ]; then
echo "### Commits since $PREVIOUS_TAG:" >> changelog.md
git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..$CURRENT_TAG >> changelog.md
else
echo "### All commits:" >> changelog.md
git log --pretty=format:"- %s (%h)" $CURRENT_TAG >> changelog.md
fi
echo "" >> changelog.md
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/$PREVIOUS_TAG...$CURRENT_TAG" >> changelog.md
# Set output for use in release step
{
echo 'CHANGELOG<<EOF'
cat changelog.md
echo 'EOF'
} >> $GITHUB_OUTPUT
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.CHANGELOG }}
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}