@@ -65,29 +65,62 @@ extends:
6565 Copy-Item $(downloadLocalProperties.secureFilePath) local.properties -Verbose
6666 displayName: Copy secring and 'local.properties'
6767
68- - script : ./gradlew --no-daemon publishToMavenLocal -PmavenCentralPublishingEnabled=true -PmavenCentralSnapshotArtifactSuffix=""
69- displayName : Publish to local Maven for verification
70- condition : contains(variables['build.sourceBranch'], 'refs/tags/v')
68+ - pwsh : |
69+ # maven-gpg-plugin signs via the local gpg keyring, so the key from
70+ # secring.gpg must be imported into gpg before signing can succeed.
71+ gpg --batch --import secring.gpg
72+ displayName: Import GPG signing key
7173
72- - script : ./gradlew --no-daemon publishToMavenLocal -PmavenCentralPublishingEnabled=true
73- displayName : Publish to local Maven for verification
74- condition : not(contains(variables['build.sourceBranch'], 'refs/tags/v'))
74+ - pwsh : |
75+ $props = Get-Content local.properties -Raw
76+ $keyId = ($props | Select-String -Pattern 'signing\.keyId=(.+)').Matches.Groups[1].Value
77+ $keyPassword = ($props | Select-String -Pattern 'signing\.password=(.+)').Matches.Groups[1].Value
78+
79+ $settingsXml = @"
80+ <settings>
81+ <mirrors>
82+ <mirror>
83+ <id>GraphDeveloperExperiences_Public</id>
84+ <mirrorOf>*</mirrorOf>
85+ <url>https://microsoftgraph.pkgs.visualstudio.com/0985d294-5762-4bc2-a565-161ef349ca3e/_packaging/GraphDeveloperExperiences_Public/maven/v1</url>
86+ </mirror>
87+ </mirrors>
88+ <profiles>
89+ <profile>
90+ <id>signing</id>
91+ <properties>
92+ <gpg.keyname>$keyId</gpg.keyname>
93+ <gpg.passphrase>$keyPassword</gpg.passphrase>
94+ </properties>
95+ </profile>
96+ </profiles>
97+ </settings>
98+ "@
99+ $settingsDir = Join-Path $HOME ".m2"
100+ New-Item -ItemType Directory -Path $settingsDir -Force | Out-Null
101+ $settingsXml | Set-Content (Join-Path $settingsDir "settings.xml") -Encoding UTF8
102+ displayName: Configure Maven settings
103+
104+ - task : MavenAuthenticate@0
105+ displayName : Authenticate to Azure Artifacts feed (PAT-less)
106+ inputs :
107+ artifactsFeeds : ' GraphDeveloperExperiences_Public'
75108
76- - script : ./gradlew --no-daemon publishMavenPublicationToADORepository -PmavenCentralPublishingEnabled=true -PmavenCentralSnapshotArtifactSuffix=""
77- displayName : Publish to local Maven ADO for ESRP
78- condition : contains(variables['build.sourceBranch'], 'refs/tags/v')
109+ - script : ./mvnw install -Psigning --no-transfer-progress
110+ displayName : Publish to local Maven for verification
79111
80- - script : ./gradlew --no-daemon publishMavenPublicationToADORepository -PmavenCentralPublishingEnabled=true
81- displayName : Publish to local Maven ADO for ESRP
82- condition : not(contains(variables['build.sourceBranch'], 'refs/tags/v'))
112+ - script : ./mvnw deploy -Psigning --no-transfer-progress -DaltDeploymentRepository=ADO::default::file://$(Build.SourcesDirectory)/target/staging-deploy
113+ displayName : Stage artifacts for ESRP
83114
84115 - pwsh : |
85- $contents = Get-Content gradle.properties -Raw
86- $major = $contents | Select-String -Pattern 'mavenMajorVersion\s*=\s*([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
87- $minor = $contents | Select-String -Pattern 'mavenMinorVersion\s*=\s*([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
88- $patch = $contents | Select-String -Pattern 'mavenPatchVersion\s*=\s*([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
89- $snapshot_suffix = if ($Env:BRANCH_NAME.StartsWith('refs/tags/v')) { '' } else { '-SNAPSHOT' }
90- $version = "$major.$minor.$patch$snapshot_suffix"
116+ $pomXml = [xml](Get-Content pom.xml -Raw)
117+ $ns = New-Object System.Xml.XmlNamespaceManager($pomXml.NameTable)
118+ $ns.AddNamespace('m', $pomXml.DocumentElement.NamespaceURI)
119+ $version = $pomXml.SelectSingleNode('/m:project/m:version', $ns).InnerText
120+ # If version contains -SNAPSHOT and we're on a tag, strip it
121+ if ($Env:BRANCH_NAME.StartsWith('refs/tags/v')) {
122+ $version = $version -replace '-SNAPSHOT$', ''
123+ }
91124 echo "Current version is $version"
92125 echo "##vso[task.setvariable variable=PACKAGE_VERSION;]$version"
93126 displayName: Get current version
@@ -100,7 +133,7 @@ extends:
100133 displayName: Inspect contents of local Maven cache
101134
102135 - pwsh : |
103- $packageFullPath = Join-Path -Path "./" -ChildPath "build/publishing-repository/ com/microsoft/graph/microsoft-graph-core" -AdditionalChildPath "$(PACKAGE_VERSION)"
136+ $packageFullPath = Join-Path -Path "./target/staging-deploy " -ChildPath "com/microsoft/graph/microsoft-graph-core" -AdditionalChildPath "$(PACKAGE_VERSION)"
104137 echo "Package full path: $packageFullPath"
105138 echo "##vso[task.setvariable variable=PACKAGE_PATH;]$packageFullPath"
106139 displayName: Get the package full path
@@ -176,16 +209,6 @@ extends:
176209 $(Pipeline.Workspace)/**/*.pom.asc.sha1
177210 $(Pipeline.Workspace)/**/*.pom.asc.sha256
178211 $(Pipeline.Workspace)/**/*.pom.asc.sha512
179- $(Pipeline.Workspace)/**/*.module
180- $(Pipeline.Workspace)/**/*.module.md5
181- $(Pipeline.Workspace)/**/*.module.sha1
182- $(Pipeline.Workspace)/**/*.module.sha256
183- $(Pipeline.Workspace)/**/*.module.sha512
184- $(Pipeline.Workspace)/**/*.module.asc
185- $(Pipeline.Workspace)/**/*.module.asc.md5
186- $(Pipeline.Workspace)/**/*.module.asc.sha1
187- $(Pipeline.Workspace)/**/*.module.asc.sha256
188- $(Pipeline.Workspace)/**/*.module.asc.sha512
189212
190213 addChangeLog : false
191214 action : edit
0 commit comments