Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 21 additions & 30 deletions .github/actions/build/todesktop/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ inputs:
TODESKTOP_ACCESS_TOKEN:
description: 'ToDesktop Access Token'
required: true
STAGING:
description: 'Build Staging'
default: 'false'
required: false
RELEASE_TAG:
description: 'Release Tag'
required: false
Expand Down Expand Up @@ -53,22 +49,18 @@ runs:
TODESKTOP_EMAIL: ${{ inputs.TODESKTOP_EMAIL }}
TODESKTOP_ACCESS_TOKEN: ${{ inputs.TODESKTOP_ACCESS_TOKEN }}
run: |
if [ "${{ inputs.STAGING }}" = "true" ]; then
echo "🚧 Building STAGING version..."
yarn run publish:staging
else
echo "🚀 Building PRODUCTION version..."
yarn run publish | tee build.log

# Extract build ID from the log
BUILD_URL=$(grep "Build complete!" build.log | head -n1 | cut -d' ' -f3)
BUILD_ID=$(echo $BUILD_URL | cut -d'/' -f6)
APP_ID=$(echo $BUILD_URL | cut -d'/' -f5)

# Only update release notes if RELEASE_TAG is provided
if [ -n "${{ inputs.RELEASE_TAG }}" ]; then
# Create download links section
DOWNLOAD_LINKS="
echo "🚀 Building ToDesktop package..."
yarn run publish | tee build.log

# Extract build ID from the log
BUILD_URL=$(grep "Build complete!" build.log | head -n1 | cut -d' ' -f3)
BUILD_ID=$(echo $BUILD_URL | cut -d'/' -f6)
APP_ID=$(echo $BUILD_URL | cut -d'/' -f5)
Comment on lines +52 to +58
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Build log parsing may be fragile—consider defensive extraction.

Lines 56–58 extract BUILD_URL, BUILD_ID, and APP_ID from build.log using grep and cut. This assumes:

  • The output message is exactly "Build complete!" on the first matching line
  • The URL is reliably the 3rd space-separated field
  • No errors occur during the yarn run publish command

If ToDesktop changes output format or the command fails partially, these variables may be empty, silently corrupting download links in the release notes.

Add defensive checks after variable extraction:

  BUILD_URL=$(grep "Build complete!" build.log | head -n1 | cut -d' ' -f3)
  BUILD_ID=$(echo $BUILD_URL | cut -d'/' -f6)
  APP_ID=$(echo $BUILD_URL | cut -d'/' -f5)
+ 
+ if [ -z "$BUILD_URL" ] || [ -z "$BUILD_ID" ] || [ -z "$APP_ID" ]; then
+   echo "❌ Failed to extract build information from build.log"
+   cat build.log
+   exit 1
+ fi

Alternatively, consider capturing structured output from ToDesktop (if available) or improving the log parsing logic.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echo "🚀 Building ToDesktop package..."
yarn run publish | tee build.log
# Extract build ID from the log
BUILD_URL=$(grep "Build complete!" build.log | head -n1 | cut -d' ' -f3)
BUILD_ID=$(echo $BUILD_URL | cut -d'/' -f6)
APP_ID=$(echo $BUILD_URL | cut -d'/' -f5)
echo "🚀 Building ToDesktop package..."
yarn run publish | tee build.log
# Extract build ID from the log
BUILD_URL=$(grep "Build complete!" build.log | head -n1 | cut -d' ' -f3)
BUILD_ID=$(echo $BUILD_URL | cut -d'/' -f6)
APP_ID=$(echo $BUILD_URL | cut -d'/' -f5)
if [ -z "$BUILD_URL" ] || [ -z "$BUILD_ID" ] || [ -z "$APP_ID" ]; then
echo "❌ Failed to extract build information from build.log"
cat build.log
exit 1
fi
🤖 Prompt for AI Agents
.github/actions/build/todesktop/action.yml lines 52-58: the script parses
BUILD_URL/BUILD_ID/APP_ID from build.log using fragile grep/cut assumptions and
doesn't check for errors; update the workflow to (1) check the exit status of
`yarn run publish` and stop with an error if it failed, (2) validate that
BUILD_URL was found (non-empty) before deriving BUILD_ID and APP_ID, and fail
the job with a clear message if not, and (3) make parsing more defensive (e.g.
use a more specific grep/regex to locate the URL or prefer structured output if
ToDesktop can emit JSON) so empty or malformed values cannot be propagated into
release notes.


# Only update release notes if RELEASE_TAG is provided
if [ -n "${{ inputs.RELEASE_TAG }}" ]; then
# Create download links section
DOWNLOAD_LINKS="
### Download Latest:
Mac (Apple Silicon): https://download.comfy.org/mac/dmg/arm64
Windows: https://download.comfy.org/windows/nsis/x64
Expand All @@ -85,14 +77,13 @@ runs:
Windows: https://download.comfy.org/${BUILD_ID}/windows/nsis/x64

</details>"

# First get existing release notes
EXISTING_NOTES=$(gh release view ${{ inputs.RELEASE_TAG }} --json body -q .body)

# Combine existing notes with download links
UPDATED_NOTES="${EXISTING_NOTES}${DOWNLOAD_LINKS}"

# Update the release with combined notes
gh release edit ${{ inputs.RELEASE_TAG }} --notes "$UPDATED_NOTES"
fi

# First get existing release notes
EXISTING_NOTES=$(gh release view ${{ inputs.RELEASE_TAG }} --json body -q .body)

# Combine existing notes with download links
UPDATED_NOTES="${EXISTING_NOTES}${DOWNLOAD_LINKS}"

# Update the release with combined notes
gh release edit ${{ inputs.RELEASE_TAG }} --notes "$UPDATED_NOTES"
fi
1 change: 0 additions & 1 deletion .github/workflows/publish_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TODESKTOP_ACCESS_TOKEN: ${{ secrets.TODESKTOP_ACCESS_TOKEN }}
TODESKTOP_EMAIL: ${{ secrets.TODESKTOP_EMAIL }}
STAGING: 'false'
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.event.release.tag_name }}
25 changes: 0 additions & 25 deletions .github/workflows/publish_staging.yml

This file was deleted.

3 changes: 1 addition & 2 deletions .github/workflows/todesktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ jobs:
shell: bash

- name: Build
uses: ./.github/actions/build/windows/todesktop
uses: ./.github/actions/build/todesktop
with:
build-targets: '--targets=@electron-forge/maker-zip'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TODESKTOP_ACCESS_TOKEN: ${{ secrets.TODESKTOP_ACCESS_TOKEN }}
TODESKTOP_EMAIL: ${{ secrets.TODESKTOP_EMAIL }}