Skip to content

Commit 906cb26

Browse files
authored
Initial commit
0 parents  commit 906cb26

11 files changed

Lines changed: 328 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Create TOX Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
9+
jobs:
10+
Build_tox:
11+
runs-on: [self-hosted, Windows, TouchDesigner]
12+
steps:
13+
- name: Check out repository code
14+
uses: actions/checkout@v6
15+
with:
16+
fetch-depth: 0
17+
fetch-tags: true
18+
submodules: true
19+
20+
- name: SudoMagic TD Package Builder
21+
uses: SudoMagicCode/action-build-td-tox-package@v0.0.5
22+
with:
23+
build_settings: ./buildSettings.json
24+
25+
- name: Generate Hybrid Version
26+
id: semver
27+
run: |
28+
# This pattern matches v, digits, a literal dot, and digits.
29+
# It effectively blocks v1.0.1 because the * after the second number
30+
# would usually allow another dot, but we want to anchor strictly.
31+
$BASE_TAG = git describe --tags --abbrev=0 --match "v[0-9]*.[0-9]*" --exclude "v*.*.*" 2>$null
32+
33+
if ($LASTEXITCODE -ne 0) {
34+
Write-Host "No base tag found, defaulting to v0.0"
35+
$BASE_TAG = "v0.0"
36+
}
37+
38+
# 2. Count commits since that base tag.
39+
# If the current commit is the tag itself, COUNT will be 0.
40+
if ($BASE_TAG -eq "v0.0") {
41+
$COUNT = git rev-list --count HEAD
42+
} else {
43+
$COUNT = git rev-list --count "$($BASE_TAG)..HEAD"
44+
}
45+
46+
# 3. Construct the hybrid VERSION (vX.Y.Z)
47+
$VERSION = "$BASE_TAG.$COUNT"
48+
49+
Write-Host "Base Tag: $BASE_TAG"
50+
Write-Host "Commits since base: $COUNT"
51+
Write-Host "Final Release Version: $VERSION"
52+
53+
echo "VERSION=$VERSION" >> $env:GITHUB_OUTPUT
54+
55+
- name: Create Github Release
56+
uses: softprops/action-gh-release@v2
57+
with:
58+
tag_name: ${{ steps.semver.outputs.VERSION }}
59+
name: Release ${{ steps.semver.outputs.VERSION }}
60+
# Generates "What's Changed" section automatically from PRs/commits
61+
generate_release_notes: true
62+
# Set to true if you want it to stay hidden until you review it
63+
draft: false
64+
prerelease: false
65+
files: ./artifacts/package.zip

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
scripts/__pycache__/
3+
4+
release/
5+
6+
scripts/td_builder/__pycache__/
7+
8+
old-scripts/td_builder/__pycache__/
9+
10+
old-scripts/__pycache__/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"folders": [
3+
{
4+
"name": "Automation",
5+
"path": "../.github/"
6+
},
7+
{
8+
"name": "Build Scripts",
9+
"path": "../Scripts/"
10+
}
11+
],
12+
"settings": {}
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"folders": [
3+
{
4+
"name": "TD Component Dev",
5+
"path": "../TouchDesigner"
6+
}
7+
],
8+
"settings": {}
9+
}

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# name-of-tox here
2+
3+
## Summary
4+
Summary of tox behvior here
5+
6+
## TDM Installation
7+
If you are using the [TouchDesigner Dependency Manager](https://github.com/SudoMagicCode/TouchDesigner-Dependency-Manager) you can add this component to your local project with a `add package` command.
8+
```shell
9+
tdm add package {{repo_url_without_https://}}
10+
```

TouchDesigner/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tdPackages/

TouchDesigner/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# td-tox-builder-template

TouchDesigner/project.toe

195 KB
Binary file not shown.
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
'''
2+
Package TOX for Release Class
3+
Authors | matthew ragan
4+
matthewragan.com
5+
'''
6+
7+
import webbrowser
8+
import json
9+
10+
popupMsg = '''Your file is saved as | {name}
11+
Save Location | {location}'''
12+
13+
14+
class PackageTOX:
15+
'''
16+
This class is designed to operate as a general helper extension.
17+
18+
When sharing a TOX it's often difficult to ensure that it's correctly
19+
packaged in a uniform and consistent manner that will ensure it's immediately usable by a
20+
third party. This TOX aims to simplify some of that process by automating the prep and
21+
packaging of a TOX in a consistent and reliable manner.
22+
---------------
23+
24+
'''
25+
26+
def __init__(self, ownerOp):
27+
'''
28+
'''
29+
self.OwnerOp = ownerOp
30+
self.Release_target_op = ownerOp.par.Targetoperator
31+
self.Release_version = ownerOp.par.Releaseversion
32+
self.Reset_color = (0.545, 0.545, 0.545)
33+
self.Format_ready_save_loc = '{loc}/{name}.tox'
34+
self.Save_dir = ownerOp.par.Savelocation
35+
self.Tox_Name = ownerOp.par.Toxname
36+
self.Destroy_tags = ownerOp.par.Destroytags
37+
self.Ext_file_tags = ownerOp.par.Externalfiletags
38+
39+
self.saveBuffer = ownerOp.op("base_saveBuffer")
40+
41+
self.GithubLink = "https://github.com/raganmd/touchdesigner-tox-prep-for-release"
42+
print("PackageTOX Initialized")
43+
return
44+
45+
def copyToSaveBuffer(self, targetOp):
46+
quiteCopy = self.saveBuffer.copy(targetOp)
47+
return quiteCopy
48+
49+
def Package(self):
50+
msg = "Packing TOX"
51+
self._log_release_event(msg=msg)
52+
location = self.Save_tox()
53+
msg = popupMsg.format(location=location, name=self.Tox_Name)
54+
55+
# if running just a build, force quit
56+
if self.OwnerOp.par.Quitafterpackaging:
57+
run(self._force_quit, delayFrames=10)
58+
59+
op('base_popup/container_popup/text_body').text = msg
60+
op('base_popup/window1').par.winopen.pulse()
61+
62+
def Save_tox(self):
63+
# format the save location for the tox
64+
save_loc = self.Format_ready_save_loc.format(
65+
loc=self.Save_dir, name=self.Tox_Name)
66+
target_op = self.copyToSaveBuffer(self.Release_target_op.eval())
67+
68+
# set version
69+
target_op.par.Version = self.Release_version
70+
target_op.par.Version.readOnly = True
71+
72+
# clean-up external files - disable loading, remove paths
73+
ext_file_tags = self.Ext_file_tags.val.split(',')
74+
ops_to_prep = [each_op for each_op in target_op.findChildren(
75+
type=DAT) if each_op.par['file'] != '']
76+
self.Disable_external_file(ops_to_prep)
77+
78+
# ensure target tox doesn't have a file path
79+
target_op.par.externaltox = ''
80+
81+
# reset target tox color to be default
82+
target_op.color = self.Reset_color
83+
84+
# lock the tox icon
85+
# target_op.op('null_icon').lock = True
86+
87+
# destory ops used for Dev
88+
destroy_tags = self.Destroy_tags.val.split(',')
89+
ops_to_destroy = target_op.findChildren(tags=destroy_tags)
90+
self.Destroy_ops(ops_to_destroy)
91+
92+
# set all custom pars but about page to defaults
93+
self.SetCustomDefaults(target_op)
94+
95+
# set parent shortcut par to be read only
96+
target_op.par.parentshortcut.readOnly = True
97+
98+
# set bg top to be read read only
99+
target_op.par.opviewer.readOnly = True
100+
101+
# hide ops
102+
self.HideOps(target_op)
103+
104+
# add privacy
105+
self.AddPrivacy(target_op)
106+
107+
# save TOX in target location
108+
target_op.save(save_loc)
109+
110+
# destroy the buffer copy
111+
target_op.destroy()
112+
113+
return save_loc
114+
115+
def HideOps(self, targetOp):
116+
# hides ops from view
117+
hideTargets = targetOp.findChildren(tags=['HIDE'])
118+
if self.OwnerOp.par.Hideops.eval():
119+
for eachOp in hideTargets:
120+
eachOp.expose = False
121+
msg = f"Hiding op {eachOp.path}"
122+
self._log_release_event(msg=msg)
123+
124+
pass
125+
126+
def SetCustomDefaults(self, targetOp):
127+
'''Set Custom Defaults
128+
129+
Skip all custom pars on about page
130+
All other custom pars, set to default vals
131+
'''
132+
for eachPar in targetOp.pars():
133+
if eachPar.isCustom and eachPar.page != 'About':
134+
eachPar.val = eachPar.default
135+
msg = f"Setting default for par {eachPar.name}"
136+
self._log_release_event(msg=msg)
137+
else:
138+
pass
139+
140+
def AddPrivacy(self, targetOp):
141+
# find all ops tagged for privacy
142+
privacyOps = targetOp.findChildren(type=COMP, tags=['private'])
143+
144+
for eachPrivateOp in privacyOps:
145+
print('private Op ', eachPrivateOp)
146+
147+
# if the private flag is on, make all privacy ops private
148+
if self.OwnerOp.par.Makeprivate.eval():
149+
privacyKey = self.OwnerOp.par.Password.eval()
150+
privacyDev = self.OwnerOp.par.Developer.eval()
151+
privacyEmail = self.OwnerOp.par.Developeremail.eval()
152+
eachPrivateOp.addPrivacy(privacyKey,
153+
developerName=privacyDev,
154+
developerEmail=privacyEmail)
155+
else:
156+
pass
157+
pass
158+
159+
def Destroy_ops(self, ops_to_destroy):
160+
161+
for each in ops_to_destroy:
162+
msg = f"destroying op {each.path}"
163+
self._log_release_event(msg=msg)
164+
each.destroy()
165+
166+
return ops_to_destroy
167+
168+
def Disable_external_file(self, ops_to_prep):
169+
170+
for each in ops_to_prep:
171+
try:
172+
# remove path par for ext
173+
each.par.file = ''
174+
# turn off loading on start
175+
each.par.loadonstart = False
176+
msg = f"disabling external file for op {each.path}"
177+
self._log_release_event(msg=msg)
178+
179+
except:
180+
msg = f'Skipping Op {each.path}'
181+
self._log_release_event(msg=msg)
182+
183+
return ops_to_prep
184+
185+
def _log_release_event(self, msg: str) -> None:
186+
automation_msg = {
187+
"sender": f'TD - {self.Tox_Name.eval()}', "payload": msg}
188+
print(msg)
189+
log_file = f"{self.Save_dir.eval()}/log.txt"
190+
try:
191+
with open(log_file, "a") as file:
192+
file.write(f"TD {self.Tox_Name.eval()} | {msg}\n")
193+
except Exception as e:
194+
pass
195+
196+
def _force_quit(self):
197+
msg = f"Quitting TouchDesigner"
198+
self._log_release_event(msg=msg)
199+
project.quit(force=True)
200+
201+
def Open_github_link(self):
202+
webbrowser.open_new_tab(self.GithubLink)
203+
return self.GithubLink

TouchDesigner/tdmPackages.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: TD-TOX-Builder Template
2+
tdVersion: 2025.32460.Project
3+
tdPackages:
4+
- package: github.com/SudoMagicCode/td-packager-comp
5+
releaseTag: v0.2.27
6+
- package: github.com/SudoMagicCode/td-comp-icon
7+
releaseTag: v1.2.8
8+
pythonRequirements: []

0 commit comments

Comments
 (0)