|
| 1 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +# Licensed under the MIT License. |
| 3 | + |
| 4 | +name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r) |
| 5 | + |
| 6 | +trigger: |
| 7 | + tags: |
| 8 | + include: |
| 9 | + - "v*" |
| 10 | + branches: |
| 11 | + include: |
| 12 | + - main |
| 13 | + |
| 14 | +parameters: |
| 15 | + - name: previewBranch |
| 16 | + type: string |
| 17 | + default: "refs/heads/main" |
| 18 | + |
| 19 | +resources: |
| 20 | + repositories: |
| 21 | + - repository: 1ESPipelineTemplates |
| 22 | + type: git |
| 23 | + name: 1ESPipelineTemplates/1ESPipelineTemplates |
| 24 | + ref: refs/tags/release |
| 25 | + |
| 26 | +extends: |
| 27 | + template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates |
| 28 | + parameters: |
| 29 | + sdl: |
| 30 | + sourceAnalysisPool: |
| 31 | + name: Azure-Pipelines-1ESPT-ExDShared |
| 32 | + os: windows |
| 33 | + image: windows-latest |
| 34 | + |
| 35 | + stages: |
| 36 | + - stage: build |
| 37 | + jobs: |
| 38 | + - job: build |
| 39 | + pool: |
| 40 | + name: Azure-Pipelines-1ESPT-ExDShared |
| 41 | + os: linux |
| 42 | + image: ubuntu-latest |
| 43 | + #TODO maybe missing template context with sdl baselines? |
| 44 | + steps: |
| 45 | + - checkout: self |
| 46 | + persistCredentials: true |
| 47 | + |
| 48 | + - task: JavaToolInstaller@1 |
| 49 | + inputs: |
| 50 | + versionSpec: '21' |
| 51 | + jdkArchitectureOption: 'x64' |
| 52 | + jdkSourceOption: 'PreInstalled' |
| 53 | + |
| 54 | + - task: DownloadSecureFile@1 |
| 55 | + inputs: |
| 56 | + secureFile: 'local.properties' |
| 57 | + |
| 58 | + - task: DownloadSecureFile@1 |
| 59 | + inputs: |
| 60 | + secureFile: 'secring.gpg' |
| 61 | + |
| 62 | + - displayName: Copy secring |
| 63 | + pwsh: | |
| 64 | + Copy-Item secring.gpg components/abstractions/ -Verbose |
| 65 | + Copy-Item secring.gpg components/authentication/azure/ -Verbose |
| 66 | + Copy-Item secring.gpg components/serialization/form/ -Verbose |
| 67 | + Copy-Item secring.gpg components/serialization/text/ -Verbose |
| 68 | + Copy-Item secring.gpg components/serialization/json/ -Verbose |
| 69 | + Copy-Item secring.gpg components/serialization/multipart/ -Verbose |
| 70 | + Copy-Item secring.gpg components/http/okHttp/ -Verbose |
| 71 | + Copy-Item secring.gpg components/bundle/ -Verbose |
| 72 | +
|
| 73 | + - shell: ./gradlew --no-daemon publishToMavenLocal |
| 74 | + displayName: Publish to local Maven |
| 75 | + if: not(contains(variables['build.sourceBranch'], 'refs/tags/v')) |
| 76 | + |
| 77 | + - shell: ./gradlew --no-daemon publishToMavenLocal -PmavenCentralSnapshotArtifactSuffix="" |
| 78 | + displayName: Publish to local Maven |
| 79 | + if: contains(variables['build.sourceBranch'], 'refs/tags/v') |
| 80 | + |
| 81 | + - displayName: Get current SNAPSHOT version |
| 82 | + pwsh: | |
| 83 | + $contents = Get-Content gradle.properties -Raw |
| 84 | + $major = $contents | Select-String -Pattern 'mavenMajorVersion = ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value } |
| 85 | + $minor = $contents | Select-String -Pattern 'mavenMinorVersion = ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value } |
| 86 | + $patch = $contents | Select-String -Pattern 'mavenPatchVersion = ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value } |
| 87 | + $version = "$major.$minor.$patch$Env:SNAPSHOT_SUFFIX" |
| 88 | + echo "Current version is $version" |
| 89 | + echo "##vso[task.setvariable variable=PACKAGE_VERSION;isOutput=true]$version" |
| 90 | + env: |
| 91 | + ${{ if contains(variables['build.sourceBranch'], 'refs/tags/v') }}: |
| 92 | + SNAPSHOT_SUFFIX: '-SNAPSHOT' |
| 93 | + |
| 94 | + - displayName: Inspect contents of local Maven cache |
| 95 | + pwsh: | |
| 96 | + .\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-abstractions -Version $env:PACKAGE_VERSION |
| 97 | + .\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-authentication-azure -Version $env:PACKAGE_VERSION |
| 98 | + .\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-http-okHttp -Version $env:PACKAGE_VERSION |
| 99 | + .\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-serialization-form -Version $env:PACKAGE_VERSION |
| 100 | + .\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-serialization-json -Version $env:PACKAGE_VERSION |
| 101 | + .\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-serialization-text -Version $env:PACKAGE_VERSION |
| 102 | + .\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-serialization-multipart -Version $env:PACKAGE_VERSION |
| 103 | + .\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-bundle -Version $env:PACKAGE_VERSION |
| 104 | +
|
| 105 | + - displayName: Zip contents of local Maven cache |
| 106 | + pwsh: | |
| 107 | + .\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-abstractions -Version $env:PACKAGE_VERSION |
| 108 | + .\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-authentication-azure -Version $env:PACKAGE_VERSION |
| 109 | + .\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-http-okHttp -Version $env:PACKAGE_VERSION |
| 110 | + .\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-serialization-form -Version $env:PACKAGE_VERSION |
| 111 | + .\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-serialization-json -Version $env:PACKAGE_VERSION |
| 112 | + .\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-serialization-text -Version $env:PACKAGE_VERSION |
| 113 | + .\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-serialization-multipart -Version $env:PACKAGE_VERSION |
| 114 | + .\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-bundle -Version $env:PACKAGE_VERSION |
| 115 | + env: |
| 116 | + OUTPUT_DIRECTORY: $(Build.ArtifactStagingDirectory) |
| 117 | + |
| 118 | + - task: 1ES.PublishPipelineArtifact@1 |
| 119 | + displayName: "Publish Artifact: jars" |
| 120 | + inputs: |
| 121 | + artifactName: jars |
| 122 | + targetPath: "$(Build.ArtifactStagingDirectory)/*.zip" |
| 123 | + |
| 124 | + |
0 commit comments