-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from num0005/build_script
Create and release a zip file ready for extraction using Github Actions.
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: release | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- '*.md' | ||
jobs: | ||
package: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.x # Version range or exact version of a Python version to use, using SemVer's version range syntax | ||
- name: Do package | ||
run: python build/create_zip.py | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: toolkit | ||
path: output/ | ||
- name: Release to Github | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
prerelease: false | ||
token: '${{ secrets.GITHUB_TOKEN }}' | ||
artifacts: output/* | ||
tag: '${{ github.run_number }}' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
**/__pycache__/ | ||
*.patch | ||
output/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
""" | ||
Helper script to create a zip file that can just be extracted to the blender addon folder | ||
SPDX-License-Identifier: MIT | ||
""" | ||
|
||
from zipfile import ZipFile, ZIP_DEFLATED | ||
import io | ||
import os | ||
import subprocess | ||
from pathlib import Path | ||
|
||
# grab the version from git | ||
git_version = subprocess.check_output(["git", "describe", "--always"]).strip().decode() | ||
print(f"version: {git_version}") | ||
|
||
# create the output directory | ||
Path("output").mkdir(exist_ok=True) | ||
|
||
# create zip name from git hash/version | ||
zip_name = "halo-asset-blender-toolset-v@" + git_version + ".zip" | ||
|
||
print(f"zip name: {zip_name}") | ||
|
||
def write_file(zip: ZipFile, path_fs, path_zip = None): | ||
if path_zip is None: | ||
path_zip = path_fs | ||
zip.write(path_fs, os.path.join("io_scene_halo", path_zip)) | ||
|
||
# Add files to zip | ||
zip: ZipFile = ZipFile(os.path.join("output", zip_name), mode='w', compression=ZIP_DEFLATED, compresslevel=9) | ||
write_file(zip, "LICENSE") | ||
write_file(zip, "README.md") | ||
for dir, subdirs, files in os.walk("io_scene_halo"): | ||
for file in files: | ||
fs_path = os.path.join(dir, file) | ||
zip.write(fs_path) | ||
|
||
zip.printdir() | ||
zip.close() | ||
print("done!") |