Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions .azure-pipelines/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)

trigger:
tags:
include:
- "v*"
branches:
include:
- main

parameters:
- name: previewBranch
type: string
default: "refs/heads/main"

resources:
repositories:
- repository: 1ESPipelineTemplates
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release

extends:
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
parameters:
sdl:
sourceAnalysisPool:
name: Azure-Pipelines-1ESPT-ExDShared
os: windows
image: windows-latest

stages:
- stage: build
jobs:
- job: build
pool:
name: Azure-Pipelines-1ESPT-ExDShared
os: linux
image: ubuntu-latest
#TODO maybe missing template context with sdl baselines?
steps:
- checkout: self
persistCredentials: true

- task: JavaToolInstaller@1
inputs:
versionSpec: '21'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'

- task: DownloadSecureFile@1
inputs:
secureFile: 'local.properties'

- task: DownloadSecureFile@1
inputs:
secureFile: 'secring.gpg'

- displayName: Copy secring
pwsh: |
Copy-Item secring.gpg components/abstractions/ -Verbose
Copy-Item secring.gpg components/authentication/azure/ -Verbose
Copy-Item secring.gpg components/serialization/form/ -Verbose
Copy-Item secring.gpg components/serialization/text/ -Verbose
Copy-Item secring.gpg components/serialization/json/ -Verbose
Copy-Item secring.gpg components/serialization/multipart/ -Verbose
Copy-Item secring.gpg components/http/okHttp/ -Verbose
Copy-Item secring.gpg components/bundle/ -Verbose

- shell: ./gradlew --no-daemon publishToMavenLocal
displayName: Publish to local Maven
if: not(contains(variables['build.sourceBranch'], 'refs/tags/v'))

- shell: ./gradlew --no-daemon publishToMavenLocal -PmavenCentralSnapshotArtifactSuffix=""
displayName: Publish to local Maven
if: contains(variables['build.sourceBranch'], 'refs/tags/v')

- displayName: Get current SNAPSHOT version
pwsh: |
$contents = Get-Content gradle.properties -Raw
$major = $contents | Select-String -Pattern 'mavenMajorVersion = ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
$minor = $contents | Select-String -Pattern 'mavenMinorVersion = ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
$patch = $contents | Select-String -Pattern 'mavenPatchVersion = ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
$version = "$major.$minor.$patch$Env:SNAPSHOT_SUFFIX"
echo "Current version is $version"
echo "##vso[task.setvariable variable=PACKAGE_VERSION;isOutput=true]$version"
env:
${{ if contains(variables['build.sourceBranch'], 'refs/tags/v') }}:
SNAPSHOT_SUFFIX: '-SNAPSHOT'

- displayName: Inspect contents of local Maven cache
pwsh: |
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-abstractions -Version $env:PACKAGE_VERSION
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-authentication-azure -Version $env:PACKAGE_VERSION
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-http-okHttp -Version $env:PACKAGE_VERSION
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-serialization-form -Version $env:PACKAGE_VERSION
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-serialization-json -Version $env:PACKAGE_VERSION
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-serialization-text -Version $env:PACKAGE_VERSION
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-serialization-multipart -Version $env:PACKAGE_VERSION
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-bundle -Version $env:PACKAGE_VERSION

- displayName: Zip contents of local Maven cache
pwsh: |
.\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-abstractions -Version $env:PACKAGE_VERSION
.\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-authentication-azure -Version $env:PACKAGE_VERSION
.\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-http-okHttp -Version $env:PACKAGE_VERSION
.\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-serialization-form -Version $env:PACKAGE_VERSION
.\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-serialization-json -Version $env:PACKAGE_VERSION
.\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-serialization-text -Version $env:PACKAGE_VERSION
.\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-serialization-multipart -Version $env:PACKAGE_VERSION
.\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-kiota-bundle -Version $env:PACKAGE_VERSION
env:
OUTPUT_DIRECTORY: $(Build.ArtifactStagingDirectory)

- task: 1ES.PublishPipelineArtifact@1
displayName: "Publish Artifact: jars"
inputs:
artifactName: jars
targetPath: "$(Build.ArtifactStagingDirectory)/*.zip"


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,4 @@ build/
local.properties

*.gpg
*.zip
26 changes: 26 additions & 0 deletions scripts/zipPackageContent.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Checks that expected files are present & have contents after the publish process to the local cache
param(
[Parameter(Mandatory=$true)][string] $ArtifactId,
[Parameter(Mandatory=$true)][string] $Version,
[Parameter(Mandatory=$true)][string] $OutputDirectory,
[Parameter()][string] $GroupId = "com.microsoft.kiota",
[Parameter()][string] $MavenLocalCachePath = "~" + [System.IO.Path]::DirectorySeparatorChar + ".m2" + [System.IO.Path]::DirectorySeparatorChar + "repository"
)

$groupIdPath = $GroupId -replace "\.", [System.IO.Path]::DirectorySeparatorChar
$packagePath = Join-Path -Path $groupIdPath -ChildPath $ArtifactId
$packageFullPath = Join-Path -Path $MavenLocalCachePath -ChildPath $packagePath -AdditionalChildPath $Version

Write-Output "---------------------------------------------------"
Write-Output "Zipping package contents at $packageFullPath"

if(-not (Test-Path -Path $packageFullPath)) {
Write-Output "Package not found in local cache."
exit 1
}

$outputFilePath = Join-Path -Path $OutputDirectory -ChildPath "$ArtifactId-$Version.zip")
Remove-Item -Path $outputFilePath -ErrorAction SilentlyContinue
Compress-Archive -Path "$packageFullPath\*" -DestinationPath $outputFilePath

exit 0