diff --git a/.github/workflows/changelog-pr.yml b/.github/workflows/changelog-pr.yml new file mode 100644 index 0000000..771d442 --- /dev/null +++ b/.github/workflows/changelog-pr.yml @@ -0,0 +1,50 @@ +name: Generate Changelog + +on: + push: + tags: + - "v*" + +permissions: + contents: write + +jobs: + changelog: + name: Generate changelog + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Generate a changelog + uses: orhun/git-cliff-action@v4.4.2 + with: + config: cliff.toml + env: + OUTPUT: CHANGELOG.md + GITHUB_REPO: ${{ github.repository }} + + - name: Commit + id: commit + run: | + TAG=${GITHUB_REF#refs/tags/} + echo "tag=$TAG" >> $GITHUB_OUTPUT + branch_name="$TAG-changelog" + + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' + set +e + git checkout -b "$branch_name" + git add CHANGELOG.md + git commit -m "chore: update changelog" + git push origin "$branch_name" + + - name: Create Pull Request + uses: repo-sync/pull-request@v2 + with: + destination_branch: main + source_branch: ${{ steps.commit.outputs.tag }}-changelog + pr_title: "chore: update changelog for ${{ steps.commit.outputs.tag }}" + pr_body: "Automated changelog update for release ${{ steps.commit.outputs.tag }}"