# Reusable workflow # # The release name and version are read from pyproject.toml. # No project-specific repository variables or additional secrets are required. name: Release on: workflow_dispatch: push: paths: - "pyproject.toml" permissions: contents: write concurrency: group: release-${{ github.ref }} cancel-in-progress: false jobs: release: runs-on: ubuntu-latest if: github.ref_name == github.event.repository.default_branch steps: - name: Checkout repo uses: actions/checkout@v7 with: fetch-depth: 0 - name: Read project metadata id: metadata run: | python - <<'PY' >> "$GITHUB_OUTPUT" import re import tomllib with open("pyproject.toml", "rb") as handle: data = tomllib.load(handle) project = data.get("project", {}) version = str(project.get("version", "")).strip() name = str(project.get("name", "")).strip() display_name = str( data.get("tool", {}).get("comfy", {}).get("DisplayName") or name ).strip() if not name: raise SystemExit("[project].name is missing in pyproject.toml") if not re.fullmatch(r"\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?", version): raise SystemExit(f"Invalid semantic version in pyproject.toml: {version}") print(f"project_name={name}") print(f"display_name={display_name}") print(f"version={version}") print(f"tag=v{version}") PY - name: Check if tag for this version already exists id: tag_check run: | TAG="${{ steps.metadata.outputs.tag }}" git fetch --force --tags if git rev-parse --verify --quiet "refs/tags/$TAG" >/dev/null; then echo "Tag $TAG already exists. Skipping release." echo "exists=true" >> $GITHUB_OUTPUT else echo "exists=false" >> $GITHUB_OUTPUT fi - name: Build release notes id: notes if: steps.tag_check.outputs.exists != 'true' run: | CURRENT_TAG="${{ steps.metadata.outputs.tag }}" PREVIOUS_TAG="$(git tag --list 'v[0-9]*' --sort=-v:refname | grep -vx "$CURRENT_TAG" | head -n 1 || true)" if [ -n "$PREVIOUS_TAG" ]; then RANGE="$PREVIOUS_TAG..HEAD" HEADER="Changes since $PREVIOUS_TAG" else RANGE="HEAD" HEADER="Initial release" fi { echo "body<> "$GITHUB_OUTPUT" - name: Create GitHub Release if: steps.tag_check.outputs.exists != 'true' uses: softprops/action-gh-release@v3 with: tag_name: ${{ steps.metadata.outputs.tag }} name: ${{ steps.metadata.outputs.display_name }} ${{ steps.metadata.outputs.tag }} body: ${{ steps.notes.outputs.body }} generate_release_notes: true