Skip to content

Commit 844992d

Browse files
authored
Update update-license-year.yml
1 parent 52307ce commit 844992d

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

.github/workflows/update-license-year.yml

+27-3
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,39 @@ jobs:
2020
run: |
2121
CURRENT_YEAR=$(date +%Y)
2222
echo "CURRENT_YEAR=$CURRENT_YEAR" >> $GITHUB_ENV
23+
24+
# 调试输出
25+
echo "Current content of LICENSE file:"
26+
cat LICENSE
27+
echo "Current year: $CURRENT_YEAR"
28+
29+
# 更新年份 - 支持多种格式
2330
if [ -f LICENSE ]; then
24-
sed -i "s/Copyright (c) [0-9]\{4\}/Copyright (c) ${CURRENT_YEAR}/" LICENSE
31+
# 更新 "Copyright (c) YYYY" 格式
32+
sed -i -E "s/Copyright \(c\) [0-9]{4}/Copyright (c) ${CURRENT_YEAR}/" LICENSE
33+
34+
# 更新 "Copyright (c) YYYY-YYYY" 格式
35+
sed -i -E "s/Copyright \(c\) [0-9]{4}-[0-9]{4}/Copyright (c) ${CURRENT_YEAR}/" LICENSE
36+
37+
# 更新 "Copyright YYYY" 格式
38+
sed -i -E "s/Copyright [0-9]{4}/Copyright ${CURRENT_YEAR}/" LICENSE
39+
40+
echo "Updated content of LICENSE file:"
41+
cat LICENSE
42+
else
43+
echo "LICENSE file not found!"
2544
fi
2645
2746
- name: Check for changes
2847
id: changes
2948
run: |
3049
if git diff --quiet; then
50+
echo "No changes detected"
3151
echo "changed=false" >> $GITHUB_OUTPUT
3252
else
53+
echo "Changes detected"
3354
echo "changed=true" >> $GITHUB_OUTPUT
55+
git diff
3456
fi
3557
3658
- name: Create Pull Request
@@ -39,10 +61,12 @@ jobs:
3961
with:
4062
token: ${{ secrets.GITHUB_TOKEN }}
4163
commit-message: "chore: update license year to ${{ env.CURRENT_YEAR }}"
42-
title: "chore: update license year"
64+
title: "chore: update license year to ${{ env.CURRENT_YEAR }}"
4365
body: |
4466
Automated changes:
45-
- Updated copyright year in LICENSE file to current year
67+
- Updated copyright year in LICENSE file to current year (${{ env.CURRENT_YEAR }})
68+
69+
Please review the changes and merge if appropriate.
4670
branch: update-license-year
4771
base: main
4872
delete-branch: true

0 commit comments

Comments
 (0)