Skip to content

Commit 809b452

Browse files
committed
refactor(plugins): resolve tags from remote, verify both arches, and refuse cross-ABI release overwrites (#1380)
1 parent dd95309 commit 809b452

2 files changed

Lines changed: 25 additions & 17 deletions

File tree

.github/workflows/build-plugin.yml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -252,19 +252,21 @@ jobs:
252252
run: |
253253
BUNDLE_NAME="${{ steps.plugin.outputs.bundleName }}"
254254
EXPECTED="${{ matrix.pluginKitVersion }}"
255-
WORK=$(mktemp -d)
256-
unzip -oq "build/Plugins/${BUNDLE_NAME}-arm64.zip" -d "$WORK"
257-
PLIST=$(find "$WORK" -path '*.tableplugin/Contents/Info.plist' | head -1)
258-
if [ -z "$PLIST" ]; then
259-
echo "::error::Could not find Info.plist in the built ${BUNDLE_NAME} bundle."
260-
exit 1
261-
fi
262-
ACTUAL=$(plutil -extract TableProPluginKitVersion raw "$PLIST")
263-
if [ "$ACTUAL" != "$EXPECTED" ]; then
264-
echo "::error::${BUNDLE_NAME} was built for PluginKit $ACTUAL but this release is labeled PluginKit $EXPECTED. Refusing to publish a mislabeled binary. Re-release from a commit whose plugin Info.plist matches the target PluginKit version."
265-
exit 1
266-
fi
267-
echo "Verified ${BUNDLE_NAME}: built PluginKit $ACTUAL matches the release label."
255+
for ARCH in arm64 x86_64; do
256+
WORK=$(mktemp -d)
257+
unzip -oq "build/Plugins/${BUNDLE_NAME}-${ARCH}.zip" -d "$WORK"
258+
PLIST=$(find "$WORK" -path '*.tableplugin/Contents/Info.plist' | head -1)
259+
if [ -z "$PLIST" ]; then
260+
echo "::error::Could not find Info.plist in the built ${BUNDLE_NAME}-${ARCH} bundle."
261+
exit 1
262+
fi
263+
ACTUAL=$(plutil -extract TableProPluginKitVersion raw "$PLIST")
264+
if [ "$ACTUAL" != "$EXPECTED" ]; then
265+
echo "::error::${BUNDLE_NAME}-${ARCH} was built for PluginKit $ACTUAL but this release is labeled PluginKit $EXPECTED. Refusing to publish a mislabeled binary. Re-release from a commit whose plugin Info.plist matches the target PluginKit version."
266+
exit 1
267+
fi
268+
echo "Verified ${BUNDLE_NAME}-${ARCH}: built PluginKit $ACTUAL matches the release label."
269+
done
268270
269271
- name: Read checksums
270272
id: sha
@@ -308,6 +310,13 @@ jobs:
308310
- ARM64: \`$ARM64_SHA\`
309311
- x86_64: \`$X86_SHA\`"
310312
313+
EXISTING_PKV=$(gh release view "$TAG" --json body --jq .body 2>/dev/null \
314+
| grep -oiE 'PluginKit [0-9]+' | grep -oE '[0-9]+' | head -1 || true)
315+
if [ -n "$EXISTING_PKV" ] && [ "$EXISTING_PKV" != "$PKV" ]; then
316+
echo "::error::Release $TAG already exists for PluginKit $EXISTING_PKV. Refusing to overwrite it with PluginKit $PKV; publish the new ABI under a new plugin version."
317+
exit 1
318+
fi
319+
311320
gh release delete "$TAG" --yes 2>/dev/null || true
312321
gh release create "$TAG" \
313322
--title "$DISPLAY_NAME v$VERSION" \

scripts/release-all-plugins.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,14 @@ for PLUGIN in "${PLUGINS[@]}"; do
6363
done
6464
done
6565

66-
git fetch --tags --quiet origin 2>/dev/null || true
67-
6866
TAG_LIST=""
6967
FIRST=true
7068
echo "Resolving next release version for each plugin (PluginKit $PKV):"
7169
for PLUGIN in "${PLUGINS[@]}"; do
72-
LATEST_TAG=$(git tag -l "plugin-${PLUGIN}-v*" | sort -V | tail -1)
70+
LATEST_TAG=$(git ls-remote --tags --refs origin "plugin-${PLUGIN}-v*" \
71+
| sed 's#.*/##' | sort -V | tail -1)
7372
if [ -z "$LATEST_TAG" ]; then
74-
echo " WARNING: No tag found for plugin-${PLUGIN}-v*. Skipping."
73+
echo " WARNING: No remote tag found for plugin-${PLUGIN}-v*. Skipping."
7574
continue
7675
fi
7776
LATEST_VER="${LATEST_TAG#plugin-${PLUGIN}-v}"

0 commit comments

Comments
 (0)