Skip to content

Commit 38777e5

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

File tree

3 files changed

+70
-43
lines changed

3 files changed

+70
-43
lines changed

.github/workflows/changelog.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
with:
27+
fetch-tags: 'true'
28+
fetch-depth: 0
29+
- name: Install Rust
30+
uses: dtolnay/rust-toolchain@stable
31+
- uses: Swatinem/rust-cache@v2
32+
- id: release
33+
run: echo "version=$(cargo pkgid --manifest-path crates/bin/Cargo.toml | cut -d '@' -f2)" >> "$GITHUB_OUTPUT"
34+
- name: Install git-cliff
35+
run: cargo install git-cliff
36+
- name: Generate a changelog
37+
run: |
38+
if [ -f CHANGELOG.md ]; then
39+
git-cliff --config github --prepend CHANGELOG.md --latest
40+
else
41+
git-cliff --config github --output CHANGELOG.md
42+
fi
43+
env:
44+
OUTPUT: CHANGELOG.md
45+
GITHUB_REPO: ${{ github.repository }}
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
- name: Commit changelog
48+
run: |
49+
git checkout -b "changelog/v${{ steps.release.outputs.version }}"
50+
git config user.name 'github-actions[bot]'
51+
git config user.email 'github-actions[bot]@users.noreply.github.com'
52+
set +e
53+
git add CHANGELOG.md
54+
git commit -m "chore: Update changelog"
55+
git push origin "changelog/v${{ steps.release.outputs.version }}" --force
56+
- name: Check out repository
57+
uses: actions/checkout@v4
58+
with:
59+
ref: "changelog/v${{ steps.release.outputs.version }}"
60+
- name: Create pull request for changelog
61+
run: |
62+
alreadyExists=$(gh pr list --json headRefName | jq '.[] | select(.headRefName == "changelog/v${{ steps.release.outputs.version }}") | any')
63+
if [[ "$alreadyExists" == "" ]]; then
64+
branch=$(git branch --show-current)
65+
gh pr create --head "$branch" --title "Changelog for v${{ steps.release.outputs.version }}" --body "This PR updates the changelog for version ${{ steps.release.outputs.version }}."
66+
fi
67+
env:
68+
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)