diff --git a/.gitignore b/.gitignore index 06ef8e6..f5b6f95 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,6 @@ migrate_working_dir/ .packages .pub-cache/ .pub/ -/build/ pubspec.lock # Web related diff --git a/CHANGELOG.md b/CHANGELOG.md index d977cc6..3a14808 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. \ No newline at end of file diff --git a/build/azure-pipelines.yml b/build/azure-pipelines.yml index 5fd496e..a7f1122 100644 --- a/build/azure-pipelines.yml +++ b/build/azure-pipelines.yml @@ -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() \ No newline at end of file diff --git a/build/gitversion-config.yml b/build/gitversion-config.yml new file mode 100644 index 0000000..39fe8ec --- /dev/null +++ b/build/gitversion-config.yml @@ -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: [] \ No newline at end of file diff --git a/build/variables.yml b/build/variables.yml new file mode 100644 index 0000000..0bdf90d --- /dev/null +++ b/build/variables.yml @@ -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 \ No newline at end of file