From 905ea8171c19472aba73dc14206c4d89743c6037 Mon Sep 17 00:00:00 2001 From: Vignes Date: Tue, 26 Nov 2024 23:01:37 +0800 Subject: [PATCH] new bump version number script --- .github/workflows/auto-bump-version.yml | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/auto-bump-version.yml diff --git a/.github/workflows/auto-bump-version.yml b/.github/workflows/auto-bump-version.yml new file mode 100644 index 0000000..a416d63 --- /dev/null +++ b/.github/workflows/auto-bump-version.yml @@ -0,0 +1,48 @@ +name: Auto Bump Version + +on: + push: + branches: + - main + +jobs: + bump-version: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + + - name: Get current version + run: | + current_version=$(grep 'version =' pyproject.toml | cut -d'"' -f2) + echo "CURRENT_VERSION=$current_version" >> $GITHUB_ENV + + - name: Bump version + run: | + IFS=. read -r major minor patch <<< "${CURRENT_VERSION}" + ((patch++)) + new_version="${major}.${minor}.${patch}" + echo "NEW_VERSION=$new_version" >> $GITHUB_ENV + + - name: Update version in meta.yaml + run: | + sed -i "s/version: .*/version: $NEW_VERSION/" vedastro/meta.yaml + + - name: Update version in setup.py + run: | + sed -i "s/version='.*'/version='$NEW_VERSION'/" setup.py + + - name: Update version in pyproject.toml + run: | + sed -i "s/version = \".*\"/version = \"$NEW_VERSION\"/" pyproject.toml + + - name: Commit changes + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "Auto bump version to $NEW_VERSION" + git push origin main