Skip to content

Commit 520e708

Browse files
Issue #619: automate execution by Github action bump-license-year.sh
1 parent 8afff68 commit 520e708

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

.ci/bump-license-year.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
PREV_YEAR=$1
6+
CURR_YEAR=$2
7+
DIR=$3
8+
9+
OLD_VALUE="// Copyright (C) 2001-$PREV_YEAR the original author or authors."
10+
NEW_VALUE="// Copyright (C) 2001-$CURR_YEAR the original author or authors."
11+
12+
find "$DIR" -type f \( -name *.java -o -name *.header -o -name *.g4 \) \
13+
-exec sed -i "s|$OLD_VALUE|$NEW_VALUE|g" {} +
14+
15+
BASEDIR=$(pwd)
16+
echo "Distinct Diff in $DIR is:"
17+
cd "$DIR"
18+
git diff | grep -Eh "^\+" | grep -v "+++ b" | sort | uniq
19+
cd "$BASEDIR"
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#############################################################################
2+
# GitHub Action to bump license year
3+
#
4+
# Workflow starts every new year.
5+
#
6+
#############################################################################
7+
name: "Bump license year"
8+
on:
9+
schedule:
10+
- cron: '0 12 1 1 *'
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
jobs:
15+
bump:
16+
name: Bump license year
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout the latest code
20+
uses: actions/checkout@v2
21+
with:
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
- name: Set Current Year
24+
id: CURRENT_YEAR
25+
run: |
26+
echo "::set-output name=year::$(date +'%Y')"
27+
- name: Modify Files
28+
run: |
29+
./.ci/bump-license-year.sh $(expr ${{ env.YEAR }} - 1) ${{ env.YEAR }} .
30+
env:
31+
YEAR: ${{ steps.CURRENT_YEAR.outputs.year }}
32+
- name: Push commit
33+
run: |
34+
git config --global user.name 'github-actions[bot]'
35+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
36+
git commit -am "minor: Bump year to ${{ env.YEAR }}"
37+
git push

0 commit comments

Comments
 (0)