Make new release #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Make new release | |
on: | |
workflow_dispatch: | |
inputs: | |
version_bump: | |
description: 'New version:' | |
required: true | |
default: 'patch' | |
type: choice | |
options: | |
- overwrite previous tag | |
- minor | |
- major | |
- patch | |
jobs: | |
release: | |
runs-on: "ubuntu-latest" | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Bump version | |
shell: python | |
env: | |
VERSION_BUMP: ${{ inputs.version_bump }} | |
run: | | |
from pathlib import Path | |
import re | |
import os | |
v_file=Path("scripts","addons","cam","version.py") | |
version_txt=v_file.read_text() | |
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 | |
if bump=='patch': | |
patch+=1 | |
elif bump=='minor': | |
minor+=1 | |
patch=0 | |
elif bump=='major': | |
major+=1 | |
minor=0 | |
patch=0 | |
v_file.write_text(f"__version__=({major},{minor},{patch})") | |
# update in bl_info structure (which can't be dynamic because blender...) | |
toml_file=Path("scripts","addons","cam","blender_manifest.toml") | |
toml_text=toml_file.read_text() | |
version_regex= r'version\s=\s"[0-9]+\.[0-9]+\.[0-9]+"' | |
toml_text = re.sub(version_regex,f'version = "{major}.{minor}.{patch}"',toml_text) | |
toml_file.write_text(toml_text) | |
env_file = Path(os.getenv('GITHUB_ENV')) | |
env_file.write_text(f"VERSION_TAG={major}.{minor}.{patch}") | |
print(f"New version: {major}.{minor}.{patch}") | |
- name: Make addon zip | |
uses: thedoctor0/[email protected] | |
with: | |
type: 'zip' | |
filename: 'blendercam.zip' | |
directory: './scripts/addons' | |
- name: Write version number | |
if: ${{ inputs.version_bump }} != "overwrite previous tag" | |
run: | | |
git config --global user.name 'Release robot' | |
git config --global user.email '[email protected]' | |
git commit -am "Version number" || true | |
- 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 }} | |
allowUpdates: true | |
body: "To install BlenderCAM, download blendercam.zip and *don't* extract it. In blender, go to preferences, add-ons, and select 'install from file' and select the blendercam.zip file you downloaded" |