diff --git a/.ci/bump-license-year.sh b/.ci/bump-license-year.sh new file mode 100755 index 0000000..7fd51ec --- /dev/null +++ b/.ci/bump-license-year.sh @@ -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" diff --git a/.github/workflows/bump-license-year.yml b/.github/workflows/bump-license-year.yml new file mode 100644 index 0000000..da677a3 --- /dev/null +++ b/.github/workflows/bump-license-year.yml @@ -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