generated from stilobique/BlenderTemplate
Initial commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import sys
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
from pylint import lint
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
folder: str = ''
|
||||
for v in sys.argv:
|
||||
if '--module=' in v:
|
||||
folder = v.replace('--module=', '')
|
||||
|
||||
if folder is False:
|
||||
print(f'Module folder not set.')
|
||||
sys.exit(1)
|
||||
|
||||
run = lint.Run([f'--rcfile={pathlib.Path(os.getcwd(), "linter", ".pylintrc")}', folder],
|
||||
do_exit=False)
|
||||
|
||||
if run.linter.stats.fatal or run.linter.stats.error:
|
||||
print('Pylint failed.')
|
||||
sys.exit(1)
|
||||
|
||||
sys.exit(0)
|
||||
@@ -0,0 +1,15 @@
|
||||
import glob
|
||||
import os
|
||||
|
||||
|
||||
def get_folder_name():
|
||||
addon = glob.glob(os.getcwd() + "/*/__init__.py", recursive=True)
|
||||
|
||||
return os.path.basename(os.path.dirname(addon[0]))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
name = get_folder_name()
|
||||
|
||||
# Keep the print value, it's request to output a string value available
|
||||
print(name)
|
||||
@@ -0,0 +1,74 @@
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class SetupVersion:
|
||||
def __init__(self, version: str, folder: str):
|
||||
self.addon_file = Path(os.getcwd(), folder, '__init__.py')
|
||||
self.tag = self.conform_tag_to_blender(version)
|
||||
self.update_addon_init()
|
||||
|
||||
def update_addon_init(self):
|
||||
"""Simple function to update the bl_info to set the Git tag release"""
|
||||
regex, update = r'[0-9]{1,2}\, [0-9]{1,2}\, [0-9]{1,2}', ''
|
||||
|
||||
try:
|
||||
with open(self.addon_file, "r") as f:
|
||||
i = 0
|
||||
lines = f.readlines()
|
||||
for line in lines:
|
||||
if ' \'version\':' in line:
|
||||
print('Actual set : ', line)
|
||||
line = re.sub(regex, self.tag, line)
|
||||
lines[i] = line
|
||||
update = lines
|
||||
print('Update version : ', line)
|
||||
break
|
||||
i += 1
|
||||
|
||||
with open(self.addon_file, 'w') as f:
|
||||
f.writelines(update)
|
||||
|
||||
except FileNotFoundError as exception:
|
||||
print(f'Can\'t find a file :\n\t{exception}')
|
||||
|
||||
@staticmethod
|
||||
def conform_tag_to_blender(version):
|
||||
"""This function convert all '.' with a coma and remove the alphabetic entry, to be ready with blender 'bl
|
||||
info' value """
|
||||
version = re.sub(r'\.', ', ', version)
|
||||
version = version.replace('v', '')
|
||||
|
||||
return version
|
||||
|
||||
|
||||
class SetupError(Exception):
|
||||
"""No tag or folder name valid"""
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
tag, name = '', ''
|
||||
|
||||
for value in sys.argv:
|
||||
if '--tag' in value:
|
||||
tag = value.replace('--tag=', '')
|
||||
print(f'[UpdateVersion] Set the tag {tag}')
|
||||
|
||||
if 'name' in value:
|
||||
name = value.replace('--name=', '')
|
||||
print(f'[UpdateVersion] Set the folder {name}')
|
||||
|
||||
try:
|
||||
if not tag or not name:
|
||||
raise SetupError
|
||||
else:
|
||||
print(f'[UpdateVersion] Set the tag {tag}, for "{name}"')
|
||||
bump = SetupVersion(tag, name)
|
||||
|
||||
except SetupError:
|
||||
print(SetupError.__doc__)
|
||||
sys.exit(1)
|
||||
@@ -0,0 +1,54 @@
|
||||
name: Create base release
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
outputs:
|
||||
version_type:
|
||||
description: "Give the bump type for this release"
|
||||
value: ${{ jobs.init-release-data.outputs.version_type }}
|
||||
version_number:
|
||||
description: "String about the tag version, integer only"
|
||||
value: ${{ jobs.init-release-data.outputs.version_number }}
|
||||
version_draft:
|
||||
description: "Boolean if the release are draft or not"
|
||||
value: ${{ jobs.init-release-data.outputs.version_draft }}
|
||||
version_name:
|
||||
description: "Number version with a prefix v."
|
||||
value: v${{ jobs.init-release-data.outputs.version_name }}
|
||||
|
||||
jobs:
|
||||
init-release-data:
|
||||
name: Initialize all data about the package
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
version_type: ${{ steps.bump_setup.outputs.type }}
|
||||
version_number: ${{ steps.semantic_setup.outputs.version }}
|
||||
version_draft: ${{ steps.semantic_setup.outputs.draft }}
|
||||
version_name: ${{ steps.semantic_setup.outputs.version }}
|
||||
steps:
|
||||
- name: Get the Semantic tag Version
|
||||
id: get_semantic_setup
|
||||
uses: oprypin/find-latest-tag@v1.1.0
|
||||
with:
|
||||
repository: ${{ github.repository }}
|
||||
releases-only: true
|
||||
prefix: 'v'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: From all use case, get the Tag version
|
||||
id: semantic_setup
|
||||
run: |
|
||||
tag=${{ steps.get_semantic_setup.outputs.tag }}
|
||||
if [ "${{ github.event.action }}" == "closed" ]; then
|
||||
echo "Close the pull request, get the previous tag"
|
||||
echo "::set-output name=version::${tag:1}"
|
||||
echo "::set-output name=draft::false"
|
||||
elif [ "${{ github.event.action }}" == "opened" ]; then
|
||||
echo "Create a new tag from a new pull request"
|
||||
echo "::set-output name=version::${{ steps.new_semantic_setup.outputs.version }}"
|
||||
echo "::set-output name=draft::true"
|
||||
else
|
||||
echo "Update the pull request, keep the tag value"
|
||||
echo "::set-output name=version::${tag:1}"
|
||||
echo "::set-output name=draft::true"
|
||||
fi
|
||||
@@ -0,0 +1,29 @@
|
||||
name: Pylinter
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
push:
|
||||
branches-ignore:
|
||||
- main
|
||||
- develop
|
||||
|
||||
|
||||
jobs:
|
||||
unit-test:
|
||||
name: Python Linter
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: "3.10"
|
||||
- name: Install the linter app and set package name
|
||||
id: config
|
||||
run: |
|
||||
echo "::set-output name=folder::$(python '.github/package.py')"
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install -r linter/requirements_linter.txt
|
||||
- name: Execute Pylint
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
python '${{ github.workspace }}/.github/lint.py' --module=${{ steps.config.outputs.folder }}
|
||||
@@ -0,0 +1,71 @@
|
||||
name: Package Blender Plugin
|
||||
|
||||
# How to start the Github Action
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
num_version:
|
||||
description: 'Get the desired number version'
|
||||
type: string
|
||||
required: true
|
||||
default: '0.0.0'
|
||||
name_version:
|
||||
description: 'The release name used'
|
||||
type: string
|
||||
required: true
|
||||
default: 'v0.0.0'
|
||||
draft_version:
|
||||
description: 'Info about the release, publish or a draft'
|
||||
type: string
|
||||
required: true
|
||||
default: 'false'
|
||||
|
||||
|
||||
# Execute this command
|
||||
jobs:
|
||||
make-archive:
|
||||
name: Make Addon Package
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
|
||||
- name: Setup package variable
|
||||
id: folder
|
||||
run: |
|
||||
echo "::set-output name=folder::$(python '.github/package.py')"
|
||||
echo "::set-output name=package::$(python '.github/package.py').zip"
|
||||
|
||||
# Update the bl info version, update the init file and push if needed
|
||||
- name: Change version number in the bl info addon data
|
||||
run: python '.github/version.py' --tag=${{ inputs.num_version }} --name=${{ steps.folder.outputs.folder }}
|
||||
|
||||
- name: Commit the previous update
|
||||
uses: actions-js/push@v1.3
|
||||
if: ${{ github.event.action }} == 'opened'
|
||||
with:
|
||||
github_token: ${{secrets.GITHUB_TOKEN}}
|
||||
author_name: Moderlab
|
||||
author_email: a.vaillant@moderlab.com
|
||||
message: '[Bot] Bump to ${{ inputs.num_version }} version.'
|
||||
branch: develop
|
||||
force: true
|
||||
|
||||
# Make an archive with the plugin source only
|
||||
- name: Create zip archive release
|
||||
run: |
|
||||
cd '${{ github.workspace }}'
|
||||
zip -r '${{ github.workspace }}/releases/${{ steps.folder.outputs.package }}' ${{ steps.folder.outputs.folder }}
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ steps.folder.outputs.folder }}
|
||||
path: ${{ github.workspace }}/releases/${{ steps.folder.outputs.package }}
|
||||
|
||||
- name: Update the github release
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: johnwbyrd/update-release@v1.0.0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
files: '${{ github.workspace }}/releases/${{ steps.folder.outputs.package }}'
|
||||
release: ${{ inputs.name_version }}
|
||||
tag: ${{ inputs.name_version }}
|
||||
@@ -0,0 +1,46 @@
|
||||
name: Package Blender Plugin
|
||||
|
||||
# How to start the Github Action
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
name_version:
|
||||
description: 'The release name used'
|
||||
type: string
|
||||
required: true
|
||||
default: 'v0.0.0'
|
||||
|
||||
|
||||
# Execute this command
|
||||
jobs:
|
||||
make-archive:
|
||||
name: Make Addon Package
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
|
||||
- name: Setup package variable
|
||||
id: folder
|
||||
run: |
|
||||
echo "::set-output name=folder::$(python '.github/package.py')_preset"
|
||||
echo "::set-output name=package::$(python '.github/package.py')_preset.zip"
|
||||
|
||||
# Make an archive with the plugin source only
|
||||
- name: Create zip archive release
|
||||
run: |
|
||||
cd '${{ github.workspace }}/presets'
|
||||
zip -r '../releases/${{ steps.folder.outputs.package }}' '.'
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ steps.folder.outputs.folder }}
|
||||
path: ${{ github.workspace }}/releases/${{ steps.folder.outputs.package }}
|
||||
|
||||
- name: Update the github release
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: johnwbyrd/update-release@v1.0.0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
files: '${{ github.workspace }}/releases/${{ steps.folder.outputs.package }}'
|
||||
release: ${{ inputs.name_version }}
|
||||
tag: ${{ inputs.name_version }}
|
||||
@@ -0,0 +1,60 @@
|
||||
name: Create addon release
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
[main]
|
||||
types:
|
||||
[edited, synchronize, closed]
|
||||
|
||||
|
||||
jobs:
|
||||
init-release-data:
|
||||
name: Initialize all data about the package
|
||||
uses: Moderlab-Production/BlenderTemplate/.github/workflows/initialize_data.yml@main
|
||||
|
||||
unit-test:
|
||||
uses: Moderlab-Production/BlenderTemplate/.github/workflows/unit_test.yml@main
|
||||
|
||||
py-linter:
|
||||
uses: Moderlab-Production/BlenderTemplate/.github/workflows/linter.yml@main
|
||||
|
||||
release-package-addon:
|
||||
name: Generate archive package addon
|
||||
needs:
|
||||
- init-release-data
|
||||
- unit-test
|
||||
- py-linter
|
||||
uses: Moderlab-Production/BlenderTemplate/.github/workflows/package_addon.yml@main
|
||||
with:
|
||||
num_version: ${{ needs.init-release-data.outputs.version_number }}
|
||||
name_version: ${{ needs.init-release-data.outputs.version_name }}
|
||||
draft_version: ${{ needs.init-release-data.outputs.version_draft }}
|
||||
|
||||
release-package-preset:
|
||||
name: Generate archive package preset
|
||||
needs:
|
||||
- init-release-data
|
||||
- unit-test
|
||||
- py-linter
|
||||
uses: Moderlab-Production/BlenderTemplate/.github/workflows/package_preset.yml@main
|
||||
with:
|
||||
name_version: ${{ needs.init-release-data.outputs.version_name }}
|
||||
|
||||
publish-release:
|
||||
name: Publish the Github Release
|
||||
needs:
|
||||
- init-release-data
|
||||
- release-package-addon
|
||||
- release-package-preset
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Update/Publish the release
|
||||
uses: tubone24/update_release@v1.3.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
TAG_NAME: ${{ needs.init-release-data.outputs.version_name }}
|
||||
with:
|
||||
release_name: ${{ needs.init-release-data.outputs.version_name }}
|
||||
body: ''
|
||||
prerelease: ${{ needs.init-release-data.outputs.version_draft }}
|
||||
@@ -0,0 +1,46 @@
|
||||
name: Create addon release
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
[main]
|
||||
types:
|
||||
[opened]
|
||||
|
||||
|
||||
jobs:
|
||||
init-release:
|
||||
name: Generate the release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup bump release
|
||||
id: bump_setup
|
||||
run: |
|
||||
if [ ${{ contains(github.event.pull_request.labels.*.name, 'release:major') }} == true ]; then
|
||||
echo "::set-output name=type::major"
|
||||
elif [ ${{ contains(github.event.pull_request.labels.*.name, 'release:minor') }} == true ]; then
|
||||
echo "::set-output name=type::minor"
|
||||
else
|
||||
echo "::set-output name=type::patch"
|
||||
fi
|
||||
|
||||
- uses: actions/checkout@main
|
||||
|
||||
- name: Create new Semantic Version
|
||||
uses: zwaldowski/semver-release-action@v2
|
||||
id: new_semantic_setup
|
||||
with:
|
||||
bump: ${{ steps.bump_setup.outputs.type }}
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
dry_run: true
|
||||
prefix: v
|
||||
|
||||
- name: Make the github release
|
||||
uses: ncipollo/release-action@v1.10.0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
prerelease: true
|
||||
tag: ${{ steps.new_semantic_setup.outputs.version_tag }}
|
||||
|
||||
unit-test:
|
||||
uses: Moderlab-Production/BlenderTemplate/.github/workflows/unit_test.yml@main
|
||||
@@ -0,0 +1,28 @@
|
||||
name: Unit Test
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
push:
|
||||
branches-ignore:
|
||||
- main
|
||||
- develop
|
||||
|
||||
|
||||
jobs:
|
||||
unit-test:
|
||||
name: Unit Test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: "3.10"
|
||||
- name: Setup python to execute all Unit Test
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install -r tests/requirements.txt
|
||||
|
||||
- name: Start all Unit Test
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
python tests/main.py
|
||||
Reference in New Issue
Block a user