mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-15 13:02:35 +08:00
ci(sync): detect upstream release, sync master, build with GH fallback, and publish release
- Gate on new upstream release whose tag matches comfyui_version.py; skip if already released locally. - Sync master from upstream (keep local README.md), then build and push image on GH runner with pre-clean; fallback to ephemeral self-hosted if GH build fails; publish release if either path succeeds. - Remove unnecessary post-job cleanup since runners are ephemeral; rely on setup-buildx cleanup.
This commit is contained in:
parent
ae49228b6e
commit
249ff20e20
97
.github/workflows/sync-build-release.yml
vendored
97
.github/workflows/sync-build-release.yml
vendored
@ -24,7 +24,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
|
||||
- name: Install prerequisites (jq, curl, git)
|
||||
- name: Install prerequisites (jq, curl, gh, git)
|
||||
run: |
|
||||
set -e
|
||||
if ! command -v jq >/dev/null 2>&1; then
|
||||
@ -39,46 +39,32 @@ jobs:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
# 1) Upstream latest release tag (e.g., v0.3.59)
|
||||
# Latest upstream release tag (e.g., v0.3.59)
|
||||
LATEST_TAG=$(gh api repos/comfyanonymous/ComfyUI/releases/latest --jq .tag_name)
|
||||
|
||||
# 2) Parse upstream comfyui_version.py from the current upstream default branch
|
||||
git remote add upstream https://github.com/comfyanonymous/ComfyUI.git 2>/dev/null || git remote set-url upstream https://github.com/comfyanonymous/ComfyUI.git
|
||||
# Fetch comfyui_version.py from upstream default branch
|
||||
if git remote get-url upstream >/dev/null 2>&1; then
|
||||
git remote set-url upstream https://github.com/comfyanonymous/ComfyUI.git
|
||||
else
|
||||
git remote add upstream https://github.com/comfyanonymous/ComfyUI.git
|
||||
fi
|
||||
git fetch upstream --depth=1
|
||||
FILE_VER=$(git show upstream/master:comfyui_version.py | sed -n 's/^__version__ = "\(.*\)"/\1/p' | tr -d '\r')
|
||||
|
||||
# Normalize release tag to bare version (strip leading 'v')
|
||||
FILE_VER=$(git show upstream/master:comfyui_version.py | sed -n 's/^__version__ = "\(.*\)"/\1/p' | tr -d '\r' || true)
|
||||
LATEST_VER="${LATEST_TAG#v}"
|
||||
|
||||
# 3) Only consider it "new" if the release tag matches the version file (avoid early bumps)
|
||||
CANDIDATE="none"
|
||||
if [ -n "${LATEST_TAG}" ] && [ "${LATEST_TAG}" != "null" ] && [ -n "${FILE_VER}" ] && [ "${FILE_VER}" = "${LATEST_VER}" ]; then
|
||||
CANDIDATE="${LATEST_TAG}"
|
||||
fi
|
||||
|
||||
# 4) Skip if this repo already has a release at that tag
|
||||
if [ "${CANDIDATE}" != "none" ]; then
|
||||
# ensure no existing release with same tag in this repo
|
||||
SELF_TAG=$(gh api repos/${GITHUB_REPOSITORY}/releases/latest --jq .tag_name 2>/dev/null || echo "none")
|
||||
if [ "${SELF_TAG}" = "${CANDIDATE}" ]; then
|
||||
CANDIDATE="none"
|
||||
if [ "${SELF_TAG}" != "${LATEST_TAG}" ]; then
|
||||
CANDIDATE="${LATEST_TAG}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "new_version=${CANDIDATE}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Cleanup workspace (always, scoped)
|
||||
if: ${{ always() }}
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
rm -rf "${GITHUB_WORKSPACE:?}/"* "${GITHUB_WORKSPACE:?}/."[!.]* 2>/dev/null || true
|
||||
|
||||
build-gh:
|
||||
name: Build on GitHub Runner (primary)
|
||||
needs: check-upstream
|
||||
if: needs.check-upstream.outputs.new_version != 'none'
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
outputs:
|
||||
built: ${{ steps.mark.outputs.built }}
|
||||
digest: ${{ steps.build.outputs.digest }}
|
||||
@ -105,11 +91,33 @@ jobs:
|
||||
git fetch upstream
|
||||
git checkout master
|
||||
git merge --no-commit --no-ff upstream/master --allow-unrelated-histories || true
|
||||
git checkout --ours README.md
|
||||
git add README.md
|
||||
git checkout --ours README.md || true
|
||||
git add README.md || true
|
||||
git commit -m "Merge upstream/master, keep local README.md" || true
|
||||
git push origin master
|
||||
|
||||
- name: Show disk usage (pre)
|
||||
run: df -h | sed 's/\s\+/ /g'
|
||||
|
||||
- name: Free Disk Space (Ubuntu)
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
tool-cache: false
|
||||
android: true
|
||||
dotnet: true
|
||||
haskell: true
|
||||
large-packages: true
|
||||
docker-images: true
|
||||
swap-storage: true
|
||||
|
||||
- name: Prune Docker caches (pre)
|
||||
run: |
|
||||
docker builder prune -af || true
|
||||
docker system prune -af --volumes || true
|
||||
|
||||
- name: Show disk usage (post-clean)
|
||||
run: df -h | sed 's/\s\+/ /g'
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
@ -141,14 +149,6 @@ jobs:
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.CR_PAT }}
|
||||
|
||||
- name: Free disk space (best effort)
|
||||
continue-on-error: true
|
||||
run: |
|
||||
sudo docker system prune -af || true
|
||||
sudo rm -rf /usr/local/lib/android || true
|
||||
sudo rm -rf /opt/ghc || true
|
||||
sudo rm -rf /opt/hostedtoolcache/CodeQL || true
|
||||
|
||||
- name: Build and Push (GH runner)
|
||||
id: build
|
||||
uses: docker/build-push-action@v6
|
||||
@ -159,13 +159,15 @@ jobs:
|
||||
push: true
|
||||
provenance: false
|
||||
sbom: false
|
||||
cache-from: type=gha,scope=gh
|
||||
cache-to: type=gha,mode=max,scope=gh
|
||||
tags: |
|
||||
${{ env.IMAGE_NAME }}:${{ needs.check-upstream.outputs.new_version }}
|
||||
${{ env.IMAGE_NAME }}:latest
|
||||
|
||||
- name: Mark build success
|
||||
id: mark
|
||||
if: ${{ success() && steps.build.outputs.digest != '' }}
|
||||
if: ${{ steps.build.outcome == 'success' && steps.build.outputs.digest != '' }}
|
||||
run: echo "built=true" >> "$GITHUB_OUTPUT"
|
||||
|
||||
build-self:
|
||||
@ -199,8 +201,8 @@ jobs:
|
||||
git fetch upstream
|
||||
git checkout master
|
||||
git merge --no-commit --no-ff upstream/master --allow-unrelated-histories || true
|
||||
git checkout --ours README.md
|
||||
git add README.md
|
||||
git checkout --ours README.md || true
|
||||
git add README.md || true
|
||||
git commit -m "Merge upstream/master, keep local README.md" || true
|
||||
git push origin master
|
||||
|
||||
@ -251,24 +253,9 @@ jobs:
|
||||
|
||||
- name: Mark build success
|
||||
id: mark
|
||||
if: ${{ success() && steps.build.outputs.digest != '' }}
|
||||
if: ${{ steps.build.outcome == 'success' && steps.build.outputs.digest != '' }}
|
||||
run: echo "built=true" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Remove BuildKit image (moby/buildkit)
|
||||
if: ${{ always() }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
docker image rm -f $(docker images 'moby/buildkit*' -q) 2>/dev/null || true
|
||||
|
||||
- name: Cleanup (always, scoped)
|
||||
if: ${{ always() }}
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
docker buildx prune -af || true
|
||||
docker image prune -af --filter "until=168h" || true
|
||||
rm -rf "${GITHUB_WORKSPACE:?}/"* "${GITHUB_WORKSPACE:?}/."[!.]* 2>/dev/null || true
|
||||
|
||||
publish:
|
||||
name: Publish Release
|
||||
needs: [check-upstream, build-gh, build-self]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user