File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Update LICENSE year
2+
3+ on :
4+ schedule :
5+ # Runs at 00:10 UTC every Jan 1
6+ - cron : ' 10 0 1 1 *'
7+ workflow_dispatch : {}
8+
9+ permissions :
10+ contents : write
11+
12+ jobs :
13+ update-year :
14+ runs-on : ubuntu-latest
15+ steps :
16+ - name : Check out repo
17+ uses : actions/checkout@v4
18+
19+ - name : Update year in LICENSE.md (MIT header line)
20+ shell : bash
21+ run : |
22+ set -euo pipefail
23+
24+ FILE="LICENSE.md"
25+ YEAR="$(date -u +%Y)"
26+
27+ if [[ ! -f "$FILE" ]]; then
28+ echo "ERROR: $FILE not found."
29+ exit 1
30+ fi
31+
32+ # Replace ONLY the 4-digit year after "Copyright (c)"
33+ # e.g. "Copyright (c) 2026 Jiho Kim" -> "Copyright (c) 2027 Jiho Kim"
34+ perl -0777 -i -pe "s/(Copyright\\s*\\(c\\)\\s*)\\d{4}(\\s+)/\$1$YEAR\$2/g" "$FILE"
35+
36+ if git diff --quiet; then
37+ echo "No changes needed."
38+ exit 0
39+ fi
40+
41+ - name : Commit and push if changed
42+ shell : bash
43+ run : |
44+ set -euo pipefail
45+ git config user.name "github-actions[bot]"
46+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
47+
48+ git add LICENSE.md
49+ git commit -m "Update LICENSE year to $(date -u +%Y)"
50+ git push
You can’t perform that action at this time.
0 commit comments