Skip to content

Commit a926f6c

Browse files
juleswg23claudedotNomad
authored
ci: add release comment if extension is changed but manifest not upgraded (#342)
* Refactor pr-release-comment to use release-check artifacts Instead of duplicating version comparison logic, the pr-release-comment job now reads release-check-*.json artifacts emitted by release-extension. This keeps the version logic in one place. Changes: - release-extension action now writes release-check JSON inline at each decision point (will release / holding back / 0.0.0) - pr-release-comment depends on release jobs instead of change-detection jobs, and aggregates the artifacts with jq Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * make comment more accurate * test: trigger reaper extension without version bump * fix: rename artifact to would-release to avoid collision with release-*.json pattern * change landing page instead of reaper * CI test: change second app without updating manifest * 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> * revert README test changes Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Jordan Jensen <jordan.jensen@posit.co>
1 parent b943eb1 commit a926f6c

2 files changed

Lines changed: 107 additions & 10 deletions

File tree

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

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,17 @@ runs:
3838
# We compare that here, and echo if a release will occur
3939
# This can be helpful when looking at Pull Request action outputs
4040
# so it is clear what will happen on a merge to `main`
41+
# Also writes release-check JSON for PR comment aggregation
4142
- name: Check if manifest has newer version
4243
id: should_release
4344
run: |
4445
# Add the extension name to the summary header for clarity
4546
echo "# Extension: ${{ inputs.extension-name }}" >> $GITHUB_STEP_SUMMARY
4647
echo "" >> $GITHUB_STEP_SUMMARY
47-
48+
4849
if [ "$MANIFEST_VERSION" = "0.0.0" ]; then
4950
MESSAGE="⚠️ Version 0.0.0 is reserved and will never be released."
50-
echo "$MESSAGE"
51-
echo "$MESSAGE" >> $GITHUB_STEP_SUMMARY
52-
echo "should_release=false" >> "$GITHUB_OUTPUT"
51+
SHOULD_RELEASE=false
5352
else
5453
# Normal version comparison logic
5554
VERSION_INFO="The manifest version is '$MANIFEST_VERSION' and the released version is '$LATEST_VERSION'"
@@ -60,16 +59,24 @@ runs:
6059
HIGHER_VERSION=$(semver "$MANIFEST_VERSION" "$LATEST_VERSION" | tail -n 1)
6160
if [ "$MANIFEST_VERSION" = "$HIGHER_VERSION" ] && [ "$MANIFEST_VERSION" != "$LATEST_VERSION" ]; then
6261
MESSAGE="🚀 Will release! The manifest version is greater than the released version."
63-
echo "$MESSAGE"
64-
echo "$MESSAGE" >> $GITHUB_STEP_SUMMARY
65-
echo "should_release=true" >> "$GITHUB_OUTPUT"
62+
SHOULD_RELEASE=true
6663
else
6764
MESSAGE="😴 Holding back from release: The manifest version is not greater than the released version."
68-
echo "$MESSAGE"
69-
echo "$MESSAGE" >> $GITHUB_STEP_SUMMARY
70-
echo "should_release=false" >> "$GITHUB_OUTPUT"
65+
SHOULD_RELEASE=false
7166
fi
7267
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
7380
shell: bash
7481

7582
# Here we download the packaged extension artifact to release
@@ -113,3 +120,13 @@ runs:
113120
name: release-${{ inputs.extension-name }}.json
114121
path: release-${{ inputs.extension-name }}.json
115122
retention-days: 1
123+
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.
126+
- name: Upload release check data
127+
if: github.event_name == 'pull_request' && env.MANIFEST_VERSION != '0.0.0'
128+
uses: actions/upload-artifact@v4
129+
with:
130+
name: would-release-${{ inputs.extension-name }}.json
131+
path: would-release-${{ inputs.extension-name }}.json
132+
retention-days: 1

.github/workflows/extensions.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,86 @@ jobs:
248248
# All extensions have been linted, packaged, and released, if necessary
249249
# Continuing to update the extension list with the latest release data
250250

251+
# Comments on PRs when extensions won't release (to help contributors notice they need to bump version)
252+
pr-release-comment:
253+
runs-on: ubuntu-latest
254+
if: always() && github.event_name == 'pull_request'
255+
needs: [
256+
simple-extension-release,
257+
publisher-command-center,
258+
package-vulnerability-scanner,
259+
runtime-version-scanner,
260+
usage-metrics-dashboard,
261+
]
262+
permissions:
263+
pull-requests: write
264+
env:
265+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
266+
steps:
267+
- name: Download release check artifacts
268+
uses: actions/download-artifact@v4
269+
with:
270+
pattern: would-release-*.json
271+
path: would-release
272+
merge-multiple: true
273+
274+
- name: Post or update PR comment
275+
run: |
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.
279+
if [ ! -d "would-release" ] || [ -z "$(ls -A would-release 2>/dev/null)" ]; then
280+
echo "No extensions changed - no comment needed"
281+
exit 0
282+
fi
283+
284+
MARKER="<!-- release-check-comment -->"
285+
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)
288+
289+
COMMENT_BODY="${MARKER}
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
304+
305+
The following extensions have code changes but the manifest version hasn't been incremented:
306+
307+
${WONT_RELEASE}
308+
309+
If you intended to release these changes, update the \`version\` field in each extension's \`manifest.json\`.
310+
"
311+
fi
312+
313+
COMMENT_BODY+="
314+
See the [contributing guide](https://github.com/posit-dev/connect-extensions/blob/main/CONTRIBUTING.md#updating-content-in-the-connect-gallery) for details."
315+
316+
# Check for existing comment with marker
317+
EXISTING_COMMENT_ID=$(gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
318+
--jq ".[] | select(.body | contains(\"$MARKER\")) | .id" | head -1)
319+
320+
if [ -n "$EXISTING_COMMENT_ID" ]; then
321+
echo "Updating existing comment (ID: $EXISTING_COMMENT_ID)..."
322+
gh api "repos/${{ github.repository }}/issues/comments/$EXISTING_COMMENT_ID" \
323+
-X PATCH \
324+
-f body="$COMMENT_BODY"
325+
else
326+
echo "Creating new comment..."
327+
gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
328+
-f body="$COMMENT_BODY"
329+
fi
330+
251331
# Gathers all release data from GitHub releases triggered by this workflow
252332
# For use in the `update-extension-list` job
253333
# If no releases were triggered the output for releases will be `[]`

0 commit comments

Comments
 (0)