Skip to content

Commit 88e9949

Browse files
committed
ci: another attempt ro fix CI for changelog
1 parent c9919c3 commit 88e9949

File tree

3 files changed

+67
-43
lines changed

3 files changed

+67
-43
lines changed

.github/workflows/changelog.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Changelog
2+
3+
env:
4+
CARGO_TERM_COLOR: always
5+
RUST_BACKTRACE: 1
6+
RUSTFLAGS: "-D warnings"
7+
RUSTDOCFLAGS: '--deny warnings'
8+
9+
permissions:
10+
id-token: write
11+
packages: write
12+
contents: write
13+
pull-requests: write
14+
15+
on:
16+
workflow_dispatch:
17+
workflow_call:
18+
19+
jobs:
20+
changelog:
21+
name: Create changelog
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Check out repository
25+
uses: actions/checkout@v4
26+
- name: Install Rust
27+
uses: dtolnay/rust-toolchain@stable
28+
- uses: Swatinem/rust-cache@v2
29+
- id: release
30+
run: echo "version=$(cargo pkgid --manifest-path crates/bin/Cargo.toml | cut -d '@' -f2)" >> "$GITHUB_OUTPUT"
31+
- name: Install git-cliff
32+
run: cargo install git-cliff
33+
- name: Generate a changelog
34+
run: |
35+
if [ -f CHANGELOG.md ]; then
36+
git-cliff --config github --prepend CHANGELOG.md --latest
37+
else
38+
git-cliff --config github --output CHANGELOG.md
39+
fi
40+
env:
41+
OUTPUT: CHANGELOG.md
42+
GITHUB_REPO: ${{ github.repository }}
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
- name: Commit changelog
45+
run: |
46+
git checkout -b "changelog/v${{ steps.release.outputs.version }}"
47+
git config user.name 'github-actions[bot]'
48+
git config user.email 'github-actions[bot]@users.noreply.github.com'
49+
set +e
50+
git add CHANGELOG.md
51+
git commit -m "chore: Update changelog"
52+
git push origin "changelog/v${{ steps.release.outputs.version }}" --force
53+
- name: Check out repository
54+
uses: actions/checkout@v4
55+
with:
56+
ref: "changelog/v${{ steps.release.outputs.version }}"
57+
- name: Create pull request for changelog
58+
run: |
59+
alreadyExists=$(gh pr list --json headRefName | jq '.[] | select(.headRefName == "changelog/v${{ steps.release.outputs.version }}") | any')
60+
if [[ "$alreadyExists" == "" ]]; then
61+
branch=$(git branch --show-current)
62+
gh pr create --head "$branch" --title "Changelog for ${{ steps.release.outputs.version }}" --body "This PR updates the changelog for version ${{ steps.release.outputs.version }}."
63+
fi
64+
env:
65+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish.yml

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -53,49 +53,9 @@ jobs:
5353

5454
changelog:
5555
needs: [version, create-release]
56+
uses: ./.github/workflows/changelog.yml
5657
name: Create changelog
57-
runs-on: ubuntu-latest
58-
steps:
59-
- name: Check out repository
60-
uses: actions/checkout@v4
61-
- run: git fetch --tags origin
62-
- name: Install Rust
63-
uses: dtolnay/rust-toolchain@stable
64-
- uses: Swatinem/rust-cache@v2
65-
- name: Install git-cliff
66-
run: cargo install git-cliff
67-
- name: Generate a changelog
68-
run: |
69-
if [ -f CHANGELOG.md ]; then
70-
git-cliff --config github --prepend CHANGELOG.md --latest
71-
else
72-
git-cliff --config github --output CHANGELOG.md
73-
fi
74-
env:
75-
OUTPUT: CHANGELOG.md
76-
GITHUB_REPO: ${{ github.repository }}
77-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78-
- name: Commit changelog
79-
run: |
80-
git checkout -b "changelog/v${{ needs.version.outputs.version }}"
81-
git config user.name 'github-actions[bot]'
82-
git config user.email 'github-actions[bot]@users.noreply.github.com'
83-
set +e
84-
git add CHANGELOG.md
85-
git commit -m "chore: Update changelog"
86-
git push origin "changelog/v${{ needs.version.outputs.version }}" --force
87-
- name: Check out repository
88-
uses: actions/checkout@v4
89-
- name: Create pull request for changelog
90-
run: |
91-
git pull
92-
alreadyExists=$(gh pr list --json headRefName | jq '.[] | select(.headRefName == "changelog/v${{ needs.version.outputs.version }}") | any')
93-
if [[ "$alreadyExists" == "" ]]; then
94-
branch=$(git branch --show-current)
95-
gh pr create --head "$branch" --title "Changelog for ${{ needs.version.outputs.version }}" --body "This PR updates the changelog for version ${{ needs.version.outputs.version }}."
96-
fi
97-
env:
98-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
secrets: inherit
9959

10060
build-and-publish:
10161
needs: [version, create-release]

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ lol/rust/Cargo.lock
88
semver-checks/
99
demo.sh
1010
ee.json
11-
.github/
1211

1312
crates/**/*.cdx.xml
1413
crates/**/*.cdx.json

0 commit comments

Comments
 (0)