From 93542d6611e1efe67a5b7a584c8e2311d239559d Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Wed, 10 Jan 2024 11:57:57 +0200 Subject: [PATCH 1/2] feat(ci): automated copyright replace workflow Signed-off-by: Lachezar Lechev --- .github/workflows/copyright.yml | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/copyright.yml diff --git a/.github/workflows/copyright.yml b/.github/workflows/copyright.yml new file mode 100644 index 0000000..125bd04 --- /dev/null +++ b/.github/workflows/copyright.yml @@ -0,0 +1,39 @@ +# Copyright (C) 2017-2024 Smart code 203358507 +name: Replace copyright + +on: + # keep the workflow with manual deployment + workflow_dispatch: + # and update every year on 1st of January + # https://crontab.guru/#0_1_1_1_1 + # “At 01:00 on day-of-month 1 and on Monday in January.” + # 0 1 1 1 1 + schedule: + - cron: "0 1 1 1 1" + +jobs: + replace-copyright: + runs-on: ubuntu-latest + if: always() + needs: check-copyright + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Rust setup + uses: dtolnay/rust-toolchain@stable + - name: Install dependencies + run: cargo install sd + - name: Replace copyright text + # with hardcoded values + # run: `find . \( -path ./target -prune -o -path ./.git -prune -o -path ./README.md \) -o -type f -exec sd "Copyright (C) 2017-2023" "Copyright (C) 2017-2024" {} \;` + # TODO: Fix env. variables not applied to the `sd` string + # run: THIS_YEAR=$(date +%Y) && LAST_YEAR=$(date +%Y -d "-1 year") && find . \( -path ./target -prune -o -path ./.git -prune \) -o -type f -exec sd "2017-$LAST_YEAR" "2017-$THIS_YEAR" {} \; + run: echo TODO + + check-copyright: + runs-on: ubuntu-latest + steps: + - name: Rust setup + uses: dtolnay/rust-toolchain@stable + - name: Install dependencies + run: cargo test copyright From 96719174d97a8776c101fa36e98a5176d4eb01ed Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Wed, 10 Jan 2024 12:04:40 +0200 Subject: [PATCH 2/2] feat: add after replacing copyright check Signed-off-by: Lachezar Lechev --- .github/workflows/copyright.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/copyright.yml b/.github/workflows/copyright.yml index 125bd04..8aaef49 100644 --- a/.github/workflows/copyright.yml +++ b/.github/workflows/copyright.yml @@ -15,7 +15,7 @@ jobs: replace-copyright: runs-on: ubuntu-latest if: always() - needs: check-copyright + needs: check-copyright-before steps: - name: Checkout repository uses: actions/checkout@v3 @@ -30,10 +30,20 @@ jobs: # run: THIS_YEAR=$(date +%Y) && LAST_YEAR=$(date +%Y -d "-1 year") && find . \( -path ./target -prune -o -path ./.git -prune \) -o -type f -exec sd "2017-$LAST_YEAR" "2017-$THIS_YEAR" {} \; run: echo TODO - check-copyright: + check-copyright-before: runs-on: ubuntu-latest steps: - name: Rust setup uses: dtolnay/rust-toolchain@stable - name: Install dependencies run: cargo test copyright + + check-copyright-after: + runs-on: ubuntu-latest + if: always() + needs: replace-copyright + steps: + - name: Rust setup + uses: dtolnay/rust-toolchain@stable + - name: Install dependencies + run: cargo test copyright \ No newline at end of file