From a15d93d3160768047edb5d0f3aeb06829c2fa13a Mon Sep 17 00:00:00 2001 From: John Rayes Date: Tue, 7 Jan 2025 15:40:09 -0700 Subject: [PATCH 1/6] GitHub Action to Update Year in Files --- .github/workflows/update-year.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/update-year.yml diff --git a/.github/workflows/update-year.yml b/.github/workflows/update-year.yml new file mode 100644 index 0000000000..ce5cee80ff --- /dev/null +++ b/.github/workflows/update-year.yml @@ -0,0 +1,28 @@ +name: Update Year + +on: + workflow_dispatch: + +jobs: + update-year: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set current year environment variable + run: echo "CURRENT_YEAR=$(date +'%Y')" >> $GITHUB_ENV + + - name: Update year in index.php + run: | + sed -i "s/define('SMF_SOFTWARE_YEAR', '[0-9]\{4\}');/define('SMF_SOFTWARE_YEAR', '${{ env.CURRENT_YEAR }}');/" index.php + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Update year to ${{ env.CURRENT_YEAR }} + branch: update-year-${{ env.CURRENT_YEAR }} + title: Update year to ${{ env.CURRENT_YEAR }} + body: This commit updates `SMF_SOFTWARE_YEAR` to ${{ env.CURRENT_YEAR }} in `index.php`. \ No newline at end of file From b3c8417517b54de34b317e6f14b0a022c406689c Mon Sep 17 00:00:00 2001 From: John Rayes Date: Tue, 7 Jan 2025 15:44:18 -0700 Subject: [PATCH 2/6] Prepend version to branch --- .github/workflows/update-year.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-year.yml b/.github/workflows/update-year.yml index ce5cee80ff..3ea267f469 100644 --- a/.github/workflows/update-year.yml +++ b/.github/workflows/update-year.yml @@ -23,6 +23,6 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: Update year to ${{ env.CURRENT_YEAR }} - branch: update-year-${{ env.CURRENT_YEAR }} + branch: 3.0/update-year-${{ env.CURRENT_YEAR }} title: Update year to ${{ env.CURRENT_YEAR }} - body: This commit updates `SMF_SOFTWARE_YEAR` to ${{ env.CURRENT_YEAR }} in `index.php`. \ No newline at end of file + body: This commit updates `SMF_SOFTWARE_YEAR` to ${{ env.CURRENT_YEAR }} in `index.php`. From 3e970ec14b844e6b321ec6ab7d51f6e644878590 Mon Sep 17 00:00:00 2001 From: John Rayes Date: Tue, 7 Jan 2025 15:48:40 -0700 Subject: [PATCH 3/6] Prepend version to title --- .github/workflows/update-year.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-year.yml b/.github/workflows/update-year.yml index 3ea267f469..16f7191f10 100644 --- a/.github/workflows/update-year.yml +++ b/.github/workflows/update-year.yml @@ -24,5 +24,5 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} commit-message: Update year to ${{ env.CURRENT_YEAR }} branch: 3.0/update-year-${{ env.CURRENT_YEAR }} - title: Update year to ${{ env.CURRENT_YEAR }} + title: "[3.0] Update year to ${{ env.CURRENT_YEAR }}" body: This commit updates `SMF_SOFTWARE_YEAR` to ${{ env.CURRENT_YEAR }} in `index.php`. From ffe85c45da9d37d64190d504b020ba2b48c65388 Mon Sep 17 00:00:00 2001 From: John Rayes Date: Fri, 17 Jan 2025 23:44:45 -0700 Subject: [PATCH 4/6] update more files --- .github/workflows/update-year.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-year.yml b/.github/workflows/update-year.yml index 16f7191f10..4fec615203 100644 --- a/.github/workflows/update-year.yml +++ b/.github/workflows/update-year.yml @@ -14,9 +14,12 @@ jobs: - name: Set current year environment variable run: echo "CURRENT_YEAR=$(date +'%Y')" >> $GITHUB_ENV - - name: Update year in index.php + - name: Update year in PHP files run: | - sed -i "s/define('SMF_SOFTWARE_YEAR', '[0-9]\{4\}');/define('SMF_SOFTWARE_YEAR', '${{ env.CURRENT_YEAR }}');/" index.php + for file in SSI.php proxy.php cron.php index.php other/*.php; do + sed -i "s/@copyright [0-9]\{4\}/@copyright ${{ env.CURRENT_YEAR }}/" $file + sed -i "s/define('SMF_SOFTWARE_YEAR', '[0-9]\{4\}');/define('SMF_SOFTWARE_YEAR', '${{ env.CURRENT_YEAR }}');/" $file + done - name: Create Pull Request uses: peter-evans/create-pull-request@v7 @@ -25,4 +28,4 @@ jobs: commit-message: Update year to ${{ env.CURRENT_YEAR }} branch: 3.0/update-year-${{ env.CURRENT_YEAR }} title: "[3.0] Update year to ${{ env.CURRENT_YEAR }}" - body: This commit updates `SMF_SOFTWARE_YEAR` to ${{ env.CURRENT_YEAR }} in `index.php`. + body: This commit updates `SMF_SOFTWARE_YEAR` to ${{ env.CURRENT_YEAR }}. This action was performed by a bot. From 9490fa136bcc5e258b3c16245e892e093f557fe9 Mon Sep 17 00:00:00 2001 From: John Rayes Date: Fri, 17 Jan 2025 23:50:21 -0700 Subject: [PATCH 5/6] Update year in Sources/ --- .github/workflows/update-year.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-year.yml b/.github/workflows/update-year.yml index 4fec615203..9c32b107b2 100644 --- a/.github/workflows/update-year.yml +++ b/.github/workflows/update-year.yml @@ -14,7 +14,25 @@ jobs: - name: Set current year environment variable run: echo "CURRENT_YEAR=$(date +'%Y')" >> $GITHUB_ENV - - name: Update year in PHP files + - name: Check if version tag matches any pre-release + run: | + str=$(grep -oP "define\('SMF_VERSION', '[^']+" index.php) + re='[0-9]+\.[0-9]+ ?[A-Za-z]+'; + if [[ $str =~ $re ]]; then + echo "PRE_RELEASE=true" >> $GITHUB_ENV + else + echo "PRE_RELEASE=false" >> $GITHUB_ENV + fi + + - name: Update year in Sources/ + if: env.PRE_RELEASE == 'true' + run: | + shopt -s globstar + for file in Sources/**/*.php Themes/default/*.php; do + sed -i "s/@copyright [0-9]\{4\}/@copyright ${{ env.CURRENT_YEAR }}/" $file + done + + - name: Update year in PHP files run: | for file in SSI.php proxy.php cron.php index.php other/*.php; do sed -i "s/@copyright [0-9]\{4\}/@copyright ${{ env.CURRENT_YEAR }}/" $file From 618af5f66e68cedf0f5b8ad861588247dccef17a Mon Sep 17 00:00:00 2001 From: John Rayes Date: Fri, 17 Jan 2025 23:59:51 -0700 Subject: [PATCH 6/6] get branch name from SMF_VERSION in ./index.php --- .github/workflows/update-year.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-year.yml b/.github/workflows/update-year.yml index 9c32b107b2..c2fe1983e7 100644 --- a/.github/workflows/update-year.yml +++ b/.github/workflows/update-year.yml @@ -18,11 +18,13 @@ jobs: run: | str=$(grep -oP "define\('SMF_VERSION', '[^']+" index.php) re='[0-9]+\.[0-9]+ ?[A-Za-z]+'; + tag=`echo $str | grep -oP "[0-9]+\.[0-9]+"` if [[ $str =~ $re ]]; then echo "PRE_RELEASE=true" >> $GITHUB_ENV else echo "PRE_RELEASE=false" >> $GITHUB_ENV fi + echo "TAG=$tag" >> $GITHUB_ENV - name: Update year in Sources/ if: env.PRE_RELEASE == 'true' @@ -44,6 +46,6 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: Update year to ${{ env.CURRENT_YEAR }} - branch: 3.0/update-year-${{ env.CURRENT_YEAR }} - title: "[3.0] Update year to ${{ env.CURRENT_YEAR }}" - body: This commit updates `SMF_SOFTWARE_YEAR` to ${{ env.CURRENT_YEAR }}. This action was performed by a bot. + branch: ${{ env.TAG }}/update-year-${{ env.CURRENT_YEAR }} + title: "[${{ env.TAG }}] Update year to ${{ env.CURRENT_YEAR }}" + body: This commit updates `SMF_SOFTWARE_YEAR` to ${{ env.CURRENT_YEAR }}. This action was performed by a bot. \ No newline at end of file