-
Notifications
You must be signed in to change notification settings - Fork 23
50 lines (43 loc) · 1.87 KB
/
update_changelog.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Update Changelog file
on:
workflow_dispatch:
release:
types: [published]
jobs:
update-changelog:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Get latest release tag
id: get_latest_release
run: echo "::set-output name=tag::$(gh release list -R ${{ github.repository }} --limit 1 --json tagName --jq '.[0].tagName')"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get release notes
id: get_release_notes
run: |
release_notes=$(gh release view ${{ steps.get_latest_release.outputs.tag }} -R ${{ github.repository }} --json body --jq '.body')
echo "::set-output name=notes::$release_notes"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update CHANGELOG.md
run: |
echo "## [${{ steps.get_latest_release.outputs.tag }}] - $(date +"%Y-%m-%d")" >> CHANGELOG.md
echo "${{ steps.get_release_notes.outputs.notes }}" >> CHANGELOG.md
echo "" >> CHANGELOG.md
- name: Create new branch
run: |
git checkout -b update-changelog-${{ steps.get_latest_release.outputs.tag }}
git add CHANGELOG.md
git commit -m 'Update CHANGELOG.md for ${{ steps.get_latest_release.outputs.tag }}'
git push -u origin update-changelog-${{ steps.get_latest_release.outputs.tag }}
- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
--title "Update CHANGELOG.md for ${{ steps.get_latest_release.outputs.tag }}" \
--body "This PR updates the CHANGELOG.md file with the release notes for ${{ steps.get_latest_release.outputs.tag }}." \
--head update-changelog-${{ steps.get_latest_release.outputs.tag }} \
--base main