Workflow file for this run
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 | |
on: | |
push: | |
tags: | |
- "v*" # Akan berjalan setiap kali ada tag baru yang dipush (misal: v1.1.0) | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Pastikan semua commit di-fetch | |
- name: Generate Changelog | |
run: | | |
# Ambil tag sebelumnya, jika tidak ada tag sebelumnya gunakan commit pertama | |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || git rev-list --max-parents=0 HEAD) | |
NEW_TAG=${{ github.ref_name }} | |
echo "Previous tag: $PREVIOUS_TAG" | |
echo "New tag: $NEW_TAG" | |
echo "Generating changelog between $PREVIOUS_TAG and $NEW_TAG" | |
echo '## Changelog' > changelog.md | |
echo '' >> changelog.md | |
echo '### New Features' >> changelog.md | |
git log $PREVIOUS_TAG..$NEW_TAG --grep '^feat' --pretty=format:"- %h %s (%an)" >> changelog.md | |
echo '' >> changelog.md | |
echo '### Bug Fixes' >> changelog.md | |
git log $PREVIOUS_TAG..$NEW_TAG --grep '^fix' --pretty=format:"- %h %s (%an)" >> changelog.md | |
echo '' >> changelog.md | |
echo '### Chores' >> changelog.md | |
git log $PREVIOUS_TAG..$NEW_TAG --grep '^chore' --pretty-format:"- %h %s (%an)" >> changelog.md | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
body_path: changelog.md | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |