-
Notifications
You must be signed in to change notification settings - Fork 2
68 lines (64 loc) · 2.29 KB
/
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Changelog
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"
RUSTDOCFLAGS: '--deny warnings'
permissions:
id-token: write
packages: write
contents: write
pull-requests: write
on:
workflow_dispatch:
workflow_call:
jobs:
changelog:
name: Create changelog
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-tags: 'true'
fetch-depth: 0
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- id: release
run: echo "version=v$(cargo pkgid --manifest-path crates/bin/Cargo.toml | cut -d '@' -f2)" >> "$GITHUB_OUTPUT"
- name: Install git-cliff
run: cargo install git-cliff
- name: Generate a changelog
run: |
if [ -f CHANGELOG.md ]; then
git-cliff --config github --prepend CHANGELOG.md --latest
else
git-cliff --config github --output CHANGELOG.md
fi
env:
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit changelog
run: |
git checkout -b "changelog/${{ steps.release.outputs.version }}"
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
set +e
git add CHANGELOG.md
git commit -m "chore: Update changelog"
git push origin "changelog/${{ steps.release.outputs.version }}" --force
- name: Check out repository
uses: actions/checkout@v4
with:
ref: "changelog/${{ steps.release.outputs.version }}"
- name: Create pull request for changelog
run: |
alreadyExists=$(gh pr list --json headRefName | jq '.[] | select(.headRefName == "changelog/${{ steps.release.outputs.version }}") | any')
if [[ "$alreadyExists" == "" ]]; then
branch=$(git branch --show-current)
gh pr create --head "$branch" --title "Changelog for ${{ steps.release.outputs.version }}" --body "This PR updates the changelog for version ${{ steps.release.outputs.version }}."
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}