From 78aebb9ce5c930ba470a1af504758589b1e7e005 Mon Sep 17 00:00:00 2001 From: Lawan Chaamindu Jayalath Samarasekara Date: Tue, 9 Apr 2024 20:25:24 +0530 Subject: [PATCH] Create create_version.yml --- .github/workflows/create_version.yml | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/create_version.yml diff --git a/.github/workflows/create_version.yml b/.github/workflows/create_version.yml new file mode 100644 index 0000000000..6778ef1f94 --- /dev/null +++ b/.github/workflows/create_version.yml @@ -0,0 +1,45 @@ +name: Update Version and README + +on: + push: + branches: + - main + +jobs: + update_version_and_readme: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Determine current date + id: current_date + run: echo "::set-output name=date::$(date +'%Y%m%d')" + + - name: Read merge counter from file + id: read_counter + run: echo "::set-output name=counter::$(cat counter.txt || echo '0')" + + - name: Increment merge counter + id: increment_counter + run: echo "::set-output name=counter::${{ steps.read_counter.outputs.counter + 1 }}" + + - name: Update version file with date and merge counter + run: echo "3.0.0.${{ steps.current_date.outputs.date }}.${{ steps.increment_counter.outputs.counter }}" > VERSION.txt + + - name: Update README.md + run: sed -i "s/Current Version: .*/Current Version: 3.0.0.${{ steps.current_date.outputs.date }}.${{ steps.increment_counter.outputs.counter }}/" README.md + + - name: Commit version and README update + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add VERSION.txt README.md + git commit -m "Update version to 3.0.0.${{ steps.current_date.outputs.date }}.${{ steps.increment_counter.outputs.counter }}" + git push