mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-08 11:46:25 -04:00
Revert CD archive to use python re-try
This commit is contained in:
parent
2e83ca0cf7
commit
ccb612a59a
76
.github/retry-if-retcode.py
vendored
Normal file
76
.github/retry-if-retcode.py
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
def run_command(
|
||||
max_attempts: int, retcode: int, sleep_seconds: int, command: str
|
||||
) -> int:
|
||||
attempts = 0
|
||||
while True:
|
||||
ps = subprocess.run(command, check=False)
|
||||
attempts += 1
|
||||
|
||||
# either suceeded or returned an unexpected exit-code, returning.
|
||||
if ps.returncode == 0 or ps.returncode != retcode:
|
||||
return ps.returncode
|
||||
|
||||
if attempts >= max_attempts:
|
||||
print(f"Reached {max_attempts=}", flush=True)
|
||||
return ps.returncode
|
||||
|
||||
print(
|
||||
f"Received retcode={ps.returncode} on attempt #{attempts}. "
|
||||
f"Retrying in {sleep_seconds}s.",
|
||||
flush=True,
|
||||
)
|
||||
if sleep_seconds:
|
||||
time.sleep(sleep_seconds)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="retry-if-retcode", epilog=r"/!\ Append your command after those args!"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--retcode",
|
||||
required=True,
|
||||
help="Return code to retry when received",
|
||||
type=int,
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--attempts",
|
||||
required=False,
|
||||
help="Max number of attempts",
|
||||
type=int,
|
||||
default=10,
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--sleep",
|
||||
required=False,
|
||||
help="Nb. of seconds to sleep in-between retries",
|
||||
type=int,
|
||||
default=1,
|
||||
)
|
||||
|
||||
args, command = parser.parse_known_args()
|
||||
if not command:
|
||||
print("You must supply a command to run")
|
||||
return 1
|
||||
|
||||
return run_command(
|
||||
max_attempts=args.attempts,
|
||||
retcode=args.retcode,
|
||||
sleep_seconds=args.sleep,
|
||||
command=command,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
4
.github/workflows/cd.yml
vendored
4
.github/workflows/cd.yml
vendored
@ -172,7 +172,7 @@ jobs:
|
||||
APPLE_STORE_AUTH_KEY_PATH: ${{ env.APPLE_STORE_AUTH_KEY_PATH }}
|
||||
APPLE_STORE_AUTH_KEY_ID: ${{ secrets.APPLE_STORE_AUTH_KEY_ID }}
|
||||
APPLE_STORE_AUTH_KEY_ISSUER_ID: ${{ secrets.APPLE_STORE_AUTH_KEY_ISSUER_ID }}
|
||||
run: xcrun xcodebuild -exportArchive -archivePath $PWD/Kiwix-$VERSION.xcarchive -exportPath $PWD/export/ -exportOptionsPlist export.plist -authenticationKeyPath $APPLE_STORE_AUTH_KEY_PATH -allowProvisioningUpdates -authenticationKeyID $APPLE_STORE_AUTH_KEY_ID -authenticationKeyIssuerID $APPLE_STORE_AUTH_KEY_ISSUER_ID
|
||||
run: python .github/retry-if-retcode.py --sleep 60 --attempts 5 --retcode 70 xcrun xcodebuild -exportArchive -archivePath $PWD/Kiwix-$VERSION.xcarchive -exportPath $PWD/export/ -exportOptionsPlist export.plist -authenticationKeyPath $APPLE_STORE_AUTH_KEY_PATH -allowProvisioningUpdates -authenticationKeyID $APPLE_STORE_AUTH_KEY_ID -authenticationKeyIssuerID $APPLE_STORE_AUTH_KEY_ISSUER_ID
|
||||
|
||||
- name: Export notarized App from archive
|
||||
if: ${{ matrix.destination.uploadto == 'dmg' }}
|
||||
@ -180,7 +180,7 @@ jobs:
|
||||
APPLE_STORE_AUTH_KEY_PATH: ${{ env.APPLE_STORE_AUTH_KEY_PATH }}
|
||||
APPLE_STORE_AUTH_KEY_ID: ${{ secrets.APPLE_STORE_AUTH_KEY_ID }}
|
||||
APPLE_STORE_AUTH_KEY_ISSUER_ID: ${{ secrets.APPLE_STORE_AUTH_KEY_ISSUER_ID }}
|
||||
run: xcrun xcodebuild -exportNotarizedApp -archivePath $PWD/Kiwix-$VERSION.xcarchive -exportPath $PWD/export/ -authenticationKeyPath $APPLE_STORE_AUTH_KEY_PATH -allowProvisioningUpdates -authenticationKeyID $APPLE_STORE_AUTH_KEY_ID -authenticationKeyIssuerID $APPLE_STORE_AUTH_KEY_ISSUER_ID
|
||||
run: python .github/retry-if-retcode.py --sleep 60 --attempts 20 --retcode 65 xcrun xcodebuild -exportNotarizedApp -archivePath $PWD/Kiwix-$VERSION.xcarchive -exportPath $PWD/export/ -authenticationKeyPath $APPLE_STORE_AUTH_KEY_PATH -allowProvisioningUpdates -authenticationKeyID $APPLE_STORE_AUTH_KEY_ID -authenticationKeyIssuerID $APPLE_STORE_AUTH_KEY_ISSUER_ID
|
||||
|
||||
- name: Create DMG
|
||||
if: ${{ matrix.destination.uploadto == 'dmg' }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user