-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #619: automate execution by Github action bump-license-year.sh
- Loading branch information
1 parent
8afff68
commit b11afe0
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
PREV_YEAR=$1 | ||
CURR_YEAR=$2 | ||
DIR=$3 | ||
|
||
OLD_VALUE="// Copyright (C) 2001-$PREV_YEAR the original author or authors." | ||
NEW_VALUE="// Copyright (C) 2001-$CURR_YEAR the original author or authors." | ||
|
||
find "$DIR" -type f \( -name *.java -o -name *.header -o -name *.g4 \) \ | ||
-exec sed -i "s|$OLD_VALUE|$NEW_VALUE|g" {} + | ||
|
||
BASEDIR=$(pwd) | ||
echo "Distinct Diff in $DIR is:" | ||
cd "$DIR" | ||
git diff | grep -Eh "^\+" | grep -v "+++ b" | sort | uniq | ||
cd "$BASEDIR" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
############################################################################# | ||
# GitHub Action to bump license year | ||
# | ||
# Workflow starts every new year. | ||
# | ||
############################################################################# | ||
name: "Bump license year" | ||
on: | ||
schedule: | ||
- cron: '0 12 1 1 *' | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
jobs: | ||
bump: | ||
name: Bump license year | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the latest code | ||
uses: actions/checkout@v2 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Set Current Year | ||
id: CURRENT_YEAR | ||
run: | | ||
echo "::set-output name=year::$(date +'%Y')" | ||
- name: Modify Files | ||
run: | | ||
./.ci/bump-license-year.sh $(expr ${{ env.YEAR }} - 1) ${{ env.YEAR }} . | ||
env: | ||
YEAR: ${{ steps.CURRENT_YEAR.outputs.year }} | ||
- name: Push commit | ||
run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git commit -am "minor: Bump year to ${{ env.YEAR }}" | ||
git push | ||