Skip to content

Commit 203def0

Browse files
fix: improve publish workflow git setup and validation (#268)
1 parent bee2234 commit 203def0

File tree

6 files changed

+99
-25
lines changed

6 files changed

+99
-25
lines changed

.github/workflows/lint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
yaml-lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: "20"
20+
21+
- name: Install YAML linter
22+
run: npm install -g yaml-lint
23+
24+
- name: Lint YAML files
25+
run: yamllint .github/workflows/*.{yml,yaml}

.github/workflows/publish.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Checkout code
1818
uses: actions/checkout@v4
1919
with:
20-
fetch-depth: 2
20+
fetch-depth: 0 # Full history needed for tags and version comparison
2121

2222
- name: Check if version actually changed
2323
id: check
@@ -41,6 +41,8 @@ jobs:
4141
steps:
4242
- name: Checkout code
4343
uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 0 # Full history needed for tags and bump_versions.py
4446

4547
- name: Set up Node.js
4648
uses: actions/setup-node@v4
@@ -70,13 +72,17 @@ jobs:
7072
- name: Auto-bump package versions based on changes
7173
run: |
7274
source .venv/bin/activate
73-
python scripts/bump_versions.py
75+
PREV_TAG=$(git tag --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1)
76+
if [ -z "$PREV_TAG" ]; then
77+
python scripts/bump_versions.py --base-ref HEAD~1
78+
else
79+
python scripts/bump_versions.py --base-ref "$PREV_TAG"
80+
fi
7481
7582
- name: Determine changed packages
7683
id: changed-packages
7784
run: |
7885
source .venv/bin/activate
79-
# Get packages that were just bumped by bump_versions.py
8086
CHANGED_OUTPUT=$(python scripts/bump_versions.py --dry-run 2>/dev/null || echo "")
8187
8288
# Extract package names from bump_versions.py output

.yamllint.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extends: default
2+
3+
rules:
4+
line-length:
5+
max: 200 # Allow longer lines in YAML files
6+
document-start: disable # Don't require --- at start
7+
truthy: disable # Allow on/off instead of true/false

README.md

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -371,32 +371,23 @@ Raw markdown used:
371371
> [Wan 2.1 Tutorial - docs.comfy.org](https://docs.comfy.org/tutorials/video/wan/wan-video) — Explanation of concepts and step-by-step tutorial
372372
```
373373

374-
### 12 — Bump Version and Create PR
375-
376-
Run the automated version helper before opening your PR. It looks at the latest git tag
377-
and bumps only the packages that changed (plus updates dependency pins):
378-
379-
```bash
380-
./scripts/bump_versions.py --dry-run # optional preview
381-
./scripts/bump_versions.py
382-
```
383-
384-
Then run the full validation script (which regenerates manifests, runs lint/tests, and
385-
builds wheels):
386-
387-
```bash
388-
./run_full_validation.sh
389-
```
374+
### 12 — Create PR
390375

391376
1. Fully test the workflow: delete the models, input images, etc. and try it as a new user would. Ensure the process has no hiccups and you can generate the thumbnail image on the first execution (if applicable).
392377
2. Create a fork of https://github.com/Comfy-Org/workflow_templates (or just checkout a new branch if you are a Comfy-Org collaborator)
393378
3. Clone the fork to your system (if not a collaborator)
394379
4. Copy your new workflow and thumbnail(s) into the `templates` folder
395380
5. Add your changes to the `templates/index.json` file
396-
6. Bump the version in `pyproject.toml` ([example](https://github.com/Comfy-Org/workflow_templates/pull/32))
381+
6. **Bump the version in the root `pyproject.toml`** ([example](https://github.com/Comfy-Org/workflow_templates/pull/32))
397382
7. Commit and push changes
398383
8. Create a PR on https://github.com/Comfy-Org/workflow_templates
399384

385+
Version bumping and package building are automated via CI/CD. Bumping the root `pyproject.toml` version automatically:
386+
- Detects which subpackages have changed since their last release
387+
- Bumps versions only for affected packages
388+
- Updates all dependency references
389+
- Builds and publishes packages to PyPI
390+
400391
Here is the PR I made for the Wan template: https://github.com/Comfy-Org/workflow_templates/pull/16
401392

402393
Once the PR is merged, if you followed step 6 correctly, a new version will be published to the [comfyui-workflow-templates PyPi package](https://pypi.org/project/comfyui-workflow-templates).

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "comfyui_workflow_templates"
7-
version = "0.3.5"
7+
version = "0.3.6"
88
description = "ComfyUI workflow templates package"
99
readme = "README.md"
1010
requires-python = ">=3.9"

scripts/bump_versions.py

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,29 @@ def git_changed_files(base_ref: str) -> List[str]:
127127
return [line.strip() for line in out.splitlines() if line.strip()]
128128

129129

130+
def get_last_pyproject_commit(pyproject_path: str) -> str:
131+
"""Find the last commit that modified a specific pyproject.toml file."""
132+
try:
133+
out = run_git(["log", "-1", "--format=%H", "--", pyproject_path])
134+
return out.strip()
135+
except subprocess.CalledProcessError:
136+
return "HEAD~1" # fallback if no history found
137+
138+
139+
def git_changed_files_since_package_release(pkg: str, cfg: PackageConfig) -> List[str]:
140+
"""Get changed files for a package since its last pyproject.toml change."""
141+
# Find the last commit that changed this package's pyproject.toml
142+
pyproject_path = str(cfg.pyproject_paths[0].relative_to(ROOT))
143+
last_commit = get_last_pyproject_commit(pyproject_path)
144+
145+
# Get all changes since that commit
146+
try:
147+
out = run_git(["diff", f"{last_commit}..HEAD", "--name-only"])
148+
return [line.strip() for line in out.splitlines() if line.strip()]
149+
except subprocess.CalledProcessError:
150+
return []
151+
152+
130153
def load_bundles_from_git(ref: str) -> Mapping[str, List[str]]:
131154
try:
132155
raw = run_git(["show", f"{ref}:bundles.json"])
@@ -197,10 +220,32 @@ def packages_changed_from_paths(changed_files: Iterable[str]) -> Set[str]:
197220

198221

199222
def packages_to_bump(base_ref: str) -> Set[str]:
200-
changed = git_changed_files(base_ref)
201-
affected = packages_changed_from_paths(changed)
202-
affected |= detect_template_asset_changes(changed)
203-
affected |= detect_bundle_changes(base_ref)
223+
"""Determine which packages need version bumps based on changes since their last release."""
224+
affected = set()
225+
226+
# Check each package individually against its own last pyproject change
227+
for pkg, cfg in PACKAGE_CONFIGS.items():
228+
229+
# Get changes since this package's last pyproject.toml modification
230+
changed_files = git_changed_files_since_package_release(pkg, cfg)
231+
232+
# Check if this package's files changed
233+
pkg_affected = packages_changed_from_paths(changed_files)
234+
if pkg in pkg_affected:
235+
affected.add(pkg)
236+
continue
237+
238+
# Check template asset changes for this package
239+
template_affected = detect_template_asset_changes(changed_files)
240+
if pkg in template_affected:
241+
affected.add(pkg)
242+
continue
243+
244+
# Check bundle changes (this still needs global base_ref for bundles.json comparison)
245+
if base_ref:
246+
bundle_affected = detect_bundle_changes(base_ref)
247+
if pkg in bundle_affected:
248+
affected.add(pkg)
204249

205250
# If any of the component bundles changed, make sure meta gets bumped too
206251
if affected & {"core", "media_api", "media_image", "media_other", "media_video"}:

0 commit comments

Comments
 (0)