|
| 1 | +name: Post Release Summary Comment |
| 2 | +description: Post or update a PR comment summarizing release links with diff, derived versions, and optional extras. |
| 3 | +author: ComfyUI Frontend Team |
| 4 | + |
| 5 | +inputs: |
| 6 | + issue-number: |
| 7 | + description: Optional PR number override (defaults to the current pull request) |
| 8 | + default: '' |
| 9 | + version_file: |
| 10 | + description: Path to the JSON file containing the current version (relative to repo root) |
| 11 | + required: true |
| 12 | + |
| 13 | +outputs: |
| 14 | + prev_version: |
| 15 | + description: Previous version derived from the parent commit |
| 16 | + value: ${{ steps.build.outputs.prev_version }} |
| 17 | + |
| 18 | +runs: |
| 19 | + using: composite |
| 20 | + steps: |
| 21 | + - name: Build comment body |
| 22 | + id: build |
| 23 | + shell: bash |
| 24 | + run: | |
| 25 | + set -euo pipefail |
| 26 | +
|
| 27 | + VERSION_FILE="${{ inputs.version_file }}" |
| 28 | + REPO="${{ github.repository }}" |
| 29 | +
|
| 30 | + if [[ -z "$VERSION_FILE" ]]; then |
| 31 | + echo '::error::version_file input is required' >&2 |
| 32 | + exit 1 |
| 33 | + fi |
| 34 | +
|
| 35 | + PREV_JSON=$(git show HEAD^1:"$VERSION_FILE" 2>/dev/null || true) |
| 36 | + if [[ -z "$PREV_JSON" ]]; then |
| 37 | + echo "::error::Unable to read $VERSION_FILE from parent commit" >&2 |
| 38 | + exit 1 |
| 39 | + fi |
| 40 | + PREV_VERSION=$(printf '%s' "$PREV_JSON" | node -pe "const data = JSON.parse(require('fs').readFileSync(0, 'utf8')); if (!data.version) { process.exit(1); } data.version") |
| 41 | + if [[ -z "$PREV_VERSION" ]]; then |
| 42 | + echo "::error::Unable to determine previous version from $VERSION_FILE" >&2 |
| 43 | + exit 1 |
| 44 | + fi |
| 45 | +
|
| 46 | + NEW_VERSION=$(node -pe "const fs=require('fs');const data=JSON.parse(fs.readFileSync(process.argv[1],'utf8'));if(!data.version){process.exit(1);}data.version" "$VERSION_FILE") |
| 47 | + if [[ -z "$NEW_VERSION" ]]; then |
| 48 | + echo "::error::Unable to determine current version from $VERSION_FILE" >&2 |
| 49 | + exit 1 |
| 50 | + fi |
| 51 | +
|
| 52 | + MARKER='release-summary' |
| 53 | + MESSAGE='Publish jobs finished successfully:' |
| 54 | + LINKS_VALUE='' |
| 55 | +
|
| 56 | + case "$VERSION_FILE" in |
| 57 | + package.json) |
| 58 | + LINKS_VALUE=$'PyPI|https://pypi.org/project/comfyui-frontend-package/{{version}}/\n''npm types|https://npm.im/@comfyorg/comfyui-frontend-types@{{version}}' |
| 59 | + ;; |
| 60 | + apps/desktop-ui/package.json) |
| 61 | + MARKER='desktop-release-summary' |
| 62 | + LINKS_VALUE='npm desktop UI|https://npm.im/@comfyorg/desktop-ui@{{version}}' |
| 63 | + ;; |
| 64 | + esac |
| 65 | +
|
| 66 | + DIFF_PREFIX='v' |
| 67 | + DIFF_LABEL='Diff' |
| 68 | + DIFF_URL="https://github.com/${REPO}/compare/${DIFF_PREFIX}${PREV_VERSION}...${DIFF_PREFIX}${NEW_VERSION}" |
| 69 | + COMMENT_FILE=$(mktemp) |
| 70 | +
|
| 71 | + { |
| 72 | + printf '<!--%s:%s%s-->\n' "$MARKER" "$DIFF_PREFIX" "$NEW_VERSION" |
| 73 | + printf '%s\n\n' "$MESSAGE" |
| 74 | + printf -- '- %s: [%s%s...%s%s](%s)\n' "$DIFF_LABEL" "$DIFF_PREFIX" "$PREV_VERSION" "$DIFF_PREFIX" "$NEW_VERSION" "$DIFF_URL" |
| 75 | +
|
| 76 | + while IFS= read -r RAW_LINE; do |
| 77 | + LINE=$(printf '%s' "$RAW_LINE" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') |
| 78 | + [[ -z "$LINE" ]] && continue |
| 79 | + if [[ "$LINE" != *"|"* ]]; then |
| 80 | + echo "::warning::Skipping malformed link entry: $LINE" >&2 |
| 81 | + continue |
| 82 | + fi |
| 83 | + LABEL=${LINE%%|*} |
| 84 | + URL_TEMPLATE=${LINE#*|} |
| 85 | + URL=${URL_TEMPLATE//\{\{version\}\}/$NEW_VERSION} |
| 86 | + URL=${URL//\{\{prev_version\}\}/$PREV_VERSION} |
| 87 | + printf -- '- %s: %s\n' "$LABEL" "$URL" |
| 88 | + done <<< "$LINKS_VALUE" |
| 89 | +
|
| 90 | + printf '\n' |
| 91 | + } > "$COMMENT_FILE" |
| 92 | +
|
| 93 | + { |
| 94 | + echo "body<<'EOF'" |
| 95 | + cat "$COMMENT_FILE" |
| 96 | + echo 'EOF' |
| 97 | + } >> "$GITHUB_OUTPUT" |
| 98 | + echo "prev_version=$PREV_VERSION" >> "$GITHUB_OUTPUT" |
| 99 | + echo "marker_search=<!--$MARKER:" >> "$GITHUB_OUTPUT" |
| 100 | + echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT" |
| 101 | +
|
| 102 | + - name: Find existing comment |
| 103 | + id: find |
| 104 | + uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad |
| 105 | + with: |
| 106 | + issue-number: ${{ inputs.issue-number || github.event.pull_request.number }} |
| 107 | + comment-author: github-actions[bot] |
| 108 | + body-includes: ${{ steps.build.outputs.marker_search }} |
| 109 | + |
| 110 | + - name: Post or update comment |
| 111 | + uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 |
| 112 | + with: |
| 113 | + issue-number: ${{ inputs.issue-number || github.event.pull_request.number }} |
| 114 | + comment-id: ${{ steps.find.outputs.comment-id }} |
| 115 | + body: ${{ steps.build.outputs.body }} |
| 116 | + edit-mode: replace |
0 commit comments