From 7f951ae87ce50b49d74c97a3dbc48db50773e85b Mon Sep 17 00:00:00 2001 From: Erfan Date: Fri, 1 Nov 2024 02:45:20 +0330 Subject: [PATCH] fix: update and fix some changelog yml bugs --- .github/workflows/changelog.yml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index a037910..42dc9bf 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -1,22 +1,24 @@ -name: Generate Changelog +name: Update Changelog + on: - workflow_dispatch: - push: - tags: ['v*'] + release: + types: [published] jobs: - generate-changelog: + update-changelog: runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v4 + - name: Checkout Code + uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 0 - name: Generate Changelog id: changelog run: | PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || git rev-list --max-parents=0 HEAD) - git log ${PREVIOUS_TAG}..HEAD --pretty=format:"- %s" > CHANGELOG.md + git log ${PREVIOUS_TAG}..HEAD --pretty=format:"- %s" >> CHANGELOG.md - name: Commit Changelog run: | @@ -24,12 +26,14 @@ jobs: git config --local user.name "GitHub Action" git add CHANGELOG.md git commit -m "docs: update changelog" || echo "No changes to commit" - git push origin HEAD:master + git push origin master - - name: Create GitHub Release + - name: Create or Update Release uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') with: body_path: CHANGELOG.md draft: false - prerelease: false \ No newline at end of file + prerelease: false + tag_name: ${{ github.event.release.tag_name }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}