- Replace hardcoded repository and token checks with generic default-branch and pyproject.toml validation - Require fine-grained PAT permissions and validate Gist ownership and description - Add concurrency groups to badge update workflows - Bump softprops/action-gh-release to v3 and use DisplayName from pyproject.toml
77 lines
2.2 KiB
YAML
77 lines
2.2 KiB
YAML
# Reusable workflow
|
|
#
|
|
# Project metadata is read by the publishing action from pyproject.toml.
|
|
# No project-specific repository variables need to be configured manually.
|
|
#
|
|
# Required repository secret:
|
|
# REGISTRY_ACCESS_TOKEN Comfy Registry publishing API key
|
|
|
|
name: Publish to Comfy Registry
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
paths:
|
|
- "pyproject.toml"
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: comfy-registry-publish-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
publish-node:
|
|
name: Publish Custom Node to registry
|
|
runs-on: ubuntu-latest
|
|
if: github.ref_name == github.event.repository.default_branch
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Validate publishing configuration
|
|
env:
|
|
REGISTRY_ACCESS_TOKEN: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
|
|
run: |
|
|
if [ -z "$REGISTRY_ACCESS_TOKEN" ]; then
|
|
echo "::error title=Missing REGISTRY_ACCESS_TOKEN::Create a Comfy Registry publishing API key and add it as a repository secret named REGISTRY_ACCESS_TOKEN."
|
|
exit 1
|
|
fi
|
|
|
|
python - <<'PY'
|
|
from pathlib import Path
|
|
import tomllib
|
|
|
|
path = Path("pyproject.toml")
|
|
if not path.is_file():
|
|
raise SystemExit("pyproject.toml was not found")
|
|
|
|
with path.open("rb") as file:
|
|
config = tomllib.load(file)
|
|
|
|
required_fields = {
|
|
"[project].name": config.get("project", {}).get("name"),
|
|
"[project].version": config.get("project", {}).get("version"),
|
|
"[tool.comfy].PublisherId": (
|
|
config.get("tool", {}).get("comfy", {}).get("PublisherId")
|
|
),
|
|
}
|
|
missing = [
|
|
field
|
|
for field, value in required_fields.items()
|
|
if not str(value or "").strip()
|
|
]
|
|
|
|
if missing:
|
|
raise SystemExit(
|
|
"Missing required pyproject.toml fields: " + ", ".join(missing)
|
|
)
|
|
PY
|
|
|
|
- name: Publish Custom Node
|
|
uses: Comfy-Org/publish-node-action@main
|
|
with:
|
|
personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
|
|
skip_checkout: true
|