diff --git a/tools/releaseBuild/azureDevOps/releaseBuild.yml b/tools/releaseBuild/azureDevOps/releaseBuild.yml new file mode 100644 index 00000000000..bf3f3f235c4 --- /dev/null +++ b/tools/releaseBuild/azureDevOps/releaseBuild.yml @@ -0,0 +1,39 @@ +name: UnifiedPackageBuild-$(Build.BuildId) +trigger: + branches: + include: + - master + - release* +pr: + branches: + include: + - master + - release* + +variables: + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + POWERSHELL_TELEMETRY_OPTOUT: 1 + +# Set AzDevOps Agent to clean the machine after the end of the build +resources: +- repo: self + clean: true + +jobs: +- template: templates/linux.yml + parameters: + buildName: deb + +- template: templates/linux.yml + parameters: + buildName: rpm + +- template: templates/linux.yml + parameters: + buildName: fxdependent + +- template: templates/linux.yml + parameters: + buildName: alpine + +- template: templates/mac.yml diff --git a/tools/releaseBuild/azureDevOps/LinuxBuild.yml b/tools/releaseBuild/azureDevOps/templates/linux.yml similarity index 57% rename from tools/releaseBuild/azureDevOps/LinuxBuild.yml rename to tools/releaseBuild/azureDevOps/templates/linux.yml index 10761d771f2..bf12a981df5 100644 --- a/tools/releaseBuild/azureDevOps/LinuxBuild.yml +++ b/tools/releaseBuild/azureDevOps/templates/linux.yml @@ -1,75 +1,69 @@ -resources: -- repo: self - clean: true -jobs: +parameters: + buildName: '' -- job: BuildJob - displayName: Build +jobs: +- job: build_${{ parameters.buildName }} + displayName: Build ${{ parameters.buildName }} condition: succeeded() pool: Hosted Ubuntu 1604 - strategy: - matrix: - deb packages: - build: ubuntu.14.04-no-appimage - rpm packages: - build: centos.7 - fxdependent package: - build: fxdependent + variables: + build: ${{ parameters.buildName }} steps: - powershell: | - tools/releaseBuild/setReleaseTag.ps1 -ReleaseTag $(ReleaseTag) + tools/releaseBuild/setReleaseTag.ps1 -ReleaseTag $(ReleaseTagVar) -Variable "ReleaseTagVar" displayName: 'Run setReleaseTag.ps1' - powershell: | Write-Verbose -Verbose "$(build)" - if ('$(build)' -eq 'fxdependent' -and '$(ReleaseTag)' -match '6.0.*') + if ('$(build)' -in 'alpine', 'fxdependent' -and '$(ReleaseTagVar)' -match '6.0.*') { - $vstsCommandString = "vso[task.setvariable variable=SkipFxDependent]true" + $vstsCommandString = "vso[task.setvariable variable=SkipBuild]true" } else { - $vstsCommandString = "vso[task.setvariable variable=SkipFxDependent]false" + $vstsCommandString = "vso[task.setvariable variable=SkipBuild]false" } + displayName: 'Skip Alpine or fxdependent for PS v6.0.*' + + - powershell: | + Import-Module $(Build.SourcesDirectory)/build.psm1 -Force + New-NugetConfigFile -NugetFeedUrl $(AzDevOpsFeed) -UserName $(AzDevOpsFeedUserName) -ClearTextPAT $(AzDevOpsFeedPAT) -FeedName AzDevOpsFeed -Destination $(Build.SourcesDirectory)/src/Modules - Write-Verbose -Message "$vstsCommandString " -Verbose - Write-Host -Object "##$vstsCommandString" - displayName: 'Skip FxDependent for PS v6.0.*' + if(-not (Test-Path "$(Build.SourcesDirectory)/src/Modules/nuget.config")) + { + throw "nuget.config is not created" + } + displayName: 'Add nuget.config for AzDevOps feed for PSGallery modules ' + condition: ne(Variables['SkipBuild'],'true') - powershell: | import-module ./build.psm1 Sync-PSTags -AddRemoteIfMissing displayName: SyncTags - condition: and(succeeded(), ne(variables['SkipFxDependent'], 'true')) + condition: and(succeeded(), ne(variables['SkipBuild'], 'true')) - powershell: | - tools/releaseBuild/vstsbuild.ps1 -ReleaseTag $(ReleaseTag) -Name '$(build)' + tools/releaseBuild/vstsbuild.ps1 -ReleaseTag $(ReleaseTagVar) -Name '$(build)' displayName: 'Build and package' - condition: and(succeeded(), ne(variables['SkipFxDependent'], 'true')) + condition: and(succeeded(), ne(variables['SkipBuild'], 'true')) - -- job: UploadJob - displayName: Upload to Azure - dependsOn: BuildJob +- job: upload_${{ parameters.buildName }} + displayName: Upload ${{ parameters.buildName }} + dependsOn: build_${{ parameters.buildName }} condition: succeeded() pool: Package ES CodeHub Lab E + variables: + buildName: ${{ parameters.buildName }} steps: - powershell: | - ./tools/releaseBuild/setReleaseTag.ps1 -ReleaseTag $(ReleaseTag) + tools/releaseBuild/setReleaseTag.ps1 -ReleaseTag $(ReleaseTagVar) -Variable "ReleaseTagVar" displayName: 'Set ReleaseTag' - powershell: | - if ($env:build -eq 'fxdependent' -and $env:ReleaseTag -match '6.0.*') - { - $vstsCommandString = "vso[task.setvariable variable=SkipFxDependent]true" - Write-Host -Object $vstsCommandString - } - displayName: 'Check if multiplier is applicable ' - - - powershell: | - $azureVersion = $env:ReleaseTag.ToLowerInvariant() -replace '\.', '-' + $azureVersion = $env:ReleaseTagVar.ToLowerInvariant() -replace '\.', '-' $vstsCommandString = "vso[task.setvariable variable=AzureVersion]$azureVersion" Write-Host "sending " + $vstsCommandString Write-Host "##$vstsCommandString" @@ -81,6 +75,7 @@ jobs: downloadType: specific itemPattern: '**/*.deb' downloadPath: '$(System.ArtifactsDirectory)\finished' + condition: and(eq(variables['buildName'], 'DEB'),succeeded()) - task: DownloadBuildArtifacts@0 displayName: 'Download tar.gz Artifacts copy' @@ -95,6 +90,7 @@ jobs: downloadType: specific itemPattern: '**/*.rpm' downloadPath: '$(System.ArtifactsDirectory)\rpm' + condition: and(eq(variables['buildName'], 'RPM'),succeeded()) - task: AzureFileCopy@1 displayName: 'Upload to azure deb and tar.gz' @@ -113,3 +109,4 @@ jobs: Destination: AzureBlob storage: '$(StorageAccount)' ContainerName: '$(AzureVersion)-unsigned' + condition: and(eq(variables['buildName'], 'RPM'),succeeded()) diff --git a/tools/releaseBuild/azureDevOps/templates/mac.yml b/tools/releaseBuild/azureDevOps/templates/mac.yml new file mode 100644 index 00000000000..ba2cd4bdbb0 --- /dev/null +++ b/tools/releaseBuild/azureDevOps/templates/mac.yml @@ -0,0 +1,44 @@ +parameters: + jobName: 'build_macOS' + +jobs: +- job: ${{ parameters.jobName }} + displayName: Build macOS + condition: succeeded() + pool: Hosted macOS Preview + steps: + #- task: @ + # inputs: + # + # displayName: '' + - powershell: | + tools/releaseBuild/setReleaseTag.ps1 -ReleaseTag $(ReleaseTagVar) -Variable "ReleaseTagVar" + displayName: 'Calculate Release Tag' + - powershell: | + # create folder + sudo mkdir /PowerShell + + # make the current user the owner + sudo chown $env:USER /PowerShell + displayName: 'Create /PowerShell' + - powershell: | + Write-Host "##vso[task.setvariable variable=PowerShellRoot]/PowerShell" + git clone $env:BUILD_REPOSITORY_LOCALPATH /PowerShell + displayName: Clone PowerShell Repo to /PowerShell + - powershell: | + tools/releaseBuild/macOS/PowerShellPackageVsts.ps1 -location $(PowerShellRoot) -BootStrap + displayName: 'Bootstrap VM' + - powershell: | + Import-Module $(Build.SourcesDirectory)/build.psm1 -Force + New-NugetConfigFile -NugetFeedUrl $(AzDevOpsFeed) -UserName $(AzDevOpsFeedUserName) -ClearTextPAT $(AzDevOpsFeedPAT) -FeedName AzDevOpsFeed -Destination "$(PowerShellRoot)/src/Modules" + + if(-not (Test-Path "$(PowerShellRoot)/src/Modules/nuget.config")) + { + throw "nuget.config is not created" + } + displayName: 'Add nuget.config for AzDevOps feed for PSGallery modules ' + - powershell: | + $env:AZDEVOPSFEEDPAT = '$(AzDevOpsFeedPAT)' + $(Build.SourcesDirectory)/tools/releaseBuild/macOS/PowerShellPackageVsts.ps1 -ReleaseTag $(ReleaseTagVar) -Destination $(System.ArtifactsDirectory) -ExtraPackage "tar" -location $(PowerShellRoot) -Build + $env:AZDEVOPSFEEDPAT = $null + displayName: 'Build and Package' diff --git a/tools/releaseBuild/build.json b/tools/releaseBuild/build.json index ca7f57f9aa7..4801821c8cd 100644 --- a/tools/releaseBuild/build.json +++ b/tools/releaseBuild/build.json @@ -241,7 +241,7 @@ ], "Linux": [ { - "Name": "ubuntu.14.04", + "Name": "ubuntu.14.04-unused", "RepoDestinationPath": "/PowerShell", "BuildCommand": "/PowerShellPackage.ps1 -location _RepoDestinationPath_ -destination _DockerVolume_ -ReleaseTag _ReleaseTag_ -AppImage -TarX64 -TarArm", "BuildDockerOptions": [ @@ -259,7 +259,7 @@ "BinaryBucket": "release" }, { - "Name": "ubuntu.14.04-no-appimage", + "Name": "deb", "RepoDestinationPath": "/PowerShell", "BuildCommand": "/PowerShellPackage.ps1 -location _RepoDestinationPath_ -destination _DockerVolume_ -ReleaseTag _ReleaseTag_ -TarX64 -TarArm -TarArm64", "DockerFile": "./tools/releaseBuild/Images/microsoft_powershell_ubuntu14.04/Dockerfile", @@ -268,16 +268,7 @@ "BinaryBucket": "release" }, { - "Name": "ubuntu.16.04", - "RepoDestinationPath": "/PowerShell", - "BuildCommand": "/PowerShellPackage.ps1 -location _RepoDestinationPath_ -destination _DockerVolume_ -ReleaseTag _ReleaseTag_", - "AdditionalContextFiles" :[ "./tools/releaseBuild/Images/GenericLinuxFiles/PowerShellPackage.ps1"], - "DockerFile": "./tools/releaseBuild/Images/microsoft_powershell_ubuntu16.04/Dockerfile", - "DockerImageName": "ps-ubunutu-16-04", - "BinaryBucket": "release" - }, - { - "Name": "centos.7", + "Name": "rpm", "RepoDestinationPath": "/PowerShell", "BuildCommand": "/PowerShellPackage.ps1 -location _RepoDestinationPath_ -destination _DockerVolume_ -ReleaseTag _ReleaseTag_", "AdditionalContextFiles" :[ "./tools/releaseBuild/Images/GenericLinuxFiles/PowerShellPackage.ps1"], @@ -286,7 +277,7 @@ "BinaryBucket": "release" }, { - "Name": "alpine.3", + "Name": "alpine", "RepoDestinationPath": "/PowerShell", "BuildCommand": "/PowerShellPackage.ps1 -location _RepoDestinationPath_ -destination _DockerVolume_ -ReleaseTag _ReleaseTag_ -Alpine", "AdditionalContextFiles" :[ "./tools/releaseBuild/Images/GenericLinuxFiles/PowerShellPackage.ps1"],