Skip to content

Commit

Permalink
Merge pull request #254 from pppalain/master
Browse files Browse the repository at this point in the history
January 24 update
  • Loading branch information
pppalain committed Jan 20, 2024
2 parents 82b10d6 + 7c5e846 commit 407e5d8
Show file tree
Hide file tree
Showing 116 changed files with 4,450 additions and 4,438 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Run tests on push / PR
on:
push:
pull_request:
jobs:
build_and_test:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest','windows-latest']
blender_version: ['3.6.7','4.0.2']
include:
- os: 'macos-latest'
blender_version: 'ignored'
runs-on: ${{matrix.os}}
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Install bash 4(macOS)
if: runner.os == 'macOS'
run: brew install bash
- name: Install blender (macOS)
if: runner.os == 'macOS'
run: brew install --cask blender
- name: Cache blender
id: cache-blender
if: runner.os != 'macOS'
uses: actions/cache/restore@v3
with:
path: blender
key: ${{ matrix.os }}-${{ matrix.blender_version}}-blender
- name: Download blender
id: download
if: steps.cache-blender.outputs.cache-hit != 'true' && runner.os != 'macOS'
shell: bash
run: |
declare -A os_suffixes
os_suffixes["ubuntu-latest"]="linux-x64.tar.xz"
os_suffixes["macos-latest"]="macos-x64.dmg"
os_suffixes["windows-latest"]="windows-x64.zip"
export OS_SUFFIX=${os_suffixes["${{matrix.os}}"]}
IFS='.' read -ra BLENDER_SPLIT <<< "${{matrix.blender_version}}"
export BLENDER_MAJOR=${BLENDER_SPLIT[0]}.${BLENDER_SPLIT[1]}
export BLENDER_MINOR=${BLENDER_SPLIT[2]}
export BLENDER_ARCHIVE="blender-${BLENDER_MAJOR}.${BLENDER_MINOR}-${OS_SUFFIX}"
echo Major version: $BLENDER_MAJOR
echo Minor version: $BLENDER_MINOR
echo Archive name: $BLENDER_ARCHIVE
curl -O -L https://download.blender.org/release/Blender${BLENDER_MAJOR}/${BLENDER_ARCHIVE}
echo "BLENDER_ARCHIVE=${BLENDER_ARCHIVE}" >> "$GITHUB_OUTPUT"
- name: Extract blender
if: steps.cache-blender.outputs.cache-hit != 'true' && runner.os != 'macOS'
run: |
import shutil
import os
os.makedirs("blender",exist_ok=True)
shutil.unpack_archive("${{ steps.download.outputs.BLENDER_ARCHIVE }}","blender")
shell: python
- name: Save blender
uses: actions/cache/save@v3
if: steps.cache-blender.outputs.cache-hit != 'true' && runner.os != 'macOS'
with:
path: blender
key: ${{ matrix.os }}-${{ matrix.blender_version}}-blender
- name: Make addon zip
uses: thedoctor0/[email protected]
if: always()
with:
type: 'zip'
filename: 'blendercam.zip'
directory: './scripts/addons'
- name: Run tests
shell: bash
run: |
if [ "${{ runner.os }}" != "macOS" ]; then
export BLENDER_BIN_PATH=${PWD}/blender/$(ls -AU blender | head -1)
export PATH=$PATH:${BLENDER_BIN_PATH}
fi
export ADDON_PATH=${PWD}/scripts/addons/blendercam.zip
cd scripts/addons/cam/tests
python install_addon.py ${ADDON_PATH}
python test_suite.py
- uses: actions/upload-artifact@v4
if: always()
with:
name: blendercam-${{matrix.os}}-${{matrix.blender_version}}
path: ./scripts/addons/cam
rerun-failed-jobs:
runs-on: ubuntu-latest
needs: [ build_and_test ]
if: failure()
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Rerun failed jobs in the current workflow (because mac blender is unstable)
env:
GH_TOKEN: ${{ github.token }}
run: gh run rerun ${{ github.run_id }} --failed

83 changes: 83 additions & 0 deletions .github/workflows/create_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
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...)
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(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"
Loading

0 comments on commit 407e5d8

Please sign in to comment.