Skip to content

Commit ee40fc8

Browse files
authored
fix(ci): use github-script for wheel pruning instead of gh CLI (#354)
1 parent 0792dcb commit ee40fc8

File tree

1 file changed

+43
-21
lines changed

1 file changed

+43
-21
lines changed

.github/workflows/release-dev.yml

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -328,29 +328,51 @@ jobs:
328328
cat openshell-checksums-sha256.txt
329329
330330
- name: Prune stale wheel assets from devel release
331+
uses: actions/github-script@v7
331332
env:
332-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
333333
WHEEL_VERSION: ${{ needs.build-python-wheels.outputs.wheel_version }}
334-
run: |
335-
set -euo pipefail
336-
CURRENT_PREFIX="openshell-${WHEEL_VERSION}-"
337-
338-
if ! gh release view devel --repo "${GITHUB_REPOSITORY}" --json assets > /dev/null 2>&1; then
339-
echo "No existing devel release found; skipping wheel pruning."
340-
exit 0
341-
fi
342-
343-
gh release view devel --repo "${GITHUB_REPOSITORY}" --json assets --jq '.assets[].name' \
344-
| while read -r asset; do
345-
case "$asset" in
346-
*.whl)
347-
if [[ "$asset" != "${CURRENT_PREFIX}"* ]]; then
348-
echo "Deleting stale wheel asset: $asset"
349-
gh release delete-asset devel "$asset" --repo "${GITHUB_REPOSITORY}" --yes
350-
fi
351-
;;
352-
esac
353-
done
334+
with:
335+
script: |
336+
const wheelVersion = process.env.WHEEL_VERSION;
337+
const currentPrefix = `openshell-${wheelVersion}-`;
338+
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
339+
340+
core.info(`=== Wheel pruning diagnostics ===`);
341+
core.info(`WHEEL_VERSION: ${wheelVersion}`);
342+
core.info(`CURRENT_PREFIX: ${currentPrefix}`);
343+
344+
// Fetch the devel release
345+
let release;
346+
try {
347+
release = await github.rest.repos.getReleaseByTag({ owner, repo, tag: 'devel' });
348+
} catch (err) {
349+
if (err.status === 404) {
350+
core.info('No existing devel release found; skipping wheel pruning.');
351+
return;
352+
}
353+
throw err;
354+
}
355+
356+
const assets = release.data.assets;
357+
core.info(`=== Current devel release assets (${assets.length} total) ===`);
358+
for (const a of assets) {
359+
core.info(` ${String(a.id).padStart(12)} ${a.name}`);
360+
}
361+
362+
// Delete stale wheels
363+
let kept = 0, deleted = 0;
364+
for (const asset of assets) {
365+
if (!asset.name.endsWith('.whl')) continue;
366+
if (asset.name.startsWith(currentPrefix)) {
367+
core.info(`Keeping current wheel: ${asset.name}`);
368+
kept++;
369+
} else {
370+
core.info(`Deleting stale wheel: ${asset.name} (id=${asset.id})`);
371+
await github.rest.repos.deleteReleaseAsset({ owner, repo, asset_id: asset.id });
372+
deleted++;
373+
}
374+
}
375+
core.info(`Summary: kept=${kept}, deleted=${deleted}`);
354376
355377
- name: Move devel tag
356378
run: |

0 commit comments

Comments
 (0)