Skip to content

Commit eb3fbf4

Browse files
dotNomadclaude
andauthored
refactor: simplify release-check pipeline and summarize will-release (#343)
- Consolidate the should_release step in the release-extension action: single message/output/JSON emission instead of a 3-branch helper, and use jq -n for safer JSON construction. - Gate release-check artifact upload at the action level (PRs, non-0.0.0), dropping the filter that used to live downstream. - Merge the aggregate + comment workflow steps into one; no intermediate no_release.json, no duplicate empty-check. - Expand the PR comment to summarize both will-release and won't-release extensions so contributors can confirm what will release on merge. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0063c00 commit eb3fbf4

2 files changed

Lines changed: 44 additions & 41 deletions

File tree

.github/actions/release-extension/action.yml

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,9 @@ runs:
4646
echo "# Extension: ${{ inputs.extension-name }}" >> $GITHUB_STEP_SUMMARY
4747
echo "" >> $GITHUB_STEP_SUMMARY
4848
49-
# Helper to write release check artifact
50-
write_release_check() {
51-
echo "{\"name\": \"${{ inputs.extension-name }}\", \"manifestVersion\": \"$MANIFEST_VERSION\", \"latestVersion\": \"$LATEST_VERSION\", \"wouldRelease\": $1}" \
52-
> would-release-${{ inputs.extension-name }}.json
53-
}
54-
5549
if [ "$MANIFEST_VERSION" = "0.0.0" ]; then
5650
MESSAGE="⚠️ Version 0.0.0 is reserved and will never be released."
57-
echo "$MESSAGE"
58-
echo "$MESSAGE" >> $GITHUB_STEP_SUMMARY
59-
echo "should_release=false" >> "$GITHUB_OUTPUT"
60-
write_release_check false
51+
SHOULD_RELEASE=false
6152
else
6253
# Normal version comparison logic
6354
VERSION_INFO="The manifest version is '$MANIFEST_VERSION' and the released version is '$LATEST_VERSION'"
@@ -68,18 +59,24 @@ runs:
6859
HIGHER_VERSION=$(semver "$MANIFEST_VERSION" "$LATEST_VERSION" | tail -n 1)
6960
if [ "$MANIFEST_VERSION" = "$HIGHER_VERSION" ] && [ "$MANIFEST_VERSION" != "$LATEST_VERSION" ]; then
7061
MESSAGE="🚀 Will release! The manifest version is greater than the released version."
71-
echo "$MESSAGE"
72-
echo "$MESSAGE" >> $GITHUB_STEP_SUMMARY
73-
echo "should_release=true" >> "$GITHUB_OUTPUT"
74-
write_release_check true
62+
SHOULD_RELEASE=true
7563
else
7664
MESSAGE="😴 Holding back from release: The manifest version is not greater than the released version."
77-
echo "$MESSAGE"
78-
echo "$MESSAGE" >> $GITHUB_STEP_SUMMARY
79-
echo "should_release=false" >> "$GITHUB_OUTPUT"
80-
write_release_check false
65+
SHOULD_RELEASE=false
8166
fi
8267
fi
68+
69+
echo "$MESSAGE"
70+
echo "$MESSAGE" >> $GITHUB_STEP_SUMMARY
71+
echo "should_release=$SHOULD_RELEASE" >> "$GITHUB_OUTPUT"
72+
73+
jq -n \
74+
--arg name "${{ inputs.extension-name }}" \
75+
--arg manifest "$MANIFEST_VERSION" \
76+
--arg latest "$LATEST_VERSION" \
77+
--argjson would "$SHOULD_RELEASE" \
78+
'{name: $name, manifestVersion: $manifest, latestVersion: $latest, wouldRelease: $would}' \
79+
> would-release-${{ inputs.extension-name }}.json
8380
shell: bash
8481

8582
# Here we download the packaged extension artifact to release
@@ -124,8 +121,10 @@ runs:
124121
path: release-${{ inputs.extension-name }}.json
125122
retention-days: 1
126123

127-
# Upload release check artifact for PR comment aggregation
124+
# Upload on PRs for any non-reserved extension so the downstream comment
125+
# job can summarize both will-release and won't-release extensions.
128126
- name: Upload release check data
127+
if: github.event_name == 'pull_request' && env.MANIFEST_VERSION != '0.0.0'
129128
uses: actions/upload-artifact@v4
130129
with:
131130
name: would-release-${{ inputs.extension-name }}.json

.github/workflows/extensions.yml

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -271,42 +271,46 @@ jobs:
271271
path: would-release
272272
merge-multiple: true
273273

274-
- name: Aggregate release check data
274+
- name: Post or update PR comment
275275
run: |
276-
# If no release checks exist, no extensions were processed
276+
# Artifacts are only uploaded by the release-extension action for
277+
# extensions that changed (and aren't reserved 0.0.0), so an empty
278+
# download directory means there's nothing to comment on.
277279
if [ ! -d "would-release" ] || [ -z "$(ls -A would-release 2>/dev/null)" ]; then
278-
echo "[]" > no_release.json
280+
echo "No extensions changed - no comment needed"
279281
exit 0
280282
fi
281283
282-
# Filter to extensions that won't release (wouldRelease: false, excluding 0.0.0)
283-
jq -s '[.[] | select(.wouldRelease == false and .manifestVersion != "0.0.0")]' \
284-
would-release/*.json > no_release.json
285-
286-
- name: Post or update PR comment
287-
run: |
288284
MARKER="<!-- release-check-comment -->"
289-
NO_RELEASE=$(cat no_release.json)
290-
291-
# Exit if no extensions need commenting
292-
if [ "$NO_RELEASE" = "[]" ] || [ -z "$NO_RELEASE" ]; then
293-
echo "All changed extensions will release - no comment needed"
294-
exit 0
295-
fi
296285
297-
# Build the extension list
298-
EXTENSION_LIST=$(echo "$NO_RELEASE" | jq -r '.[] | "- **\(.name)**: manifest version `\(.manifestVersion)` ≤ released version `\(.latestVersion)`"')
286+
WILL_RELEASE=$(jq -r 'select(.wouldRelease) | "- **\(.name)**: `\(.latestVersion)` → `\(.manifestVersion)`"' would-release/*.json)
287+
WONT_RELEASE=$(jq -r 'select(.wouldRelease | not) | "- **\(.name)**: manifest version `\(.manifestVersion)` ≤ released version `\(.latestVersion)`"' would-release/*.json)
299288
300-
# Build comment body
301289
COMMENT_BODY="${MARKER}
302-
## 😴 Extensions changed but won't release
290+
## Extension release summary
291+
"
292+
293+
if [ -n "$WILL_RELEASE" ]; then
294+
COMMENT_BODY+="
295+
### 🚀 Will release on merge
296+
297+
${WILL_RELEASE}
298+
"
299+
fi
300+
301+
if [ -n "$WONT_RELEASE" ]; then
302+
COMMENT_BODY+="
303+
### 😴 Changed but won't release
303304
304-
The following extensions have code changes but the manifest version hasn't been incremented, so they won't be released when this PR merges:
305+
The following extensions have code changes but the manifest version hasn't been incremented:
305306
306-
${EXTENSION_LIST}
307+
${WONT_RELEASE}
307308
308309
If you intended to release these changes, update the \`version\` field in each extension's \`manifest.json\`.
310+
"
311+
fi
309312
313+
COMMENT_BODY+="
310314
See the [contributing guide](https://github.com/posit-dev/connect-extensions/blob/main/CONTRIBUTING.md#updating-content-in-the-connect-gallery) for details."
311315
312316
# Check for existing comment with marker

0 commit comments

Comments
 (0)