Search Unity

Feature Request Creating 2 builds with different signing credentials

Discussion in 'Unity Build Automation' started by mgear, Mar 24, 2023.

  1. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,440
    if want to release with different credentials (for ios)
    Currently need to do full build again..

    Would be nice (to save time and resources)
    if previous build could be just signed with a new key?
    (if thats even possible with ios builds)
     
  2. Benjamin-Gooding

    Benjamin-Gooding

    Unity Technologies

    Joined:
    Apr 12, 2022
    Posts:
    303
    I agree that this would be a nice feature to have. At this point in time the only thing I could think of that you could do is edit the build target configuration to use different credentials. Then you can go to the build you want to re-sign and there is an option to resign the build.

    upload_2023-3-27_11-47-54.png
     
    mgear likes this.
  3. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,440
    Ok! that looks good enough for me (as i don't need multiple signs on most builds).

    Haven't tested it yet,
    but then could be nice if clicking that re-sign build button would allow picking signing credentials right there.
    (instead of if it needs to be modified to actual build configs first)
     
  4. Benjamin-Gooding

    Benjamin-Gooding

    Unity Technologies

    Joined:
    Apr 12, 2022
    Posts:
    303
    I agree that would be an awesome feature to have. I've added it to our backlog but I unfortunately don't see us getting to this in the near feature.
     
  5. allan-oooh

    allan-oooh

    Joined:
    Mar 29, 2019
    Posts:
    53
    I use fastlane to do this for a very specific scenario. This will resign the build and upload to testflight and than restore the original build so you can download it on provisioned devices from UCB (which allows for some debugging access that testflight builds don't allow).

    Code (CSharp):
    1. lane :upload do |options|
    2.  
    3.     # keep the development signed build untouched
    4.     source_path = Dir[File.join(options[:output_directory], "*.ipa")][0]
    5.     target_path = source_path + ".bak"
    6.     sh("cp", source_path, target_path)
    7.  
    8.     # sign for testflight
    9.     setup_circle_ci()
    10.     match(
    11.         type: "appstore",
    12.         s3_bucket: "BUCKET_NAME",
    13.         s3_region: "us-east-2",
    14.         s3_access_key: "ACCESS_KEY",
    15.         storage_mode: "s3",
    16.         team_id: "TEAM_ID",
    17.         readonly: true
    18.     )
    19.     provisioning_profile = ENV["sigh_#{ENV["MATCH_APP_IDENTIFIER"]}_appstore_profile-path"]
    20.     resign(
    21.         ipa: source_path,
    22.         provisioning_profile: provisioning_profile,
    23.         signing_identity: "SIGNING_IDENTITY",
    24.         use_app_entitlements: true
    25.     )
    26.  
    27.     # sign in and upload to testflight
    28.     api_key = app_store_connect_api_key()
    29.     begin
    30.         upload_to_testflight(changelog: "Bug fixes and improvements", api_key: api_key)
    31.     rescue => e
    32.         # ignore failure, assuming it's because a build is already being reviewed
    33.         puts e.message
    34.     end
    35.  
    36.     # restore the development build
    37.     sh("mv", target_path, source_path)
    38. end
    You'll need to setup fastlane match for this work and define a bunch of environment variables in your build configuration:

    * APP_STORE_CONNECT_API_KEY_KEY_ID - the Key ID
    * APP_STORE_CONNECT_API_KEY_ISSUER_ID - the Issuer ID for the organization
    * APP_STORE_CONNECT_API_KEY_KEY - the base64 content of the key (.p8 file downloaded on key creation)
    * APP_STORE_CONNECT_API_KEY_IS_KEY_CONTENT_BASE64 - `true`
    * PILOT_GROUPS - comma separated lists of external test flight groups to submit the build to
    * MATCH_APP_IDENTIFIER - the bundle id of the app
    * MATCH_S3_SECRET_ACCESS_KEY - The secret key for S3 access
    * MATCH_PASSWORD - The password used to encrypt match data in S3