Skip to content

Commit fe5a74c

Browse files
authored
Update build-ipa.yml
1 parent 5dc50e2 commit fe5a74c

File tree

1 file changed

+44
-25
lines changed

1 file changed

+44
-25
lines changed

.github/workflows/build-ipa.yml

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -338,29 +338,37 @@ jobs:
338338
# Fetch README.md that lists signed certs
339339
curl -s https://raw.githubusercontent.com/ProStore-iOS/certificates/refs/heads/main/README.md > readme.md
340340
341-
# Extract signed certificate full names (line format in your README)
342-
FULL_NAMES=$(grep -F '| **✅ Signed** |' readme.md | awk -F'|' '{gsub(/^\s+|\s+$/,"",$2); print $2}')
341+
# Debug: show the README excerpt and matching lines
342+
echo "----- README excerpt -----"
343+
sed -n '1,200p' readme.md || true
344+
echo "----- Matching lines -----"
345+
grep -nF '| **✅ Signed** |' readme.md || true
343346
344-
if [ -z "$FULL_NAMES" ]; then
345-
echo "No signed certificates found. Skipping signing."
347+
# Read all full names into an array safely (handles spaces/newlines)
348+
mapfile -t FULL_NAMES < <(
349+
grep -F '| **✅ Signed** |' readme.md \
350+
| awk -F'|' '{gsub(/^[ \t]+|[ \t]+$/,"",$2); print $2}'
351+
)
352+
353+
echo "Found ${#FULL_NAMES[@]} signed certificate(s)."
354+
if [ ${#FULL_NAMES[@]} -eq 0 ]; then
355+
echo "No signed certificates found. Exiting."
346356
exit 0
347357
fi
348358
349-
# Install zsign dependencies
359+
# Install build dependencies (no-op if already installed)
350360
brew install pkg-config openssl minizip
351361
352362
# Build zsign
353363
git clone https://github.com/zhlynn/zsign.git
354-
cd zsign/build/macos
364+
pushd zsign/build/macos >/dev/null
355365
make clean && make
366+
popd >/dev/null
356367
357-
# Find the built zsign binary (most zsign builds place it in zsign/bin/zsign)
358-
cd ../../..
368+
# Locate binary (expected at zsign/bin/zsign)
359369
ZSIGN_PATH="$(pwd)/zsign/bin/zsign"
360-
361-
# As a fallback, try to locate if not found
362370
if [ ! -x "$ZSIGN_PATH" ]; then
363-
echo "Expected binary not found at $ZSIGN_PATH, searching..."
371+
echo "Binary not at expected path $ZSIGN_PATH searching..."
364372
FOUND=$(find "$(pwd)/zsign" -type f -name zsign -perm -111 -print -quit || true)
365373
if [ -n "$FOUND" ]; then
366374
ZSIGN_PATH="$FOUND"
@@ -370,34 +378,43 @@ jobs:
370378
exit 1
371379
fi
372380
fi
373-
374-
echo "Using zsign at: $ZSIGN_PATH"
381+
echo "Using zsign: $ZSIGN_PATH"
375382
ls -l "$ZSIGN_PATH" || true
376383
377-
# Process each cert
378-
echo "$FULL_NAMES" | while IFS= read -r FULL_NAME; do
379-
if [ -z "$FULL_NAME" ]; then continue; fi
384+
# Prepare output directory for artifacts that will be uploaded
385+
SIGNED_DIR="signed-ipas"
386+
mkdir -p "$SIGNED_DIR"
380387
381-
# short name used for filenames: sanitize to lowercase alnum and dashes
388+
# Loop over certificates and sign each
389+
for FULL_NAME in "${FULL_NAMES[@]}"; do
390+
# Skip empty lines just in case
391+
if [ -z "${FULL_NAME// /}" ]; then
392+
echo "Skipping empty name"
393+
continue
394+
fi
395+
396+
echo "---- Processing: '$FULL_NAME' ----"
397+
398+
# sanitize short name for file/dir
382399
SHORT_NAME=$(echo "$FULL_NAME" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g' | sed -E 's/^-+|-+$//g')
383400
384-
# URL-encode the full display name for the GitHub path
401+
# URL-encode the full display name for GitHub path
385402
ENCODED=$(python3 -c "import sys,urllib.parse as u; print(u.quote(sys.stdin.read().strip()))" <<< "$FULL_NAME")
386403
387404
CERT_DIR="certs/$SHORT_NAME"
388405
mkdir -p "$CERT_DIR"
389406
pushd "$CERT_DIR" >/dev/null
390407
391-
# download files; if any are missing this will fail, which is likely what you want
408+
# Download files; -f will fail the step if missing
392409
curl -fLO "https://github.com/ProStore-iOS/certificates/raw/refs/heads/main/${ENCODED}/${ENCODED}.mobileprovision"
393410
curl -fLO "https://github.com/ProStore-iOS/certificates/raw/refs/heads/main/${ENCODED}/${ENCODED}.p12"
394411
curl -fLO "https://github.com/ProStore-iOS/certificates/raw/refs/heads/main/${ENCODED}/password.txt"
395412
396413
popd >/dev/null
397414
398-
SIGNED_IPA="build/com.prostoreios.prostore-signed-${SHORT_NAME}-ios.ipa"
415+
SIGNED_IPA="${SIGNED_DIR}/com.prostoreios.prostore-signed-${SHORT_NAME}-ios.ipa"
399416
400-
# run zsign
417+
# Run zsign
401418
"$ZSIGN_PATH" -k "${CERT_DIR}/${ENCODED}.p12" \
402419
-p "$(cat "${CERT_DIR}/password.txt")" \
403420
-m "${CERT_DIR}/${ENCODED}.mobileprovision" \
@@ -406,13 +423,15 @@ jobs:
406423
407424
echo "Signed IPA created: $SIGNED_IPA"
408425
done
409-
- name: Upload Artifacts
410-
if: always()
411-
continue-on-error: true
426+
427+
echo "Signing complete. Signed files:"
428+
ls -la "$SIGNED_DIR" || true
429+
- name: Upload signed IPAs
412430
uses: actions/upload-artifact@v4
413431
with:
414432
name: signed-ipas
415-
path: artifact_dir/**
433+
path: signed-ipas/*.ipa
434+
416435
# create-github-release:
417436
# name: Create GitHub Release
418437
# needs: [build-unsigned-ipa, sign-ipas]

0 commit comments

Comments
 (0)