From 698243cdc081fbdbce0a63ab7097b2c42dc9e723 Mon Sep 17 00:00:00 2001 From: huchenlei Date: Wed, 8 Jan 2025 17:20:23 -0500 Subject: [PATCH] Add github action to sync version.py --- .github/workflows/update-version.yml | 51 ++++++++++++++++++++++++++++ version.py | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/update-version.yml diff --git a/.github/workflows/update-version.yml b/.github/workflows/update-version.yml new file mode 100644 index 000000000..182305aec --- /dev/null +++ b/.github/workflows/update-version.yml @@ -0,0 +1,51 @@ +name: Update Version File + +on: + push: + paths: + - "pyproject.toml" + branches: + - master + +jobs: + update-version: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + + - name: Update version.py + run: | + # Read version from pyproject.toml and update version.py + python -c ' + import tomllib + + # Read version from pyproject.toml + with open("pyproject.toml", "rb") as f: + config = tomllib.load(f) + version = config["project"]["version"] + + # Write version to version.py + with open("version.py", "w") as f: + f.write("# This file is automatically generated by the build process when version is\n") + f.write("# updated in pyproject.toml.\n") + f.write(f"__version__ = \"{version}\"\n") + ' + + - name: Commit changes + run: | + git config --local user.name "github-actions" + git config --local user.email "github-actions@github.com" + git add version.py + git diff --quiet && git diff --staged --quiet || git commit -m "chore: Update version.py to match pyproject.toml" + git push diff --git a/version.py b/version.py index 7cccc7535..4bb44b4a9 100644 --- a/version.py +++ b/version.py @@ -1,3 +1,3 @@ # This file is automatically generated by the build process when version is # updated in pyproject.toml. -__version__ = "0.3.10" +__version__ = "0.3.9"