Skip to content

Commit

Permalink
Issue #619: automate execution by Github action bump-license-year.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahulkhinchi03 committed Jul 15, 2022
1 parent 8afff68 commit 520e708
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .ci/bump-license-year.sh
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"
37 changes: 37 additions & 0 deletions .github/workflows/bump-license-year.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#############################################################################
# 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

0 comments on commit 520e708

Please sign in to comment.