Skip to content

Commit

Permalink
feat: Migrate Azure pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee31416 committed Jun 3, 2024
1 parent 2a63be4 commit 29a0c9e
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 16 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ migrate_working_dir/
.packages
.pub-cache/
.pub/
/build/
pubspec.lock

# Web related
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
## Before Initial Release

- feat: initial commit 🎉
- Migrated the pipeline from the .NET version of the package.
77 changes: 62 additions & 15 deletions build/azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,71 @@
trigger:
branches:
include:
- main
- main
pr:
branches:
include:
- main

variables:
- name: windowsHostedAgentImage
value: 'windows-2022'
- name: IsReleaseBranch # Should this branch name use the release stage.
value: $[or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), startsWith(variables['Build.SourceBranch'], 'refs/heads/feature/'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'))]
- template: variables.yml

pool:
vmImage: 'ubuntu-latest'

steps:

- task: Hey24sheep.flutter.flutter-install.FlutterInstall@0
displayName: 'Flutter Install'

- task: gitversion/setup@0
retryCountOnTaskFailure: 3
inputs:
versionSpec: '5.12.0'
displayName: 'Install GitVersion'

- task: gitversion/execute@0
inputs:
useConfigFile: true
configFilePath: $(Build.SourcesDirectory)/build/gitversion-config.yml
displayName: 'Calculate App Version'

# There is currently no other alternatives for setting the app version using gitversion.
- powershell: |
((Get-Content -Path pubspec.yaml) -replace '(version:\s*)[\d\.]+', "version: $(GitVersion.MajorMinorPatch)") | Set-Content -Path pubspec.yaml
displayName: Replace version powershell command
- script : flutter doctor
displayName : Run flutter doctor

- script: flutter pub get
displayName: Install dependencies

- script: flutter analyze
displayName: Analyze code

- script: flutter build
displayName: Build app

- script: flutter test
displayName: Run tests

stages:
- stage: OnWindows_
jobs:
- job: Test Pipeline
- script: flutter pub publish --dry-run
displayName: 'Run flutter pub publish --dry-run'

pool:
vmImage: $(windowsHostedAgentImage)
- task: DownloadSecureFile@1
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), eq(variables['IsReleaseBranch'], 'true'))
inputs:
secureFile: 'flutter_publisher_gckey.json'
name: DownloadGCloudKey

workspace:
clean: all # Cleanup the workspace before starting.
- script: |
gcloud auth activate-service-account --key-file=$(DownloadGCloudKey.secureFilePath)
gcloud auth print-identity-token --audiences=https://pub.dev | dart pub token add https://pub.dev
dart pub publish --force
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), eq(variables['IsReleaseBranch'], 'true'))
displayName: 'Publish to pub.dev as a nventive publisher'
steps:
- script: echo Hello world!
- task: PostBuildCleanup@3
displayName: 'Post-Build Cleanup: Cleanup files to keep build server clean!'
condition: always()
27 changes: 27 additions & 0 deletions build/gitversion-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# The version is driven by conventional commits via xxx-version-bump-message.
# Anything merged to main creates a new stable version.
# Only builds from main and feature/* are pushed to nuget.org.

assembly-versioning-scheme: MajorMinorPatch
mode: MainLine
next-version: '' # Use git tags to set the base version.
continuous-delivery-fallback-tag: ""
commit-message-incrementing: Enabled
major-version-bump-message: "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)"
minor-version-bump-message: "^(feat)(\\([\\w\\s-]*\\))?:"
patch-version-bump-message: "^(build|chore|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:"
no-bump-message: "^(ci|benchmarks)(\\([\\w\\s-]*\\))?:" # You can use the "ci" or "benchmarks" type to avoid bumping the version when your changes are limited to the [build or .github folders] or limited to benchmark code.
branches:
main:
regex: ^master$|^main$
tag: ''
dev:
regex: dev/.*?/(.*?)
tag: dev.{BranchName}
source-branches: [main]
feature:
tag: feature.{BranchName}
regex: feature/(.*?)
source-branches: [main]
ignore:
sha: []
7 changes: 7 additions & 0 deletions build/variables.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
variables:
IsReleaseBranch: $[eq(variables['Build.SourceBranch'], 'refs/heads/main')]

# Pipeline configuration (Disable shallow fetch).
# See https://dev.to/kkazala/azure-devops-pipelines-shallow-fetch-1-is-now-default-4656 for more details.
# See https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/pipeline-options-for-git?view=azure-devops&tabs=yaml#shallow-fetch for more details.
Agent.Source.Git.ShallowFetchDepth: 0

0 comments on commit 29a0c9e

Please sign in to comment.