Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ESRP Release to Maven Central #29153

Merged
merged 2 commits into from May 31, 2022
Merged

Conversation

hallipr
Copy link
Member

@hallipr hallipr commented May 31, 2022

Add support for publishing individual packages to maven central via ESRP Release.

The release task has approver statically set. For now, releases are auto approved so this won't matter. We may need to find a way to have a dynamic set of approvers added to the task based on the library being released.

@ghost ghost added the azure-spring All azure-spring related issues label May 31, 2022
$sourcesArtifact = $packageDetail.AssociatedArtifacts | Where-Object { ($_.Classifier -eq "sources") -and ($_.Type -eq "jar") }

[AssociatedArtifact[]]$additionalArtifacts = $packageDetail.AssociatedArtifacts | Where-Object {
($_ -ne $pomArtifact) -and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: -NotIn might be simpler here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copied from the artifact handling in Publish-MavenPackages.ps1. I'm intentionally changing little until I can make a refactor PR to unify the mvn cli argument handling between GPG signing and deployment.

$commaDelimitedTypes = ""

if ($null -ne $packageDetail.AdditionalArtifacts) {
foreach($additionalArtifact in $packageDetail.AdditionalArtifacts) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Probably simpler here to use an array and then use -join rather than constructing the string and then cutting the leading comma off.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Same as before though. I'd rather address in a refactor pr than add a different implementation in this file.

if ($additionalAssociatedArtifacts -ne $null) {
$commaDelimitedFileNames = ""
$additionalAssociatedArtifacts | ForEach-Object { $commaDelimitedFileNames += ",$($_.File.FullName)" }
$filesOption = "-Dfiles=$($commaDelimitedFileNames.Substring(1))"
$commaDelimitedClassifiers = ""
$additionalAssociatedArtifacts | ForEach-Object { $commaDelimitedClassifiers += ",$($_.Classifier)" }
$classifiersOption = "-Dclassifiers=$($commaDelimitedClassifiers.Substring(1))"
$commaDelimitedTypes = ""
$additionalAssociatedArtifacts | ForEach-Object { $commaDelimitedTypes += ",$($_.Type)" }
$typesOption = "-Dtypes=$($commaDelimitedTypes.Substring(1))"
}

Copy link
Member

@benbp benbp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple nits that don't matter. Initial change LGTM to me though agreed we'll probably want a codeowner/approver solution eventually.

@hallipr
Copy link
Member Author

hallipr commented May 31, 2022

Bypassing check enforcer. The change tested well with this pipeline run:
https://dev.azure.com/azure-sdk/internal/_build/results?buildId=1611796&view=results

@hallipr
Copy link
Member Author

hallipr commented May 31, 2022

/check-enforcer override

@hallipr hallipr merged commit f324f60 into main May 31, 2022
@hallipr hallipr deleted the pahallis/esrp-release branch May 31, 2022 22:39
GroupID: ${{artifact.groupId}}
ArtifactDirectory: $(Pipeline.Workspace)/${{parameters.ArtifactName}}-signed
OutputDirectory: $(Pipeline.Workspace)/EsrpPackages
Target: EsrpRelease
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking to see what the difference is between these two blocks it seems like we could just default things like the output and artifact name based on the Target and simply have one call to the java-publishing.yml while setting the Target via a variable we define above.

ArtifactPath: $(Pipeline.Workspace)/${{parameters.ArtifactName}}-signed
- ${{ if eq(parameters.UseEsrpRelease, 'true') }}:
- template: /eng/pipelines/templates/steps/java-publishing.yml
parameters:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar feedback here about using a variable instead of duplicating the template parameters.

PackageLocation: $(PackageLocation)
Owners: $(Build.RequestedForEmail)
Approvers: 'wesh@microsoft.com'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required to be listed here? Also does this mean I need to approve all the releases? Can we use an alias or the bot account instead?

Target: MavenCentral
BuildToolsPath: $(Pipeline.Workspace)/azure-sdk-build-tools
JavaRepoRoot: $(Pipeline.Workspace)/azure-sdk-for-java
- template: /eng/common/pipelines/templates/steps/publish-artifact.yml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we think it is worth adding this publish artifact step in the java-publishing.yml template? It seems like we are doing these 2 steps connected in the places I see here.

function Get-RandomRepositoryDirectory() {
Write-Host "Getting random repository directory."
$randomSubDirectoryName = [System.IO.Path]::GetRandomFileName()
$randomRepositoryDirectory = New-Item -Type Directory -Path $env:TEMP -Name $randomSubDirectoryName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we want to use Temp here? As opposed to just a directory under the working directory?

}

function ConvertTo-DeploymentDetails($PackageDetail) {
$pomArtifact = $packageDetail.AssociatedArtifacts | Where-Object { ($null -eq $_.Classifier) -and ($_.Type -eq "pom") }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We should consider using .Where({...}) over | Where-Object as it will ensure you always end up with an array.

anushkasingh16 pushed a commit to anushkasingh16/azure-sdk-for-java that referenced this pull request Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure-spring All azure-spring related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants