@@ -456,6 +456,10 @@ workflows:
456456 - _check_exported_artifacts
457457
458458 _run :
459+ envs :
460+ - PROFILES_PATH : " ~/Library/Developer/Xcode/UserData/Provisioning\ Profiles"
461+ before_run :
462+ - _generate_api_token
459463 steps :
460464 - script :
461465 title : Remove temp folder
@@ -472,7 +476,15 @@ workflows:
472476 - content : |-
473477 #!/bin/bash
474478 set -ex
475- rm -rf ~/Library/MobileDevice/Provisioning Profiles
479+ rm -rf ~/Library/MobileDevice/Provisioning\ Profiles
480+ ls -la ~/Library/MobileDevice/Provisioning\ Profiles
481+
482+ rm -rf $PROFILES_PATH
483+ ls -la $PROFILES_PATH
484+ - restore-cache :
485+ run_if : " true"
486+ inputs :
487+ - key : xcode-profiles-cache
476488 - git::https://github.com/bitrise-steplib/bitrise-step-simple-git-clone.git :
477489 inputs :
478490 - repository_url : $TEST_APP_URL
@@ -496,10 +508,16 @@ workflows:
496508 - verbose_log : " yes"
497509 - keychain_path : $BITRISE_KEYCHAIN_PATH
498510 - keychain_password : $BITRISE_KEYCHAIN_PASSWORD
499- - fallback_provisioning_profile_url_list : $FALLBACK_PROFILES
511+ - fallback_provisioning_profile_url_list : $PROFILES_PATH
500512 - api_key_path : $API_KEY_PATH
501513 - api_key_id : $API_KEY_ID
502514 - api_key_issuer_id : $API_KEY_ISSUER_ID
515+ - save-cache :
516+ run_if : " true"
517+ inputs :
518+ - key : xcode-profiles-cache
519+ - cache_paths : |-
520+ $PROFILES_PATH
503521
504522 _check_outputs :
505523 steps :
@@ -638,3 +656,28 @@ workflows:
638656 set -ex
639657 envman add --key BITRISE_BUILD_URL --value $BITRISE_BUILD_URL_BACKUP
640658 envman add --key BITRISE_BUILD_API_TOKEN --value $BITRISE_BUILD_API_TOKEN_BACKUP
659+
660+ _generate_api_token :
661+ steps :
662+ - script :
663+ run_if : " {{ not .IsCI }}"
664+ title : Generate API access token
665+ description : Generate an expiring API token using $API_CLIENT_SECRET
666+ inputs :
667+ - content : |
668+ #!/bin/env bash
669+ set -e
670+
671+ json_response=$(curl --fail -X POST https://auth.services.bitrise.io/auth/realms/bitrise-services/protocol/openid-connect/token -k \
672+ --data "client_id=bitrise-steps" \
673+ --data "client_secret=$CACHE_API_CLIENT_SECRET" \
674+ --data "grant_type=urn:ietf:params:oauth:grant-type:uma-ticket" \
675+ --data "claim_token=eyJhcHBfaWQiOlsiY2FjaGUtc3RlcHMtdGVzdHMiXSwgIm9yZ19pZCI6WyJ0ZXN0LW9yZy1pZCJdLCAiYWJjc19hY2Nlc3NfZ3JhbnRlZCI6WyJ0cnVlIl19" \
676+ --data "claim_token_format=urn:ietf:params:oauth:token-type:jwt" \
677+ --data "audience=bitrise-services")
678+
679+ auth_token=$(echo $json_response | jq -r .access_token)
680+
681+ envman add --key BITRISEIO_ABCS_API_URL --value $BITRISEIO_CACHE_SERVICE_URL
682+ envman add --key BITRISEIO_BITRISE_SERVICES_ACCESS_TOKEN --value $auth_token --sensitive
683+
0 commit comments