mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-10 17:02:50 +02:00
fix(ci): Fix RPM signing loops and ensure failures are caught
Replace while-read loops with for loops to avoid subshell variable scoping issues. Export GPG_TTY=/dev/null to suppress terminal warnings. Provide empty passphrase via stdin for batch signing without interaction. Both signing and verification now properly track failures and exit with non-zero status if any RPMs fail to sign or verify, preventing misleading successful pipeline runs.
This commit is contained in:
parent
b86d9c15a7
commit
4ffabfb7e1
1 changed files with 46 additions and 18 deletions
|
@ -187,42 +187,70 @@ jobs:
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Sign all binary RPMs
|
# Track signing failures
|
||||||
find "$HOME/rpmbuild/RPMS" -name "*.rpm" -type f | while read rpm; do
|
FAILED_COUNT=0
|
||||||
|
TOTAL_COUNT=0
|
||||||
|
|
||||||
|
# Export GPG_TTY to avoid terminal warnings
|
||||||
|
export GPG_TTY=/dev/null
|
||||||
|
|
||||||
|
# Sign all RPMs (binary and source)
|
||||||
|
for rpm in $(find "$HOME/rpmbuild" -name "*.rpm" -type f); do
|
||||||
echo "Signing: $(basename $rpm)"
|
echo "Signing: $(basename $rpm)"
|
||||||
rpmsign --addsign "$rpm" || echo "Warning: Failed to sign $rpm"
|
TOTAL_COUNT=$((TOTAL_COUNT + 1))
|
||||||
|
|
||||||
|
# Use expect or provide empty passphrase via stdin for batch signing
|
||||||
|
if ! echo "" | rpmsign --addsign "$rpm" 2>&1; then
|
||||||
|
echo "ERROR: Failed to sign $rpm"
|
||||||
|
FAILED_COUNT=$((FAILED_COUNT + 1))
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Sign the SRPM
|
# Fail if any RPMs failed to sign
|
||||||
find "$HOME/rpmbuild/SRPMS" -name "*.src.rpm" -type f | while read srpm; do
|
if [ "$FAILED_COUNT" -gt 0 ]; then
|
||||||
echo "Signing: $(basename $srpm)"
|
echo "ERROR: Failed to sign $FAILED_COUNT out of $TOTAL_COUNT RPMs"
|
||||||
rpmsign --addsign "$srpm" || echo "Warning: Failed to sign $srpm"
|
exit 1
|
||||||
done
|
fi
|
||||||
|
|
||||||
|
echo "Successfully signed all $TOTAL_COUNT RPMs"
|
||||||
|
|
||||||
- name: Verify RPM signatures
|
- name: Verify RPM signatures
|
||||||
run: |
|
run: |
|
||||||
# Skip if no signing key is configured or no RPMs were signed
|
# Skip if no signing key is configured
|
||||||
if [ -z "${{ secrets.RPM_SIGNING_KEY }}" ]; then
|
if [ -z "${{ secrets.RPM_SIGNING_KEY }}" ]; then
|
||||||
echo "No RPM signing key configured - skipping signature verification"
|
echo "No RPM signing key configured - skipping signature verification"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if rpmsign was successful (at least one signed RPM exists)
|
|
||||||
SIGNED_COUNT=$(find "$HOME/rpmbuild" -name "*.rpm" -type f -exec rpm -K {} \; 2>/dev/null | grep -c "signatures OK" || true)
|
|
||||||
if [ "$SIGNED_COUNT" -eq 0 ]; then
|
|
||||||
echo "No successfully signed RPMs found - skipping signature verification"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Import our public key for verification
|
# Import our public key for verification
|
||||||
|
echo "Importing GPG public key for verification..."
|
||||||
curl -s https://forgejo.ellis.link/continuwuation/continuwuity/raw/branch/main/fedora/RPM-GPG-KEY-continuwuity.asc | rpm --import
|
curl -s https://forgejo.ellis.link/continuwuation/continuwuity/raw/branch/main/fedora/RPM-GPG-KEY-continuwuity.asc | rpm --import
|
||||||
|
|
||||||
|
# Track verification failures
|
||||||
|
FAILED_COUNT=0
|
||||||
|
TOTAL_COUNT=0
|
||||||
|
|
||||||
# Verify all RPMs
|
# Verify all RPMs
|
||||||
find "$HOME/rpmbuild" -name "*.rpm" -type f | while read rpm; do
|
for rpm in $(find "$HOME/rpmbuild" -name "*.rpm" -type f); do
|
||||||
echo -n "Verifying $(basename $rpm): "
|
echo -n "Verifying $(basename $rpm): "
|
||||||
rpm --checksig "$rpm"
|
TOTAL_COUNT=$((TOTAL_COUNT + 1))
|
||||||
|
|
||||||
|
if rpm --checksig "$rpm"; then
|
||||||
|
echo " ✓"
|
||||||
|
else
|
||||||
|
echo " ✗ FAILED"
|
||||||
|
FAILED_COUNT=$((FAILED_COUNT + 1))
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Fail if any RPMs failed verification
|
||||||
|
if [ "$FAILED_COUNT" -gt 0 ]; then
|
||||||
|
echo "ERROR: $FAILED_COUNT out of $TOTAL_COUNT RPMs failed signature verification"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Successfully verified all $TOTAL_COUNT RPM signatures"
|
||||||
|
|
||||||
- name: Test RPM installation
|
- name: Test RPM installation
|
||||||
run: |
|
run: |
|
||||||
# Find the main binary RPM (exclude debug and source RPMs)
|
# Find the main binary RPM (exclude debug and source RPMs)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue