Skip to content

Commit c636900

Browse files
authored
Add Desktop UI npm publishing workflows (#5915)
## Summary Adds automated npm publishing for @comfyorg/desktop-ui package with version management and release workflows. - Ref: #5912 ## Changes - **What**: Three GitHub Actions workflows for desktop-ui npm publishing automation ### Two functions 1. Bump action - Just creates a version bump PR for `desktop-ui` 2. Publish action - Can be run manually - essentially a function with params / void return ### One automation - Watches for matching commits, then calls the Publish action with pre-filled details ## Review Focus Security hardening and workflow correctness. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5915-Add-Desktop-UI-npm-publishing-workflows-2826d73d365081d9b7f8d7f752536ceb) by [Unito](https://www.unito.io)
1 parent f09590f commit c636900

File tree

3 files changed

+335
-0
lines changed

3 files changed

+335
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish Desktop UI on PR Merge
2+
3+
on:
4+
pull_request:
5+
types: [ closed ]
6+
branches: [ main, core/* ]
7+
paths:
8+
- 'apps/desktop-ui/package.json'
9+
10+
jobs:
11+
resolve:
12+
name: Resolve Version and Dist Tag
13+
runs-on: ubuntu-latest
14+
if: >
15+
github.event.pull_request.merged == true &&
16+
contains(github.event.pull_request.labels.*.name, 'Release')
17+
outputs:
18+
version: ${{ steps.get_version.outputs.version }}
19+
dist_tag: ${{ steps.dist.outputs.dist_tag }}
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v5
23+
with:
24+
ref: ${{ github.event.pull_request.merge_commit_sha }}
25+
persist-credentials: false
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v5
29+
with:
30+
node-version: '24.x'
31+
32+
- name: Read desktop-ui version
33+
id: get_version
34+
run: |
35+
VERSION=$(node -p "require('./apps/desktop-ui/package.json').version")
36+
echo "version=$VERSION" >> $GITHUB_OUTPUT
37+
38+
- name: Determine dist-tag
39+
id: dist
40+
env:
41+
VERSION: ${{ steps.get_version.outputs.version }}
42+
run: |
43+
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+- ]]; then
44+
echo "dist_tag=next" >> $GITHUB_OUTPUT
45+
else
46+
echo "dist_tag=latest" >> $GITHUB_OUTPUT
47+
fi
48+
49+
publish:
50+
name: Publish Desktop UI to npm
51+
needs: resolve
52+
uses: ./.github/workflows/publish-desktop-ui.yaml
53+
with:
54+
version: ${{ needs.resolve.outputs.version }}
55+
dist_tag: ${{ needs.resolve.outputs.dist_tag }}
56+
ref: ${{ github.event.pull_request.merge_commit_sha }}
57+
secrets:
58+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
59+
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
name: Publish Desktop UI
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to publish (e.g., 1.2.3)'
8+
required: true
9+
type: string
10+
dist_tag:
11+
description: 'npm dist-tag to use'
12+
required: true
13+
default: latest
14+
type: string
15+
ref:
16+
description: 'Git ref to checkout (commit SHA, tag, or branch)'
17+
required: false
18+
type: string
19+
workflow_call:
20+
inputs:
21+
version:
22+
required: true
23+
type: string
24+
dist_tag:
25+
required: false
26+
type: string
27+
default: latest
28+
ref:
29+
required: false
30+
type: string
31+
secrets:
32+
NPM_TOKEN:
33+
required: true
34+
35+
concurrency:
36+
group: publish-desktop-ui-${{ github.workflow }}-${{ inputs.version }}-${{ inputs.dist_tag }}
37+
cancel-in-progress: false
38+
39+
jobs:
40+
publish_desktop_ui:
41+
name: Publish @comfyorg/desktop-ui
42+
runs-on: ubuntu-latest
43+
permissions:
44+
contents: read
45+
env:
46+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
47+
steps:
48+
- name: Validate inputs
49+
env:
50+
VERSION: ${{ inputs.version }}
51+
shell: bash
52+
run: |
53+
set -euo pipefail
54+
SEMVER_REGEX='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\.(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*))?(\+([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$'
55+
if [[ ! "$VERSION" =~ $SEMVER_REGEX ]]; then
56+
echo "::error title=Invalid version::Version '$VERSION' must follow semantic versioning (x.y.z[-suffix][+build])" >&2
57+
exit 1
58+
fi
59+
60+
- name: Determine ref to checkout
61+
id: resolve_ref
62+
env:
63+
REF: ${{ inputs.ref }}
64+
VERSION: ${{ inputs.version }}
65+
shell: bash
66+
run: |
67+
set -euo pipefail
68+
if [ -n "$REF" ]; then
69+
if ! git check-ref-format --allow-onelevel "$REF"; then
70+
echo "::error title=Invalid ref::Ref '$REF' fails git check-ref-format validation." >&2
71+
exit 1
72+
fi
73+
echo "ref=$REF" >> "$GITHUB_OUTPUT"
74+
else
75+
echo "ref=refs/tags/v$VERSION" >> "$GITHUB_OUTPUT"
76+
fi
77+
78+
- name: Checkout repository
79+
uses: actions/checkout@v5
80+
with:
81+
ref: ${{ steps.resolve_ref.outputs.ref }}
82+
fetch-depth: 1
83+
persist-credentials: false
84+
85+
- name: Install pnpm
86+
uses: pnpm/action-setup@v4
87+
with:
88+
version: 10
89+
90+
- name: Setup Node.js
91+
uses: actions/setup-node@v5
92+
with:
93+
node-version: '24.x'
94+
cache: 'pnpm'
95+
registry-url: https://registry.npmjs.org
96+
97+
- name: Install dependencies
98+
run: pnpm install --frozen-lockfile --ignore-scripts
99+
100+
- name: Build Desktop UI
101+
run: pnpm build:desktop
102+
103+
- name: Prepare npm package
104+
id: pkg
105+
shell: bash
106+
run: |
107+
set -euo pipefail
108+
APP_PKG=apps/desktop-ui/package.json
109+
ROOT_PKG=package.json
110+
111+
NAME=$(jq -r .name "$APP_PKG")
112+
APP_VERSION=$(jq -r .version "$APP_PKG")
113+
ROOT_LICENSE=$(jq -r .license "$ROOT_PKG")
114+
REPO=$(jq -r .repository "$ROOT_PKG")
115+
116+
if [ -z "$NAME" ] || [ "$NAME" = "null" ]; then
117+
echo "::error title=Missing name::apps/desktop-ui/package.json is missing 'name'" >&2
118+
exit 1
119+
fi
120+
121+
INPUT_VERSION="${{ inputs.version }}"
122+
if [ "$APP_VERSION" != "$INPUT_VERSION" ]; then
123+
echo "::error title=Version mismatch::apps/desktop-ui version $APP_VERSION does not match input $INPUT_VERSION" >&2
124+
exit 1
125+
fi
126+
127+
if [ ! -d apps/desktop-ui/dist ]; then
128+
echo "::error title=Missing build::apps/desktop-ui/dist not found. Did build succeed?" >&2
129+
exit 1
130+
fi
131+
132+
PUBLISH_DIR=apps/desktop-ui/.npm-publish
133+
rm -rf "$PUBLISH_DIR"
134+
mkdir -p "$PUBLISH_DIR"
135+
cp -R apps/desktop-ui/dist "$PUBLISH_DIR/dist"
136+
137+
INPUT_VERSION="${{ inputs.version }}"
138+
jq -n \
139+
--arg name "$NAME" \
140+
--arg version "$INPUT_VERSION" \
141+
--arg description "Static assets for the ComfyUI Desktop UI" \
142+
--arg license "$ROOT_LICENSE" \
143+
--arg repository "$REPO" \
144+
'{
145+
name: $name,
146+
version: $version,
147+
description: $description,
148+
license: $license,
149+
repository: $repository,
150+
type: "module",
151+
private: false,
152+
files: ["dist"],
153+
publishConfig: { access: "public" }
154+
}' > "$PUBLISH_DIR/package.json"
155+
156+
if [ -f apps/desktop-ui/README.md ]; then
157+
cp apps/desktop-ui/README.md "$PUBLISH_DIR/README.md"
158+
fi
159+
160+
echo "publish_dir=$PUBLISH_DIR" >> "$GITHUB_OUTPUT"
161+
echo "name=$NAME" >> "$GITHUB_OUTPUT"
162+
163+
- name: Pack (preview only)
164+
shell: bash
165+
working-directory: ${{ steps.pkg.outputs.publish_dir }}
166+
run: |
167+
set -euo pipefail
168+
npm pack --json | tee pack-result.json
169+
170+
- name: Upload package tarball artifact
171+
uses: actions/upload-artifact@v4
172+
with:
173+
name: desktop-ui-npm-tarball-${{ inputs.version }}
174+
path: ${{ steps.pkg.outputs.publish_dir }}/*.tgz
175+
if-no-files-found: error
176+
177+
- name: Check if version already on npm
178+
id: check_npm
179+
env:
180+
NAME: ${{ steps.pkg.outputs.name }}
181+
VER: ${{ inputs.version }}
182+
shell: bash
183+
run: |
184+
set -euo pipefail
185+
STATUS=0
186+
OUTPUT=$(npm view "${NAME}@${VER}" --json 2>&1) || STATUS=$?
187+
if [ "$STATUS" -eq 0 ]; then
188+
echo "exists=true" >> "$GITHUB_OUTPUT"
189+
echo "::warning title=Already published::${NAME}@${VER} already exists on npm. Skipping publish."
190+
else
191+
if echo "$OUTPUT" | grep -q "E404"; then
192+
echo "exists=false" >> "$GITHUB_OUTPUT"
193+
else
194+
echo "::error title=Registry lookup failed::$OUTPUT" >&2
195+
exit "$STATUS"
196+
fi
197+
fi
198+
199+
- name: Publish package
200+
if: steps.check_npm.outputs.exists == 'false'
201+
env:
202+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
203+
DIST_TAG: ${{ inputs.dist_tag }}
204+
run: pnpm publish --access public --tag "$DIST_TAG" --no-git-checks --ignore-scripts
205+
working-directory: ${{ steps.pkg.outputs.publish_dir }}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Version Bump Desktop UI
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_type:
7+
description: 'Version increment type'
8+
required: true
9+
default: 'patch'
10+
type: 'choice'
11+
options: [patch, minor, major, prepatch, preminor, premajor, prerelease]
12+
pre_release:
13+
description: Pre-release ID (suffix)
14+
required: false
15+
default: ''
16+
type: string
17+
18+
jobs:
19+
bump-version-desktop-ui:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: write
23+
pull-requests: write
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v5
28+
with:
29+
persist-credentials: false
30+
31+
- name: Install pnpm
32+
uses: pnpm/action-setup@v4
33+
with:
34+
version: 10
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v5
38+
with:
39+
node-version: '24.x'
40+
cache: 'pnpm'
41+
42+
- name: Bump desktop-ui version
43+
id: bump-version
44+
env:
45+
VERSION_TYPE: ${{ github.event.inputs.version_type }}
46+
PRE_RELEASE: ${{ github.event.inputs.pre_release }}
47+
run: |
48+
pnpm -C apps/desktop-ui version "$VERSION_TYPE" --preid "$PRE_RELEASE" --no-git-tag-version
49+
NEW_VERSION=$(node -p "require('./apps/desktop-ui/package.json').version")
50+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
51+
52+
- name: Format PR string
53+
id: capitalised
54+
env:
55+
VERSION_TYPE: ${{ github.event.inputs.version_type }}
56+
run: |
57+
echo "capitalised=${VERSION_TYPE@u}" >> $GITHUB_OUTPUT
58+
59+
- name: Create Pull Request
60+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e
61+
with:
62+
token: ${{ secrets.PR_GH_TOKEN }}
63+
commit-message: '[release] Increment desktop-ui to ${{ steps.bump-version.outputs.NEW_VERSION }}'
64+
title: desktop-ui ${{ steps.bump-version.outputs.NEW_VERSION }}
65+
body: |
66+
${{ steps.capitalised.outputs.capitalised }} version increment for @comfyorg/desktop-ui to ${{ steps.bump-version.outputs.NEW_VERSION }}
67+
branch: desktop-ui-version-bump-${{ steps.bump-version.outputs.NEW_VERSION }}
68+
base: main
69+
labels: |
70+
Release
71+

0 commit comments

Comments
 (0)