Skip to content

Commit 54487d4

Browse files
authored
Merge f8f9c2a into 6ef90df
2 parents 6ef90df + f8f9c2a commit 54487d4

File tree

15 files changed

+1118
-85
lines changed

15 files changed

+1118
-85
lines changed

eng/maven.publish.settings.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
3+
https://maven.apache.org/xsd/settings-1.0.0.xsd">
4+
<servers>
5+
<server>
6+
<id>target-repo</id>
7+
<username>${repo.username}</username>
8+
<password>${repo.password}</password>
9+
</server>
10+
</servers>
11+
12+
<profiles>
13+
<profile>
14+
<id>signing</id>
15+
<properties>
16+
<gpg.executable>${gpgexe}</gpg.executable>
17+
</properties>
18+
</profile>
19+
</profiles>
20+
21+
<activeProfiles>
22+
<activeProfile>signing</activeProfile>
23+
</activeProfiles>
24+
25+
<!--
26+
NOTE: Maven Central downloads are quite unreliable. This gives us better reliability.
27+
-->
28+
<mirrors>
29+
<mirror>
30+
<id>repo-maven-apache-org-mirror</id>
31+
<url>https://repo-maven-apache-org.azurefd.net/maven2</url>
32+
<mirrorOf>central</mirrorOf>
33+
</mirror>
34+
</mirrors>
35+
</settings>

eng/pipelines/templates/stages/archetype-android-release.yml

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
parameters:
2-
Artifacts: []
3-
ArtifactName: 'not-specified'
2+
- name: Artifacts
3+
type: object
4+
default: []
5+
- name: ArtifactName
6+
type: string
7+
default: 'not-specified'
8+
- name: DependsOn
9+
type: object
10+
- name: VerifyVersions
11+
type: string
12+
default: 'not-specified'
413

514
stages:
615
# The signing stage is responsible for submitting binaries to ESRP for our official signing
@@ -53,7 +62,7 @@ stages:
5362
- deployment: TagRepository
5463
displayName: "Create release tag"
5564
condition: ne(variables['Skip.TagRepository'], 'true')
56-
environment: github
65+
environment: maven
5766
timeoutInMinutes: 5
5867
dependsOn:
5968
- ${{ if eq(parameters.VerifyVersions, 'true')}}:
@@ -95,19 +104,35 @@ stages:
95104
steps:
96105
- checkout: azure-sdk-build-tools
97106
path: azure-sdk-build-tools
98-
- template: /tools/gpg/gpg.yml@azure-sdk-build-tools
99-
- template: /tools/java-publishing/java-publishing.yml@azure-sdk-build-tools
107+
- template: tools/gpg/gpg.yml@azure-sdk-build-tools
108+
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
109+
parameters:
110+
SkipCheckoutNone: true
111+
Repositories:
112+
- Name: Azure/azure-sdk-for-android
113+
Commitish: $(Build.SourceVersion)
114+
WorkingDirectory: $(Pipeline.Workspace)/azure-sdk-for-android
115+
- template: /eng/pipelines/templates/steps/java-publishing.yml
100116
parameters:
101117
ArtifactID: ${{artifact.name}}
102118
GroupID: ${{artifact.groupId}}
103119
ArtifactDirectory: $(Pipeline.Workspace)/${{parameters.ArtifactName}}-signed
104-
Target: MavenCentral
120+
OutputDirectory: $(Pipeline.Workspace)/EsrpPackages
121+
Target: EsrpRelease
122+
BuildToolsPath: $(Pipeline.Workspace)/azure-sdk-build-tools
123+
# Note: In spite of the fact that the variable is named JavaRepoRoot, the
124+
# root needs to be the root of the android repository
125+
JavaRepoRoot: $(Pipeline.Workspace)/azure-sdk-for-android
126+
- template: /eng/common/pipelines/templates/steps/publish-artifact.yml
127+
parameters:
128+
ArtifactName: ${{parameters.ArtifactName}}-${{artifact.name}}-esrp-$(System.JobAttempt)
129+
ArtifactPath: $(Pipeline.Workspace)/EsrpPackages
105130

106131
- ${{if ne(artifact.options.skipPublishDocs, 'true')}}:
107132
- deployment: PublishDocs
108133
displayName: Publish Docs to GitHubIO Blob Storage
109134
condition: and(succeeded(), ne(variables['Skip.PublishDocs'], 'true'))
110-
environment: githubio
135+
environment: maven
111136
dependsOn: PublishPackage
112137

113138
pool:
@@ -118,13 +143,21 @@ stages:
118143
runOnce:
119144
deploy:
120145
steps:
121-
- checkout: azure-sdk-build-tools
122-
path: azure-sdk-build-tools
123-
- template: /tools/generic-blob-upload/publish-blobs.yml@azure-sdk-build-tools
146+
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
147+
- download: current
148+
displayName: 'Download Artifact: ${{parameters.ArtifactName}}-signed'
149+
artifact: ${{parameters.ArtifactName}}-signed
150+
patterns: ${{artifact.safeName}}/**
151+
- pwsh: |
152+
Get-ChildItem -Recurse $(Pipeline.Workspace)/${{parameters.ArtifactName}}-signed/${{artifact.safeName}}
153+
workingDirectory: $(Pipeline.Workspace)
154+
displayName: Output Visible Artifacts
155+
- template: /eng/common/pipelines/templates/steps/publish-blobs.yml
124156
parameters:
125157
FolderForUpload: '$(Pipeline.Workspace)/${{parameters.ArtifactName}}-signed/${{artifact.safeName}}'
126158
BlobSASKey: '$(azure-sdk-docs-prod-sas)'
127159
BlobName: '$(azure-sdk-docs-prod-blob-name)'
128160
TargetLanguage: 'android'
161+
ArtifactLocation: $(Pipeline.Workspace)/${{parameters.ArtifactName}}-signed/${{artifact.safeName}}
129162
# we override the regular script path because we have cloned the build tools repo as a separate artifact.
130-
ScriptPath: '$(Pipeline.Workspace)/azure-sdk-build-tools/scripts/copy-docs-to-blobstorage.ps1'
163+
ScriptPath: 'eng/common/scripts/copy-docs-to-blobstorage.ps1'

eng/pipelines/templates/stages/archetype-sdk-client.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1+
resources:
2+
repositories:
3+
- repository: azure-sdk-build-tools
4+
type: git
5+
name: internal/azure-sdk-build-tools
6+
ref: refs/tags/azure-sdk-build-tools_20220920.1
7+
- repository: azure-sdk-tools
8+
type: github
9+
name: Azure/azure-sdk-tools
10+
endpoint: azure
11+
112
parameters:
2-
Artifacts: []
3-
ServiceDirectory: not-specified
4-
13+
- name: Artifacts
14+
type: object
15+
default: []
16+
- name: ServiceDirectory
17+
type: string
18+
default: not-specified
19+
520
stages:
621
- stage: Build
722
jobs:
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
parameters:
2+
ArtifactDirectory: not-specified
3+
OutputDirectory: not-specified
4+
RepositoryUrl: not-specified
5+
GroupID:
6+
ArtifactID:
7+
GPGExecutablePath: $(Pipeline.Workspace)/azure-sdk-build-tools/tools/gpg/bin/gpg.exe
8+
JavaRepoRoot: $(Pipeline.Workspace)/azure-sdk-for-java
9+
StageOnly: false
10+
ShouldPublish: true
11+
12+
steps:
13+
- ${{if eq(parameters.Target, 'Burner')}}:
14+
- task: PowerShell@2
15+
displayName: 'Publish to Burner Feed'
16+
inputs:
17+
pwsh: true
18+
workingDirectory: $(Agent.BuildDirectory)
19+
filePath: ${{ parameters.JavaRepoRoot }}/eng/scripts/Publish-MavenPackages.ps1
20+
arguments: >
21+
-ArtifactDirectory ${{ parameters.ArtifactDirectory }}
22+
-GroupIDFilter ${{ parameters.GroupID }}
23+
-ArtifactIDFilter ${{ parameters.ArtifactID }}
24+
-RepositoryUrl https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-$(Build.BuildID)/maven/v1
25+
-RepositoryUsername nobody
26+
-RepositoryPassword $(System.AccessToken)
27+
-GPGExecutablePath ${{ parameters.GPGExecutablePath }}
28+
-ShouldPublish:$${{parameters.ShouldPublish}}
29+
-InformationAction Continue
30+
31+
- ${{if eq(parameters.Target, 'JavaDevFeed')}}:
32+
- task: PowerShell@2
33+
displayName: 'Publish to Java Dev Feed'
34+
inputs:
35+
pwsh: true
36+
workingDirectory: $(Agent.BuildDirectory)
37+
filePath: ${{ parameters.JavaRepoRoot }}/eng/scripts/Publish-MavenPackages.ps1
38+
arguments: >
39+
-ArtifactDirectory ${{ parameters.ArtifactDirectory }}
40+
-GroupIDFilter ${{ parameters.GroupID }}
41+
-ArtifactIDFilter ${{ parameters.ArtifactID }}
42+
-RepositoryUrl ${{ parameters.RepositoryUrl }}
43+
-RepositoryUsername nobody
44+
-RepositoryPassword $(System.AccessToken)
45+
-GPGExecutablePath ${{ parameters.GPGExecutablePath }}
46+
-ShouldPublish:$${{parameters.ShouldPublish}}
47+
-InformationAction Continue
48+
49+
- ${{if eq(parameters.Target, 'AndroidDevFeed')}}:
50+
- task: PowerShell@2
51+
displayName: 'Publish to Andriod Public Dev Feed'
52+
inputs:
53+
pwsh: true
54+
workingDirectory: $(Agent.BuildDirectory)
55+
filePath: ${{ parameters.JavaRepoRoot }}/eng/scripts/Publish-MavenPackages.ps1
56+
arguments: >
57+
-ArtifactDirectory ${{ parameters.ArtifactDirectory }}
58+
-GroupIDFilter ${{ parameters.GroupID }}
59+
-ArtifactIDFilter ${{ parameters.ArtifactID }}
60+
-RepositoryUrl https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-android/maven/v1
61+
-RepositoryUsername nobody
62+
-RepositoryPassword $(System.AccessToken)
63+
-GPGExecutablePath ${{ parameters.GPGExecutablePath }}
64+
-ShouldPublish:$${{parameters.ShouldPublish}}
65+
-InformationAction Continue
66+
67+
- ${{if eq(parameters.Target, 'MavenCentral')}}:
68+
- task: PowerShell@2
69+
displayName: 'Publish to Maven Central'
70+
inputs:
71+
pwsh: true
72+
workingDirectory: $(Agent.BuildDirectory)
73+
filePath: ${{ parameters.JavaRepoRoot }}/eng/scripts/Publish-MavenPackages.ps1
74+
arguments: >
75+
-ArtifactDirectory ${{ parameters.ArtifactDirectory }}
76+
-GroupIDFilter "${{ parameters.GroupID }}"
77+
-ArtifactIDFilter "${{ parameters.ArtifactID }}"
78+
-RepositoryUrl https://oss.sonatype.org/service/local/staging/deploy/maven2/
79+
-RepositoryUsername azuresdk
80+
-RepositoryPassword $(azuresdk-sonatype-password)
81+
-GPGExecutablePath ${{ parameters.GPGExecutablePath }}
82+
-StageOnly:$${{parameters.StageOnly}}
83+
-ShouldPublish:$${{parameters.ShouldPublish}}
84+
-InformationAction Continue
85+
86+
- ${{if eq(parameters.Target, 'EsrpRelease')}}:
87+
- task: PowerShell@2
88+
displayName: 'Gpg sign and hash packages'
89+
inputs:
90+
pwsh: true
91+
workingDirectory: $(Agent.BuildDirectory)
92+
filePath: ${{ parameters.JavaRepoRoot }}/eng/scripts/SignAndHash-MavenPackages.ps1
93+
arguments: >
94+
-Path ${{ parameters.ArtifactDirectory }}
95+
-DestinationPath ${{ parameters.OutputDirectory }}
96+
-GroupIDFilter "${{ parameters.GroupID }}"
97+
-ArtifactIDFilter "${{ parameters.ArtifactID }}"
98+
-GPGExecutablePath ${{ parameters.GPGExecutablePath }}
99+
-InformationAction Continue
100+
- ${{if and(eq(parameters.ShouldPublish, 'true'), ne(parameters.StageOnly, 'true'))}}:
101+
- task: EsrpRelease@1
102+
displayName: 'Publish to ESRP'
103+
inputs:
104+
ConnectedServiceName: 'ESRP Release Service'
105+
Intent: 'PackageDistribution'
106+
ContentType: 'Maven'
107+
PackageLocation: $(PackageLocation)
108+
Owners: $(Build.RequestedForEmail)
109+
Approvers: '[email protected]'
110+
ServiceEndpointUrl: 'https://api.esrp.microsoft.com'
111+
MainPublisher: 'ESRPRELPACMANTEST'
112+
DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47'
113+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This step is used to prevent duplication of artifact publishes when there is an issue that would prevent the overall success of the job.
2+
# Ensuring that we only publish when successful (and two a differently named artifact otherwise) will allow easy retry on a build pipeline
3+
# without running into the "cannot override artifact" failure when we finally do get a passing run.
4+
5+
# ArtifactName - The name of the artifact in the "successful" case.
6+
# ArtifactPath - The path we will be publishing.
7+
# CustomCondition - Used if there is additional logic necessary to prevent attempt of publish.
8+
9+
parameters:
10+
ArtifactName: ''
11+
ArtifactPath: ''
12+
CustomCondition: true
13+
14+
steps:
15+
- task: PublishPipelineArtifact@1
16+
condition: and(succeeded(), ${{ parameters.CustomCondition }})
17+
displayName: 'Publish ${{ parameters.ArtifactName }} Artifacts'
18+
inputs:
19+
artifactName: '${{ parameters.ArtifactName }}'
20+
path: '${{ parameters.ArtifactPath }}'
21+
22+
- task: PublishPipelineArtifact@1
23+
condition: failed()
24+
displayName: 'Publish failed ${{ parameters.ArtifactName }} Artifacts'
25+
inputs:
26+
artifactName: '${{ parameters.ArtifactName }}-FailedAttempt$(System.JobAttempt)'
27+
path: '${{ parameters.ArtifactPath }}'

eng/scripts/Language-Settings.ps1

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function Get-AllPackageInfoFromRepo ($serviceDirectory)
2828
$pkgProp = [PackageProps]::new($pkgName, $pkgVersion, $pkgPath, $serviceDirName, $pkgGroup)
2929
$allPackageProps += $pkgProp
3030
}
31-
31+
3232
}
3333
return $allPackageProps
3434
}
@@ -41,4 +41,72 @@ function SetPackageVersion ($PackageName, $Version, $ReleaseDate, $ReplaceLatest
4141
}
4242
& "$EngDir/scripts/Update-PkgVersion.ps1" -PackageName $PackageName -NewVersionString $Version `
4343
-ReleaseDate $ReleaseDate -ReplaceLatestEntryTitle $ReplaceLatestEntryTitle
44+
}
45+
46+
function Publish-andriod-GithubIODocs ($DocLocation, $PublicArtifactLocation)
47+
{
48+
$PublishedDocs = Get-ChildItem "$DocLocation" | Where-Object -FilterScript {$_.Name.EndsWith("-javadoc.jar")}
49+
foreach ($Item in $PublishedDocs)
50+
{
51+
$UnjarredDocumentationPath = ""
52+
try
53+
{
54+
$PkgName = $Item.BaseName
55+
# The jar's unpacking command doesn't allow specifying a target directory
56+
# and will unjar all of the files in whatever the current directory is.
57+
# Create a subdirectory to unjar into, set the location, unjar and then
58+
# set the location back to its original location.
59+
$UnjarredDocumentationPath = Join-Path -Path $DocLocation -ChildPath $PkgName
60+
New-Item -ItemType directory -Path "$UnjarredDocumentationPath"
61+
$CurrentLocation = Get-Location
62+
Set-Location $UnjarredDocumentationPath
63+
jar -xf "$($Item.FullName)"
64+
Set-Location $CurrentLocation
65+
66+
# If javadocs are produced for a library with source, there will always be an
67+
# index.html. If this file doesn't exist in the UnjarredDocumentationPath then
68+
# this is a sourceless library which means there are no javadocs and nothing
69+
# should be uploaded to blob storage.
70+
$IndexHtml = Join-Path -Path $UnjarredDocumentationPath -ChildPath "index.html"
71+
if (!(Test-Path -path $IndexHtml))
72+
{
73+
Write-Host "$($PkgName) does not have an index.html file, skipping."
74+
continue
75+
}
76+
77+
# Get the POM file for the artifact we're processing
78+
$PomFile = $Item.FullName.Substring(0,$Item.FullName.LastIndexOf(("-javadoc.jar"))) + ".pom"
79+
Write-Host "PomFile $($PomFile)"
80+
81+
# Pull the version from the POM
82+
[xml]$PomXml = Get-Content $PomFile
83+
$Version = $PomXml.project.version
84+
$ArtifactId = $PomXml.project.artifactId
85+
86+
# inject the ga tag just before we upload the index to storage.
87+
$indexContent = Get-Content -Path $IndexHtml -Raw
88+
$tagContent = Get-Content -Path $CampaignTag -Raw
89+
90+
$indexContent = $indexContent.Replace("</head>", $tagContent + "</head>")
91+
Set-Content -Path $IndexHtml -Value $indexContent -NoNewline
92+
93+
Write-Host "Start Upload for $($PkgName)/$($Version)"
94+
Write-Host "DocDir $($UnjarredDocumentationPath)"
95+
Write-Host "PkgName $($ArtifactId)"
96+
Write-Host "DocVersion $($Version)"
97+
$releaseTag = RetrieveReleaseTag $PublicArtifactLocation
98+
Upload-Blobs -DocDir $UnjarredDocumentationPath -PkgName $ArtifactId -DocVersion $Version -ReleaseTag $releaseTag
99+
}
100+
Finally
101+
{
102+
if (![string]::IsNullOrEmpty($UnjarredDocumentationPath))
103+
{
104+
if (Test-Path -Path $UnjarredDocumentationPath)
105+
{
106+
Write-Host "Cleaning up $UnjarredDocumentationPath"
107+
Remove-Item -Recurse -Force $UnjarredDocumentationPath
108+
}
109+
}
110+
}
111+
}
44112
}

0 commit comments

Comments
 (0)