Skip to content

Commit af20d0b

Browse files
authored
[release/9.0.1xx] [devops] Use a zip file with all the certificates and provisioning profiles. (#23455)
Azure DevOps' UI to add and modify secure files is utterly horrible. * There's no way to modify a secure file, you have to delete it and re-add it. * There's no documented way to add/remove a secure file using the REST API, although there's apparently an un-official REST API (microsoft/azure-pipelines-tasks#9172 (comment)), which was apparently supposed to become documented, which was over 6 years ago and in the meantime the only thing that happened was that the issue got closed. * There's no way to update the security settings for a secure file using the REST API that I could find, and the UI to do so is _sloooooow_ and clunky. So instead of going through the pain of adding/deleting/updating 19 different files, add them all in a single zip file, and feel the pain only once (per year). Backport of #23448.
1 parent 8071534 commit af20d0b

File tree

2 files changed

+16
-51
lines changed

2 files changed

+16
-51
lines changed

tools/devops/automation/scripts/install-qa-provisioning-profiles.sh

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash -eux
1+
#!/bin/bash -eu
22

33
WHITE=$(tput setaf 7 2>/dev/null || true)
44
BLUE=$(tput setaf 6 2>/dev/null || true)
@@ -40,17 +40,7 @@ done
4040

4141
echo "${BLUE}Installing certificates and provisioning profiles to the keychain '${WHITE}${KEYCHAIN}${BLUE}'${CLEAR}"
4242

43-
IFS="." read -r -a VERSIONS <<< "$(sw_vers -productVersion)"
44-
majorVersion="${VERSIONS[0]}"
45-
minorVersion="${VERSIONS[1]}"
46-
echo "macOS version: ${majorVersion}.${minorVersion}"
47-
if [[ "$majorVersion" -gt 10 || ("$majorVersion" -eq 10 && "$minorVersion" -gt 11) ]]; then
48-
echo "keychain file format: Sierra (10.12) and above"
49-
KEYCHAIN_FILE=~/Library/Keychains/$KEYCHAIN.keychain-db
50-
else
51-
echo "keychain file format: El Capitan (10.11) and below"
52-
KEYCHAIN_FILE=~/Library/Keychains/$KEYCHAIN.keychain
53-
fi
43+
KEYCHAIN_FILE=~/Library/Keychains/$KEYCHAIN.keychain-db
5444

5545
if test -f "$KEYCHAIN_FILE"; then
5646
echo "${BLUE}Deleting previous keychain '${WHITE}$KEYCHAIN_FILE${BLUE}'${CLEAR}"
@@ -102,6 +92,8 @@ if test -z "$ONLY_CREATE_KEYCHAIN"; then
10292
shopt -s nullglob
10393
for p12 in provisioning-profiles/certificates-and-profiles/*.p12; do
10494
echo "${BLUE}Installing the certificate '${WHITE}$p12${BLUE}'${CLEAR}"
95+
openssl pkcs12 -nodes -in "$p12" -passin pass:1234 2>/dev/null | grep friendlyName | sed 's/^[[:space:]]*//' | sed 's/^/ /' || true
96+
openssl pkcs12 -nodes -in "$p12" -passin pass:1234 2>/dev/null | openssl x509 -noout -dates -subject -fingerprint | sed 's/^/ /' || true
10597
security import "$p12" -P "${AUTH_TOKEN_LA_DEV_APPLE_P12}" -A -t cert -f pkcs12 -k "$KEYCHAIN_FILE"
10698
done
10799

tools/devops/automation/templates/common/install-qa-provisioning-profiles.yml

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,30 @@ parameters:
22
- name: env
33
type: object
44

5-
- name: secureFiles
6-
type: object
7-
default:
8-
[
9-
{ 'name': 'AppleWWDRCAG3-2.cer', 'secureFile': 'macios-AppleWWDRCAG3-2.cer' },
10-
{ 'name': 'developer-id-application-luis-aguilera-jul-2029.p12', 'secureFile': 'macios-developer-id-application-luis-aguilera-jul-2029.p12' },
11-
{ 'name': 'developer-id-installer-luis-aguilera-jul-2029.p12', 'secureFile': 'macios-developer-id-installer-luis-aguilera-jul-2029.p12' },
12-
{ 'name': 'la_dev_apple.p12', 'secureFile': 'macios-la-dev-apple.p12' },
13-
{ 'name': 'la_dev_iPhone.p12', 'secureFile': 'macios-la-dev-iPhone.p12' },
14-
{ 'name': 'la_distr_apple.p12', 'secureFile': 'macios-la-distr-apple.p12' },
15-
{ 'name': 'la_distr_iphone.p12', 'secureFile': 'macios-la-distr-iphone.p12' },
16-
{ 'name': 'la_mac_app_dev.p12', 'secureFile': 'macios-la-mac-app-dev.p12' },
17-
{ 'name': 'la_mac_app_distr.p12', 'secureFile': 'macios-la-mac-app-distr.p12' },
18-
{ 'name': 'la_mac_installer_distr.p12', 'secureFile': 'macios-la-mac-installer-distr.p12' },
19-
{ 'name': 'vseng-xamarin-mac-devices-2.p12', 'secureFile': 'macios-vseng-xamarin-mac-devices-2.p12' },
20-
{ 'name': 'vseng-xamarin-mac-devices.p12', 'secureFile': 'macios-vseng-xamarin-mac-devices.p12' },
21-
{ 'name': 'vsengxamarinmacdevices.mobileprovision', 'secureFile': 'macios-vsengxamarinmacdevices.mobileprovision' },
22-
{ 'name': 'WildCardiOSDevelopment.mobileprovision', 'secureFile': 'macios-WildCardiOSDevelopment.mobileprovision' },
23-
{ 'name': 'WildCardiOSDistribution.mobileprovision', 'secureFile': 'macios-WildCardiOSDistribution.mobileprovision' },
24-
{ 'name': 'WildCardMacAppDevelopment.provisionprofile', 'secureFile': 'macios-WildCardMacAppDevelopment.provisionprofile' },
25-
{ 'name': 'WildCardMacDistribution.provisionprofile', 'secureFile': 'macios-WildCardMacDistribution.provisionprofile' },
26-
{ 'name': 'WildCardtvOSDevelopment.mobileprovision', 'secureFile': 'macios-WildCardtvOSDevelopment.mobileprovision' },
27-
{ 'name': 'WildCardtvOSDistribution.mobileprovision', 'secureFile': 'macios-WildCardtvOSDistribution.mobileprovision' },
28-
]
295
- name: xamarinMaciosPath
306
type: string
317
default: $(Build.SourcesDirectory)/$(BUILD_REPOSITORY_TITLE)
32-
8+
339
steps:
3410
- pwsh: |
3511
New-Item $(Build.SourcesDirectory)/maccore/tools/provisioning-profiles/certificates-and-profiles -ItemType Directory -Force
3612
displayName: 'Create secret files folder'
3713

38-
- ${{ each secureFile in parameters.secureFiles }}:
39-
- task: DownloadSecureFile@1
40-
displayName: 'Download ${{ secureFile.name }}'
41-
inputs:
42-
secureFile: ${{ secureFile.secureFile }}
14+
- task: DownloadSecureFile@1
15+
displayName: 'Download macios-certificates-and-provisioning-profiles.zip'
16+
inputs:
17+
secureFile: macios-certificates-and-provisioning-profiles.zip
18+
4319
- pwsh: |
4420
gci $(Agent.TempDirectory)
21+
unzip -l $(Agent.TempDirectory)/macios-certificates-and-provisioning-profiles.zip
4522
displayName: 'List secure files'
46-
- pwsh: |
47-
$secureFiles = '${{ convertToJson(parameters.secureFiles) }}' | ConvertFrom-Json
48-
foreach ($secureFile in $secureFiles) {
49-
$sourcePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath $secureFile.secureFile
50-
$destinationPath = Join-Path -Path "$env:BUILD_SOURCESDIRECTORY/maccore/tools/provisioning-profiles/certificates-and-profiles" -ChildPath $secureFile.name
5123

52-
Copy-Item -Path $sourcePath -Destination $destinationPath -Force
53-
}
24+
- pwsh: |
25+
mkdir -p $Env:BUILD_SOURCESDIRECTORY/maccore/tools/provisioning-profiles/certificates-and-profiles
26+
unzip -d $Env:BUILD_SOURCESDIRECTORY/maccore/tools/provisioning-profiles/certificates-and-profiles/ $(Agent.TempDirectory)/macios-certificates-and-provisioning-profiles.zip
5427
displayName: 'Copy Certificates and Profiles'
55-
28+
5629
- pwsh: |
5730
gci $(Build.SourcesDirectory)/maccore/tools/provisioning-profiles/certificates-and-profiles
5831
displayName: 'List Certificates and Profiles'
@@ -66,4 +39,4 @@ steps:
6639

6740
- pwsh: |
6841
Remove-Item $(Build.SourcesDirectory)/maccore/tools/provisioning-profiles/certificates-and-profiles -Recurse -Force
69-
displayName: 'Clean certs and profiles'
42+
displayName: 'Clean certs and profiles'

0 commit comments

Comments
 (0)