Release-Workflow: Paketprüfung und Release-Anlage gegen SIGPIPE absichern
Some checks failed
CI / PHP Lint (push) Successful in 39s
CI / PHP Lint-1 (push) Successful in 1m0s
CI / Unit Tests & Static Analysis (push) Failing after 31s
CI / PHP Lint (pull_request) Successful in 37s
CI / PHP Lint-1 (pull_request) Successful in 1m14s
CI / Unit Tests & Static Analysis (pull_request) Successful in 42s
Some checks failed
CI / PHP Lint (push) Successful in 39s
CI / PHP Lint-1 (push) Successful in 1m0s
CI / Unit Tests & Static Analysis (push) Failing after 31s
CI / PHP Lint (pull_request) Successful in 37s
CI / PHP Lint-1 (pull_request) Successful in 1m14s
CI / Unit Tests & Static Analysis (pull_request) Successful in 42s
Der erste Lauf auf dem neuen Runner scheiterte an der eigenen Prüfung:
"Fehlt im Paket: assets/global.css", obwohl die Datei im ZIP liegt.
Ursache ist "unzip -l | grep -q" je Datei. grep beendet sich beim ersten
Treffer, unzip stirbt an SIGPIPE, und weil der Runner die Schritte mit
pipefail ausführt, gilt die Prüfung als fehlgeschlagen – aber nur für
Dateien, die früh in der Liste stehen. index.php und install.php liegen
am Ende und kamen deshalb durch.
Jetzt wird die Dateiliste einmal erzeugt und danach nur noch in der
Datei gesucht. Zusätzlich wird geprüft, dass LICENSE und
THIRD-PARTY-NOTICES.md enthalten sind und tests/, tools/, docs/ sowie
.github/ eben nicht.
Dieselbe Falle steckte in der Release-Anlage ("curl | grep | head -1"):
umgestellt auf Antwort in eine Datei und "grep -m1". Schlägt das Anlegen
fehl, steht die Antwort der API jetzt im Log.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
f5081a4b11
commit
d2407c57c1
1 changed files with 45 additions and 7 deletions
52
.github/workflows/release.yml
vendored
52
.github/workflows/release.yml
vendored
|
|
@ -65,21 +65,45 @@ jobs:
|
||||||
- name: Inhalt kurz prüfen
|
- name: Inhalt kurz prüfen
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
|
# Die Dateiliste einmal erzeugen und danach nur noch darin suchen.
|
||||||
|
# Frueher lief hier "unzip -l | grep -q" je Datei: grep beendet sich
|
||||||
|
# beim ersten Treffer, unzip stirbt an SIGPIPE, und mit pipefail galt
|
||||||
|
# die Pruefung als fehlgeschlagen - aber nur fuer Dateien, die frueh
|
||||||
|
# in der Liste stehen.
|
||||||
|
unzip -Z1 "dist/${{ steps.meta.outputs.name }}.zip" > /tmp/zip-inhalt.txt
|
||||||
|
|
||||||
# Ein paar Dateien muessen enthalten sein, sonst ist das Paket kaputt.
|
# Ein paar Dateien muessen enthalten sein, sonst ist das Paket kaputt.
|
||||||
for required in \
|
for required in \
|
||||||
unifi-voucher-tool/index.php \
|
unifi-voucher-tool/index.php \
|
||||||
unifi-voucher-tool/install.php \
|
unifi-voucher-tool/install.php \
|
||||||
unifi-voucher-tool/database.sql \
|
unifi-voucher-tool/database.sql \
|
||||||
|
unifi-voucher-tool/LICENSE \
|
||||||
|
unifi-voucher-tool/THIRD-PARTY-NOTICES.md \
|
||||||
unifi-voucher-tool/assets/global.css \
|
unifi-voucher-tool/assets/global.css \
|
||||||
unifi-voucher-tool/assets/vendor/inter/inter.css \
|
unifi-voucher-tool/assets/vendor/inter/inter.css \
|
||||||
|
unifi-voucher-tool/assets/vendor/inter/LICENSE.txt \
|
||||||
unifi-voucher-tool/includes/Ui.php
|
unifi-voucher-tool/includes/Ui.php
|
||||||
do
|
do
|
||||||
if ! unzip -l "dist/${{ steps.meta.outputs.name }}.zip" | grep -q "$required"; then
|
if ! grep -Fxq "$required" /tmp/zip-inhalt.txt; then
|
||||||
echo "Fehlt im Paket: $required" >&2
|
echo "Fehlt im Paket: $required" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "Paket vollständig."
|
|
||||||
|
# Und umgekehrt: Entwicklungsdateien haben im Paket nichts verloren.
|
||||||
|
for forbidden in \
|
||||||
|
unifi-voucher-tool/tests/ \
|
||||||
|
unifi-voucher-tool/tools/ \
|
||||||
|
unifi-voucher-tool/docs/ \
|
||||||
|
unifi-voucher-tool/.github/
|
||||||
|
do
|
||||||
|
if grep -Fq "$forbidden" /tmp/zip-inhalt.txt; then
|
||||||
|
echo "Gehoert nicht ins Paket: $forbidden" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Paket vollständig ($(wc -l < /tmp/zip-inhalt.txt) Dateien)."
|
||||||
|
|
||||||
- name: Als Build-Artefakt sichern
|
- name: Als Build-Artefakt sichern
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
|
|
@ -112,9 +136,16 @@ jobs:
|
||||||
|
|
||||||
# Rollendes Vorab-Release durch ein frisches ersetzen, damit der
|
# Rollendes Vorab-Release durch ein frisches ersetzen, damit der
|
||||||
# Download-Link stabil bleibt und auf den aktuellen Stand zeigt.
|
# Download-Link stabil bleibt und auf den aktuellen Stand zeigt.
|
||||||
|
# Hinweis: Pipelines hier bewusst ohne "head -1" hinter curl/grep.
|
||||||
|
# Beendet sich das letzte Glied frueher, stirbt das erste an SIGPIPE
|
||||||
|
# und der Schritt bricht ab (pipefail). "grep -m1" auf einer Datei
|
||||||
|
# hat das Problem nicht.
|
||||||
if [ "$TAG" = "latest-main" ]; then
|
if [ "$TAG" = "latest-main" ]; then
|
||||||
OLD_ID="$(curl -sf -H "$AUTH" "${API}/releases/tags/${TAG}" \
|
curl -sf -H "$AUTH" "${API}/releases/tags/${TAG}" -o /tmp/altes-release.json || true
|
||||||
| grep -o '"id":[0-9]*' | head -1 | cut -d: -f2 || true)"
|
OLD_ID=""
|
||||||
|
if [ -s /tmp/altes-release.json ]; then
|
||||||
|
OLD_ID="$(grep -m1 -o '"id":[0-9]*' /tmp/altes-release.json | cut -d: -f2 || true)"
|
||||||
|
fi
|
||||||
if [ -n "${OLD_ID:-}" ]; then
|
if [ -n "${OLD_ID:-}" ]; then
|
||||||
curl -sf -X DELETE -H "$AUTH" "${API}/releases/${OLD_ID}" || true
|
curl -sf -X DELETE -H "$AUTH" "${API}/releases/${OLD_ID}" || true
|
||||||
curl -sf -X DELETE -H "$AUTH" "${API}/tags/${TAG}" || true
|
curl -sf -X DELETE -H "$AUTH" "${API}/tags/${TAG}" || true
|
||||||
|
|
@ -133,12 +164,19 @@ jobs:
|
||||||
BODY="${BODY}- oder gleich den eingebauten Updater unter Administration, System-Update verwenden.\n\n"
|
BODY="${BODY}- oder gleich den eingebauten Updater unter Administration, System-Update verwenden.\n\n"
|
||||||
BODY="${BODY}Pruefsumme: siehe beigelegte .sha256-Datei."
|
BODY="${BODY}Pruefsumme: siehe beigelegte .sha256-Datei."
|
||||||
|
|
||||||
RELEASE_ID="$(curl -sf -X POST -H "$AUTH" -H 'Content-Type: application/json' \
|
# ohne -f, damit bei einem Fehler die Antwort der API im Log landet
|
||||||
|
curl -s -X POST -H "$AUTH" -H 'Content-Type: application/json' \
|
||||||
-d "{\"tag_name\":\"${TAG}\",\"target_commitish\":\"${GITHUB_SHA}\",\"name\":\"${TITLE}\",\"body\":\"${BODY}\",\"draft\":false,\"prerelease\":${PRERELEASE}}" \
|
-d "{\"tag_name\":\"${TAG}\",\"target_commitish\":\"${GITHUB_SHA}\",\"name\":\"${TITLE}\",\"body\":\"${BODY}\",\"draft\":false,\"prerelease\":${PRERELEASE}}" \
|
||||||
"${API}/releases" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)"
|
"${API}/releases" -o /tmp/neues-release.json || true
|
||||||
|
|
||||||
|
RELEASE_ID=""
|
||||||
|
if [ -s /tmp/neues-release.json ]; then
|
||||||
|
RELEASE_ID="$(grep -m1 -o '"id":[0-9]*' /tmp/neues-release.json | cut -d: -f2 || true)"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "${RELEASE_ID:-}" ]; then
|
if [ -z "${RELEASE_ID:-}" ]; then
|
||||||
echo "Release konnte nicht angelegt werden." >&2
|
echo "Release konnte nicht angelegt werden:" >&2
|
||||||
|
cat /tmp/neues-release.json >&2 || true
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue