Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CI Artifact Names, Android and Firebase Conf. Injection #35

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,18 @@ stages:
androidArtifactName: 'GeneratedAndroidArtifact_Staging'
androidKeyPropertiesFile: $(InternalKeyProperties)
androidVariableGroup: 'FlutterApplicationTemplate.Distribution.Internal.Android'
iosArtifactName: 'GeneratediOSArtifact_Staging'
iosProvisioningProfileFile: $(InternalProvisioningProfile)
iosExportOptionsFile: $(InternalExportOptions)
iosCertificateFile: $(InternalCertificate)
iosVariableGroup: 'FlutterApplicationTemplate.Distribution.Internal.iOS'
releaseNotesArtifactName: 'GeneratedReleaseNotes_Staging'
firebaseJsonFile: $(InternalFirebaseJson)
firebaseOptionsDartFile: $(InternalFirebaseOptionsDart)
googleServicesJsonFile: $(InternalGoogleServicesJson)

- stage: Publish_Template_Package
condition: and(succeeded(), eq(variables['IsLightBuild'], 'false'), eq(variables['IsReleaseBranch'], 'true'))
condition: and(succeeded(), eq(variables['IsPullRequestBuild'], 'false'), eq(variables['IsReleaseBranch'], 'true'))
dependsOn:
- CopyTool_GeneratedApp
- Build_Staging_GeneratedApp
Expand All @@ -78,9 +83,12 @@ stages:
iosCertificateFile: $(InternalCertificate)
iosVariableGroup: 'FlutterApplicationTemplate.Distribution.Internal.iOS'
BannerVersionNameText: 'STAGING'
firebaseJsonFile: $(InternalFirebaseJson)
firebaseOptionsDartFile: $(InternalFirebaseOptionsDart)
googleServicesJsonFile: $(InternalGoogleServicesJson)

- stage: AppCenter_TestFlight_Staging
condition: and(succeeded(), eq(variables['IsLightBuild'], 'false'))
condition: and(succeeded(), eq(variables['IsPullRequestBuild'], 'false'))
dependsOn: Build_Staging
jobs:
- template: stage-release-appcenter.yml
Expand All @@ -100,7 +108,7 @@ stages:

- stage: Build_Production
dependsOn: Build_Staging
condition: and(succeeded(), eq(variables['IsLightBuild'], 'false'))
condition: and(succeeded(), eq(variables['IsPullRequestBuild'], 'false'))
Marc-Antoine-Soucy marked this conversation as resolved.
Show resolved Hide resolved
jobs:
- template: stage-build.yml
parameters:
Expand All @@ -112,9 +120,12 @@ stages:
iosExportOptionsFile: $(AppStoreExportOptions)
iosCertificateFile: $(AppStoreCertificate)
iosVariableGroup: 'FlutterApplicationTemplate.Distribution.AppStore'
firebaseJsonFile: $(FirebaseJson)
firebaseOptionsDartFile: $(FirebaseOptionsDart)
googleServicesJsonFile: $(GoogleServicesJson)

- stage: AppCenter_Production
condition: and(succeeded(), eq(variables['IsLightBuild'], 'false'))
condition: and(succeeded(), eq(variables['IsPullRequestBuild'], 'false'))
dependsOn: Build_Production
jobs:
- template: stage-release-appcenter.yml
Expand All @@ -128,7 +139,7 @@ stages:
appCenterDistributionGroup: $(AppCenterDistributionGroup)

- stage: AppStore
condition: and(succeeded(), eq(variables['IsLightBuild'], 'false'))
condition: and(succeeded(), eq(variables['IsPullRequestBuild'], 'false'))
dependsOn: Build_Production
jobs:
- template: stage-release-appstore.yml
Expand All @@ -137,7 +148,7 @@ stages:
deploymentEnvironment: AppStore

- stage: GooglePlay
condition: and(succeeded(), eq(variables['IsLightBuild'], 'false'))
condition: and(succeeded(), eq(variables['IsPullRequestBuild'], 'false'))
dependsOn: Build_Production
jobs:
- template: stage-release-googleplay.yml
Expand Down
22 changes: 20 additions & 2 deletions build/stage-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
- name: androidArtifactName
type: string
default: $(AndroidArtifactName)_$(applicationEnvironment)
- name: iosArtifactName
type: string
default: $(iOSArtifactName)_$(applicationEnvironment)
- name: androidKeyStoreFile
type: string
default: ''
Expand Down Expand Up @@ -35,6 +38,9 @@
- name: removeHyperlinksFromReleaseNotes
type: boolean
default: false
- name: releaseNotesArtifactName
type: string
default: $(ReleaseNotesArtifactName)
- name: pathToSrc
type: string
default: '$(Build.SourcesDirectory)/src'
Expand All @@ -44,13 +50,19 @@
- name: BannerVersionNameText
type: string
default: ''
- name: firebaseJsonFile
type: string
- name: firebaseOptionsDartFile
type: string
- name: googleServicesJsonFile
type: string

jobs:
- job: OnWindows_ReleaseNotes
pool:
vmImage : $(windowsHostedAgentImage)
variables:
ArtifactName: ReleaseNotes_${{ parameters.artifactName }}
ArtifactName: ${{ parameters.releaseNotesArtifactName }}
ApplicationEnvironment: ${{ parameters.applicationEnvironment }}
steps:
- template: steps-build-release-notes.yml
Expand Down Expand Up @@ -105,6 +117,9 @@ jobs:
projectName: ${{ parameters.projectName }}
androidKeystoreFile: ${{ parameters.androidKeyStoreFile }}
androidKeyStorePropertiesFile: ${{ parameters.androidKeyPropertiesFile }}
firebaseJsonFile: '${{ parameters.firebaseJsonFile }}'
firebaseOptionsDartFile: '${{ parameters.firebaseOptionsDartFile }}'
googleServicesJsonFile: '${{ parameters.googleServicesJsonFile }}'

- job: OnMac_iOS
pool:
Expand All @@ -126,4 +141,7 @@ jobs:
iosCertificatePassword: ${{ parameters.iosCertificatePassword }}
iosProvisioningProfileFile: ${{ parameters.iosProvisioningProfileFile }}
iosExportOptionsFile: ${{ parameters.iosExportOptionsFile }}
BannerVersionNameText: ${{ parameters.BannerVersionNameText }}
BannerVersionNameText: ${{ parameters.BannerVersionNameText }}
firebaseJsonFile: '${{ parameters.firebaseJsonFile }}'
firebaseOptionsDartFile: '${{ parameters.firebaseOptionsDartFile }}'
googleServicesJsonFile: '${{ parameters.googleServicesJsonFile }}'
16 changes: 13 additions & 3 deletions build/steps-build-android.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
parameters:
- name: androidKeystoreFile
type: string
default: ''
- name: androidKeyStorePropertiesFile
type: string
default: ''
- name: pathToSrc
type: string
default: ''
- name: projectName
type: string
default: '$(ProjectName)'
- name: firebaseJsonFile
type: string
- name: firebaseOptionsDartFile
type: string
- name: googleServicesJsonFile
type: string

steps:
#-if false
Expand All @@ -31,6 +34,13 @@ steps:

- template: templates/flutter-install.yml

- template : templates/replace-firebase-config.yml
parameters:
pathToSrc: '${{ parameters.pathToSrc }}'
firebaseJsonFile: '${{ parameters.firebaseJsonFile }}'
firebaseOptionsDartFile: '${{ parameters.firebaseOptionsDartFile }}'
googleServicesJsonFile: '${{ parameters.googleServicesJsonFile }}'

- task: DownloadSecureFile@1
name: keyStore
displayName: "Download Keystore from Secure Files"
Expand Down
23 changes: 15 additions & 8 deletions build/steps-build-ios.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
parameters:
- name: iosCertificateFile
type: string
default: ''
- name: iosCertificatePassword
type: string
default: ''
- name: iosProvisioningProfileFile
type: string
default: ''
- name: iosExportOptionsFile
type: string
default: ''
- name: pathToSrc
type: string
default: ''
- name: projectName
type: string
default: '$(ProjectName)'
- name: BannerVersionNameText
type: string
default: ''
- name: firebaseJsonFile
type: string
- name: firebaseOptionsDartFile
type: string
- name: googleServicesJsonFile
type: string

steps:
#-if false
Expand Down Expand Up @@ -47,6 +47,13 @@ steps:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: ${{ parameters.iosProvisioningProfileFile }}

- template : templates/replace-firebase-config.yml
parameters:
pathToSrc: '${{ parameters.pathToSrc }}'
firebaseJsonFile: '${{ parameters.firebaseJsonFile }}'
firebaseOptionsDartFile: '${{ parameters.firebaseOptionsDartFile }}'
googleServicesJsonFile: '${{ parameters.googleServicesJsonFile }}'

# Flutter project signing process goes through exportOptions.plist file which holds secure information about signing.
- task: DownloadSecureFile@1
name: exportOptions
Expand Down Expand Up @@ -96,7 +103,7 @@ steps:
condition: failed()

- task: Xcode@5
condition: and(succeeded(), eq(variables['IsLightBuild'], 'false'))
condition: and(succeeded(), eq(variables['IsPullRequestBuild'], 'false'))
displayName: 'Xcode Archive iOS'
inputs:
actions: 'archive'
Expand All @@ -115,7 +122,7 @@ steps:
provisioningProfileName: '$(provisioningProfile.provisioningProfileName)'

- task: CopyFiles@2
condition: and(succeeded(), eq(variables['IsLightBuild'], 'false'))
condition: and(succeeded(), eq(variables['IsPullRequestBuild'], 'false'))
displayName: 'Copy Binary Files'
inputs:
sourceFolder: '${{ parameters.pathToSrc }}/app'
Expand Down
42 changes: 42 additions & 0 deletions build/templates/replace-firebase-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
parameters:
- name: pathToSrc
type: string
- name: firebaseJsonFile
type: string
- name: firebaseOptionsDartFile
type: string
- name: googleServicesJsonFile
type: string

steps:
- task: DownloadSecureFile@1
name: firebaseJson
displayName: "Download Keystore from Secure Files"
inputs:
secureFile: ${{ parameters.firebaseJsonFile }}

- task: DownloadSecureFile@1
name: firebaseOptionsDart
displayName: "Download Keystore from Secure Files"
inputs:
secureFile: ${{ parameters.firebaseOptionsDartFile }}

- task: DownloadSecureFile@1
name: googleServicesJson
displayName: "Download Keystore from Secure Files"
inputs:
secureFile: ${{ parameters.googleServicesJsonFile }}

- task: PowerShell@2
displayName: Copy Firebase Configuration Files
inputs:
targetType: 'inline'
script: |
Copy-Item -Path '$(firebaseJson.secureFilePath)' -Destination '${{ parameters.pathToSrc }}\app\firebase.json'
Write-Host 'Firebase.json copied to ${{ parameters.pathToSrc }}/app/firebase.json'

Copy-Item -Path '$(firebaseOptionsDart.secureFilePath)' -Destination '${{ parameters.pathToSrc }}\app\lib\firebase_options.dart'
Write-Host 'FirebaseOptions.Dart copied to ${{ parameters.pathToSrc }}/app/lib/firebase_options.dart'

Copy-Item -Path '$(googleServicesJson.secureFilePath)' -Destination '${{ parameters.pathToSrc }}\app\android\app\google-services.json'
Write-Host 'GoogleServices.json copied to ${{ parameters.pathToSrc }}\app\android\app\google-services.json'
13 changes: 11 additions & 2 deletions build/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
AppStoreExportOptions: com.nventive.flutterapptemplate.exportOptions.plist # This is the export options file for the AppStore (Production distribution) builds.
AppStoreCertificate: nventive.p12 # This is the client production certificate used to sign AppStore builds.

# Firebase
InternalFirebaseJson: firebase-flutter-internal.json
InternalFirebaseOptionsDart: firebase_options-flutter-internal.dart
InternalGoogleServicesJson: google-services-flutter-internal.json
FirebaseJson: firebase-flutter.json
FirebaseOptionsDart: firebase_options-flutter.dart
GoogleServicesJson: google-services-flutter.json

# Prerequisites - Service connections.
# Make sure you have the following service connections in your Azure pipeline library.
GooglePlayServiceConnection: GooglePlay-nventive-ApplicationTemplate
Expand Down Expand Up @@ -71,9 +79,10 @@
iOSArtifactName: iOS
WindowsArtifactName: Windows
TestsArtifactName: Tests
ReleaseNotesArtifactName: ReleaseNotes

# For Application.Building.Light optimizations.
IsLightBuild: $[eq(variables['Build.Reason'], 'PullRequest')]
# To know if it's a Pull Request build.
IsPullRequestBuild: $[eq(variables['Build.Reason'], 'PullRequest')]

# Pipeline configuration (Disable shallow fetch).
# See https://dev.to/kkazala/azure-devops-pipelines-shallow-fetch-1-is-now-default-4656 for more details.
Expand Down
10 changes: 5 additions & 5 deletions doc/AzurePipelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ It also runs automated tests during the build steps.
### Pull request runs

Due to the length of mobile builds, pipelines are configured to behave a little differently when building in a context of **pull request (PR) build validation**.
To reduce the build time, some stages and steps are disabled for PR builds.
This requires a specific variable called `IsLightBuild` to be set, hence why it is appearing in the pipeline.
To reduce the CI/CD utilization time, some stages and steps are disabled for PR builds.
This requires a specific variable called `IsPullRequestBuild` to be set, hence why it is appearing in the pipeline.

Also, all release stages are disabled in the context of PR build validation because, with the optimizations differences, the resulting application would not represent the real thing.
Also, all release stages are disabled in the context of PR build validation.

### Release runs

Pipeline runs **triggered on the main branch** don't qualify for `IsLightBuild` and build the application with the goal of releasing it.
Pipeline runs **triggered on the main branch** don't qualify for `IsPullRequestBuild` and build the application with the goal of releasing it.
All stages are therefore enabled.

## Stages and Steps
Expand Down Expand Up @@ -67,7 +67,7 @@ This is where the exact build steps are defined. These vary depending on the pla
1. Install and run [GitVersion](https://gitversion.net/) to calculate the semantic version based on the Git history.
1. Install the proper signing certificates (depending on the platform).
1. Build the application.
1. Archive the application (if on iOS and depending on `IsLightBuild`).
1. Archive the application (if on iOS and depending on `IsPullRequestBuild`).
1. Run the tests and publish both the test results and the code coverage results.
1. Push the built artifacts (.ipa, .aab, release notes, etc.).
1. Cleanup.
Expand Down
Loading