From 334c8d2af6891f41b18dd0094bda04e8a9c15311 Mon Sep 17 00:00:00 2001 From: carlhandy Date: Thu, 18 Jul 2024 00:55:20 -0400 Subject: [PATCH] automate versioning --- .github/scripts/update-version.sh | 19 +++++++++++++++++++ .github/workflows/update-version.yml | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 .github/scripts/update-version.sh create mode 100644 .github/workflows/update-version.yml diff --git a/.github/scripts/update-version.sh b/.github/scripts/update-version.sh new file mode 100644 index 00000000..0b0227cd --- /dev/null +++ b/.github/scripts/update-version.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Get the new version number from the tag +NEW_VERSION=$(echo $GITHUB_REF | cut -d / -f 3) + +# Remove the 'v' prefix if present +NEW_VERSION=${NEW_VERSION#v} + +# Update the version in main.php +sed -i "s/Version: [0-9.]\+/Version: $NEW_VERSION/" main.php + +# Commit the change +git config --local user.email "action@github.com" +git config --local user.name "GitHub Action" +git add main.php +git commit -m "Bump version to $NEW_VERSION" + +# Push the change +git push \ No newline at end of file diff --git a/.github/workflows/update-version.yml b/.github/workflows/update-version.yml new file mode 100644 index 00000000..8c0b6be1 --- /dev/null +++ b/.github/workflows/update-version.yml @@ -0,0 +1,18 @@ +name: Update Version + +on: + push: + tags: + - 'v*' + +jobs: + update-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Update version in main.php + run: | + chmod +x .github/scripts/update-version.sh + .github/scripts/update-version.sh \ No newline at end of file