diff --git a/.github/workflows/create_release.yaml b/.github/workflows/create_release.yaml index 5090a8e3..4afda82d 100644 --- a/.github/workflows/create_release.yaml +++ b/.github/workflows/create_release.yaml @@ -1,4 +1,4 @@ -name: Run tests on push / PR +name: Make new release on: workflow_dispatch: inputs: @@ -15,6 +15,8 @@ on: jobs: release: runs-on: "ubuntu-latest" + permissions: + contents: write steps: - name: Checkout uses: actions/checkout@v4.1.1 @@ -28,34 +30,54 @@ jobs: import os v_file=Path("scripts","addons","cam","version.py") version_txt=v_file.read_text() - major,minor,patch = re.match(version_txt,".*\((\d+),(\d+),(\d+)\)".groups() + major,minor,patch = re.match(r".*\(\s*(\d+),(\s*\d+),(\s*\d+)\)",version_txt).groups() + major=int(major) + minor=int(minor) + patch=int(patch) bump = os.getenv("VERSION_BUMP") if bump == "minor": minor+=1 - bump = "${{ inputs.logLevel }}" - if version=='patch': + if bump=='patch': patch+=1 - elif version=='minor': + elif bump=='minor': minor+=1 patch=0 - elif version=='major': + elif bump=='major': major+=1 minor=0 patch=0 - v_file.write_text(f"__version__={(major,minor,patch)}") + v_file.write_text(f"__version__=({major},{minor},{patch})") + # update in bl_info structure (which can't be dynamic because blender...) + init_file=Path("scripts","addons","cam","__init__.py") + init_text=init_file.read_text() + version_regex= r"\"version\"\s*:\s*\(([\d\s,]+)\)" + init_text = re.sub(version_regex,f'"version":({major},{minor},{patch})',init_text) + init_file.write_text(init_text) + env_file = Path(os.getenv('GITHUB_ENV')) - env_file.write_text("VERSION_TAG")=f"v{major}.{minor}.{patch}" - print(f"New version: v{major}.{minor}.{patch}") + env_file.write_text(f"VERSION_TAG={major}.{minor}.{patch}") + print(f"New version: {major}.{minor}.{patch}") - name: Make addon zip uses: thedoctor0/zip-release@0.7.5 with: type: 'zip' filename: 'blendercam.zip' directory: './scripts/addons' - - name: tag release + - name: Write version number + if: ${{ inputs.version_bump }} != "overwrite previous tag" + run: | + git config --global user.name 'Release robot' + git config --global user.email 'release-robot@users.noreply.github.com' + git commit -am "Version number" + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} + - name: make release uses: ncipollo/release-action@v1 with: artifacts: "scripts/addons/blendercam.zip" tag: ${{ env.VERSION_TAG }} - commit: ${ GITHUB_SHA } + allowUpdates: true diff --git a/scripts/addons/cam/__init__.py b/scripts/addons/cam/__init__.py index 3c70237c..dc216cd7 100644 --- a/scripts/addons/cam/__init__.py +++ b/scripts/addons/cam/__init__.py @@ -57,7 +57,7 @@ from cam.version import __version__ bl_info = { "name": "CAM - gcode generation tools", "author": "Vilem Novak", - "version": (0, 6, 9), + "version":(0,9,7), "blender": (3, 6, 0), "location": "Properties > render", "description": "Generate machining paths for CNC", diff --git a/scripts/addons/cam/version.py b/scripts/addons/cam/version.py index cd1715d3..e4fbe155 100644 --- a/scripts/addons/cam/version.py +++ b/scripts/addons/cam/version.py @@ -1 +1 @@ -__version__=(0,9,3) \ No newline at end of file +__version__=(0,9,7) \ No newline at end of file