Last active
October 27, 2023 10:54
-
-
Save weslley39/38c3540660f3c33e894da061de313ba8 to your computer and use it in GitHub Desktop.
Awesome script to generate APK and IPA through Azure Devops and send to AppCenter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Before start, put the .mobileprovision and .p12 certificates for iOS build | |
# and .jks for Android build in the Library tab, under SecureFiles. | |
# Without this the signin process will not work | |
# You can store the password in the Library under Variables groups, as used in this script | |
# or insert directly (I don't recommend that) | |
trigger: | |
- master | |
pool: | |
vmImage: 'macos-latest' | |
variables: | |
- group: android_variable_group | |
- group: ios_variable_group | |
steps: | |
- checkout: self | |
persistCredentials: true | |
# # - task: ShellScript@2 | |
# # inputs: | |
# # scriptPath: appcenter-post-clone.sh | |
# # displayName: Post Clone Script | |
- task: NodeTool@0 | |
inputs: | |
versionSpec: '8.x' | |
displayName: Select Node version | |
- script: yarn install | |
displayName: yarn install | |
# # - task: ShellScript@2 | |
# # inputs: | |
# # scriptPath: appcenter-pre-build.sh | |
# # displayName: Pre Build Script | |
# # continueOnError: false | |
##################### | |
## ANDROID | |
##################### | |
# - script: /Users/vsts/agent/2.150.3/scripts/emit-tags.sh continuous,javascript,xcode,android,signed,distribution | |
# displayName: Get Build Number | |
- task: Gradle@2 | |
inputs: | |
workingDirectory: 'android' | |
gradleWrapperFile: 'android/gradlew' | |
tasks: 'assembleRelease' | |
options: '-DMOBILECENTER_BUILD_VERSION=$(Build.BuildId) -DAPPCENTER_BUILD_VERSION=$(Build.BuildId)' | |
continueOnError: false | |
- script: mv android/app/build/outputs/apk/release/app-release-unsigned.apk app-release.apk | |
displayName: Android Postprocess | |
continueOnError: false | |
- task: AndroidSigning@3 | |
inputs: | |
apkFiles: 'app-release.apk' | |
apksign: true # Optional | |
apksignerKeystoreFile: 'key_values_store_in_secure_files.jks' | |
apksignerKeystorePassword: $(KeystorePasswordStoredInVariableGroups) # Optional | |
apksignerKeystoreAlias: $(KeystoreAliasStoredInVariableGroups) # Optional | |
apksignerKeyPassword: $(KeyPasswordStoredInVariableGroups) # Optional | |
continueOnError: false | |
- task: CopyFiles@2 | |
inputs: | |
contents: 'app-release.apk' | |
targetFolder: $(Build.ArtifactStagingDirectory) | |
- task: PublishBuildArtifacts@1 | |
- task: AppCenterDistribute@3 | |
inputs: | |
serverEndpoint: 'your_appcenter_server_name' | |
appSlug: 'username/project_name' | |
appFile: 'app-release.apk' | |
releaseNotesOption: 'input' | |
releaseNotesInput: $(Build.SourceVersionMessage) # Required when releaseNotesOption == Input | |
###################### | |
### IOS | |
###################### | |
- task: InstallAppleCertificate@2 | |
inputs: | |
certSecureFile: your_distribution_cert_stored_in_secure_files.p12 | |
certPwd: $(P12passwordStoredInVariableGroups) | |
displayName: Install Apple Certificate | |
- task: InstallAppleProvisioningProfile@1 | |
inputs: | |
provisioningProfileLocation: 'secureFiles' | |
provProfileSecureFile: 'your_profile_stored_in_secure_files.mobileprovision' | |
displayName: 'Install Apple Provisioning Profile' | |
- task: CocoaPods@0 | |
inputs: | |
workingDirectory: 'ios' | |
forceRepoUpdate: true | |
- task: CmdLine@2 | |
inputs: | |
script: '/usr/bin/find . -name *Info.plist -exec /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $(Build.BuildId)" {} \;' | |
workingDirectory: 'ios' | |
displayName: Set iOS Bundle version | |
- task: Xcode@5 | |
inputs: | |
actions: 'clean' | |
scheme: 'your_ios_project_schema_name' | |
sdk: 'iphoneos' | |
configuration: 'Debug' | |
xcodeVersion: 'default' # Options: 8, 9, 10, default, specifyPath | |
xcWorkspacePath: '$(system.defaultWorkingDirectory)/ios/your_ios_project_schema.xcworkspace' | |
useXcpretty: false | |
args: '-UseModernBuildSystem=NO' | |
- task: Xcode@5 | |
inputs: | |
actions: 'archive' | |
scheme: 'your_ios_project_schema_name' | |
sdk: 'iphoneos' | |
configuration: 'Release' | |
xcodeVersion: 'default' # Options: 8, 9, 10, default, specifyPath | |
xcWorkspacePath: '$(system.defaultWorkingDirectory)/ios/your_ios_project_schema.xcworkspace' | |
useXcpretty: false | |
teamId: 'your_deleopment_team_id' | |
args: '-UseModernBuildSystem=NO DEVELOPMENT_TEAM=your_deleopment_team_id' | |
packageApp: true | |
archivePath: 'output/build/archive' | |
exportPath: 'output/build/export' | |
exportOptions: 'auto' | |
signingOption: 'manual' | |
signingIdentity: $(APPLE_CERTIFICATE_SIGNING_IDENTITY) | |
provisioningProfileUuid: $(APPLE_PROV_PROFILE_UUID) | |
- task: CopyFiles@2 | |
inputs: | |
contents: '**/*.ipa' | |
targetFolder: $(Build.ArtifactStagingDirectory) | |
- task: PublishBuildArtifacts@1 | |
- task: AppCenterDistribute@3 | |
inputs: | |
serverEndpoint: 'your_appcenter_server_name' | |
appSlug: 'username/project_name' | |
appFile: 'output/build/export/your_project_build_name.ipa' | |
releaseNotesOption: 'input' | |
releaseNotesInput: $(Build.SourceVersionMessage) # Required when releaseNotesOption == Input | |
# - task: ShellScript@2 | |
# inputs: | |
# scriptPath: appcenter-post-build.sh | |
# displayName: Post Build Script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment