Skip to content

Instantly share code, notes, and snippets.

@nbellocam
Created December 2, 2020 21:53
Show Gist options
  • Save nbellocam/4f8810abac150a55e87fe3bc69cb0ce5 to your computer and use it in GitHub Desktop.
Save nbellocam/4f8810abac150a55e87fe3bc69cb0ce5 to your computer and use it in GitHub Desktop.
CI pipeline for a Swift application using Azure DevOps
trigger:
- develop
- master
pr:
branches:
include:
- develop
paths:
include:
- ProjectName/*
pool:
vmImage: 'macos-latest'
variables:
sdk: 'macosx'
projectPath: 'ProjectName/ProjectName.xcodeproj'
workspacePath: 'ProjectName/ProjectName.xcworkspace'
scheme: 'ProjectName'
configuration: 'Debug'
coveragePath: '$(agent.buildDirectory)/coverage/'
artifactName: 'ArtifactName'
- task: InstallAppleCertificate@2
inputs:
certSecureFile: 'appCertificateName.p12'
certPwd: '${secretVariable}'
keychain: 'temp'
deleteCert: true
- task: CmdLine@2
displayName: 'Run swiftlint on pipeline terminal'
inputs:
script: '$(build.Repository.LocalPath)/ProjectName/Pods/SwiftLint/swiftlint --config $(build.Repository.LocalPath)/ProjectName/.swiftlint.yml --reporter junit'
- task: Xcode@5
displayName: 'Build and Sign'
inputs:
actions: 'build'
sdk: '$(sdk)'
scheme: '$(scheme)'
signingOption: 'manual'
signingIdentity: 'Developer ID Application'
teamId: $(teamId)
packageApp: false
destinationPlatformOption: 'macOS'
configuration: '$(configuration)' # only testable for Debug with current config
xcWorkspacePath: '$(workspacePath)'
xcodeVersion: 'default'
args: '-derivedDataPath $(build.Repository.LocalPath)/ProjectName/'
- task: Xcode@5
displayName: 'Run XCTest/XCUITest'
inputs:
actions: 'test'
sdk: '$(sdk)'
scheme: '$(scheme)'
packageApp: false
destinationPlatformOption: 'macOS'
configuration: '$(configuration)' # only testable for Debug with current config
xcWorkspacePath: '$(workspacePath)'
xcodeVersion: 'default'
- script: gem install slather
displayName: 'Install Slather'
- script: slather coverage -x --scheme $(scheme) --workspace $(workspacePath) --output-directory $(coveragePath) $(projectPath)
displayName: 'Run slather to convert Code Coverage'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: '$(coveragePath)/cobertura.xml'
- task: CmdLine@2
displayName: 'Application Packaging and installer signing'
inputs:
script: 'productbuild --sign "$(teamId)" --root "$(build.Repository.LocalPath)/ProjectName/Build/Products/Debug/ProjectName.app" "Installation/Path/Here" /Applications/ProjectName.pkg'
- task: CmdLine@2
displayName: 'Application notarization'
inputs:
script: 'xcrun altool --notarize-app --primary-bundle-id sw.ProjectName -u "your@apple.account" -p $(appSpecificPassword) --file /Applications/ProjectName.pkg'
- task: CopyFiles@2
displayName: 'Swift - Create Artifact'
inputs:
SourceFolder: 'Build/Location/Goes/Here' # PLACEHOLDER LOCATION
TargetFolder: '$(Build.ArtifactStagingDirectory)/drop'
- task: PublishPipelineArtifact@1
displayName: 'Swift - Publish Artifact'
inputs:
targetPath: '$(Pipeline.Workspace)'
artifactName: '$(artifactName)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment