From 2f28901a0ae1b01aa5ac4ce9d5d88b13129e9070 Mon Sep 17 00:00:00 2001 From: Ircama Date: Sat, 16 Nov 2024 09:33:01 +0100 Subject: [PATCH] Automatically update version when pushing a tag --- .github/workflows/build.yml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 860b825..c872484 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,27 @@ jobs: steps: - name: Git Checkout uses: actions/checkout@v4 + with: + ref: main + fetch-depth: 0 # Fetch all history for accurate commits and tags + + - name: Update VERSION in python file ui.py + $VERSION = "${{ github.ref_name }}" + run: | + $VERSION = "${{ github.ref_name }}" + if ($VERSION.StartsWith('v')) { + $VERSION = $VERSION.Substring(1) + } + (Get-Content ui.py) -replace '^VERSION = ".*"$', "VERSION = `"$VERSION`"" | Set-Content ui.py + + - name: Commit and push version update + run: | + git config --local user.name "github-actions[bot]" + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git add ui.py + git commit -m "Update VERSION to ${{ github.ref_name }}" + git remote set-url origin https://Ircama:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} + git push origin main - name: Install Python uses: actions/setup-python@v5 @@ -27,9 +48,7 @@ jobs: pip install -r requirements.txt - name: Run PyInstaller to create epson_print_conf.exe - run: > - python -m PyInstaller epson_print_conf.spec -- --default - --version ${{ github.ref_name }} + run: python -m PyInstaller epson_print_conf.spec -- --default - name: Zip the epson_print_conf.exe asset to epson_print_conf.zip run: |