1+ name : Build Split Platform Extension
2+ on :
3+ # push:
4+ pull_request :
5+ jobs :
6+ build_and_test :
7+ strategy :
8+ fail-fast : false
9+ matrix :
10+ os : ['ubuntu-latest'] # ,'windows-latest']
11+ blender_version : ['5.0.0'] # 5.1.0-beta+v51.748b1754d82a
12+ # include:
13+ # - os: 'macos-latest'
14+ # blender_version: '4.2.1'
15+ runs-on : ${{ matrix.os }}
16+ steps :
17+
18+ # Check out the Fabex repo
19+ - name : Checkout repository
20+ uses : actions/checkout@v4.1.1
21+ # - name: Install bash 4(macOS)
22+ # if: runner.os == 'macOS'
23+ # run: brew install bash
24+ # - name: Install blender (macOS)
25+ # if: runner.os == 'macOS'
26+ # run: brew install --cask blender
27+
28+ # Check for a cached version of Blender
29+ # Skips Download and Install if the Blender version is unchanged
30+ - name : Cache blender
31+ id : cache-blender
32+ if : runner.os != 'macOS'
33+ uses : actions/cache/restore@v4
34+ with :
35+ path : blender
36+ key : ${{ matrix.os }}-${{ matrix.blender_version }}-blender
37+
38+ # Download Blender for initial run, or when Blender version
39+ # is updated
40+ - name : Download blender
41+ id : download
42+ if : steps.cache-blender.outputs.cache-hit != 'true' && runner.os != 'macOS'
43+ shell : bash
44+ run : |
45+ declare -A os_suffixes
46+ os_suffixes["ubuntu-latest"]="linux-x64.tar.xz"
47+ os_suffixes["macos-latest"]="macos-x64.dmg"
48+ os_suffixes["windows-latest"]="windows-x64.zip"
49+ export OS_SUFFIX=${os_suffixes["${{ matrix.os }}"]}
50+ IFS='.' read -ra BLENDER_SPLIT <<< "${{ matrix.blender_version }}"
51+ export BLENDER_MAJOR=${BLENDER_SPLIT[0]}.${BLENDER_SPLIT[1]}
52+ export BLENDER_MINOR=${BLENDER_SPLIT[2]}
53+ export BLENDER_ARCHIVE="blender-${BLENDER_MAJOR}.${BLENDER_MINOR}-${OS_SUFFIX}"
54+ echo Major version: $BLENDER_MAJOR
55+ echo Minor version: $BLENDER_MINOR
56+ echo Archive name: $BLENDER_ARCHIVE
57+ curl -O -L https://download.blender.org/release/Blender${BLENDER_MAJOR}/${BLENDER_ARCHIVE}
58+ echo "BLENDER_ARCHIVE=${BLENDER_ARCHIVE}" >> "$GITHUB_OUTPUT"
59+
60+ # Extract the downloaded Blender archive
61+ - name : Extract blender
62+ if : steps.cache-blender.outputs.cache-hit != 'true' && runner.os != 'macOS'
63+ run : |
64+ import shutil
65+ import os
66+ os.makedirs("blender",exist_ok=True)
67+ shutil.unpack_archive("${{ steps.download.outputs.BLENDER_ARCHIVE }}","blender")
68+ shell : python
69+
70+ # Save this Blender version to the cache for re-use
71+ - name : Save blender
72+ uses : actions/cache/save@v4
73+ if : steps.cache-blender.outputs.cache-hit != 'true' && runner.os != 'macOS'
74+ with :
75+ path : blender
76+ key : ${{ matrix.os }}-${{ matrix.blender_version }}-blender
77+
78+ # Build the Extension using Blender
79+ - name : Build Extension
80+ id : build
81+ shell : bash
82+ run : |
83+ export BLENDER_BIN_PATH=${PWD}/blender/$(ls -AU blender | head -1)
84+ export PATH=$PATH:${BLENDER_BIN_PATH}
85+ blender --command extension build --source-dir=./fabex --split-platforms
86+
87+ - name : Get Version Tag
88+ shell : python
89+ run : |
90+ from pathlib import Path
91+ import re
92+ import os
93+
94+ # Path to the file with the version number
95+ v_file=Path("fabex","version.py")
96+ version_txt=v_file.read_text()
97+
98+ # Separate each number in the version into its own variable
99+ major,minor,patch = re.match(r".*\(\s*(\d+),(\s*\d+),(\s*\d+)\)",version_txt).groups()
100+
101+ # Write the version number to an env file for the 'make release' action
102+
103+ version_tag = f"{major}.{minor}.{patch}".replace(' ','')
104+ runner_os = "${{runner.os}}".lower()
105+ runner_arch = "${{runner.arch}}".lower()
106+
107+ env_file = Path(os.getenv('GITHUB_ENV'))
108+ env_file.write_text(
109+ f"""VERSION_TAG={version_tag}
110+ OS={runner_os}
111+ ARCH={runner_arch}
112+ """)
113+
114+ print(f"New version: {major}.{minor}.{patch}")
115+
116+ # Upload the Linux Extension file for download
117+ - name : Upload Linux Build
118+ uses : actions/upload-artifact@v4
119+ if : always()
120+ with :
121+ name : fabex-${{ env.VERSION_TAG }}-${{ env.OS }}_${{env.ARCH}}
122+ path : ./fabex-${{ env.VERSION_TAG }}-${{ env.OS }}_${{env.ARCH}}.zip
123+
124+ # Upload the Windows Extension file for download
125+ - name : Upload Windows Build
126+ uses : actions/upload-artifact@v4
127+ if : always()
128+ with :
129+ name : fabex-${{ env.VERSION_TAG }}-windows_x64
130+ path : ./fabex-${{ env.VERSION_TAG }}-windows_x64.zip
131+
132+ # Upload the Mac x64 Extension file for download
133+ - name : Upload Mac x86 Build
134+ uses : actions/upload-artifact@v4
135+ if : always()
136+ with :
137+ name : fabex-${{ env.VERSION_TAG }}-macos_x64
138+ path : ./fabex-${{ env.VERSION_TAG }}-macos_x64.zip
139+
140+ # Upload the Mac ARM Extension file for download
141+ - name : Upload Mac ARM Build
142+ uses : actions/upload-artifact@v4
143+ if : always()
144+ with :
145+ name : fabex-${{ env.VERSION_TAG }}-macos_arm64
146+ path : ./fabex-${{ env.VERSION_TAG }}-macos_arm64.zip
147+
148+ - name : make release
149+ uses : ncipollo/release-action@v1
150+ with :
151+ artifacts : " fabex-*.zip"
152+ tag : ${{ env.VERSION_TAG }}
153+ allowUpdates : true
154+ bodyFile : ' ./docs/RELEASE.md'
0 commit comments