diff --git a/.pipelines/DSC-Official-PMC.yml b/.pipelines/DSC-Official-PMC.yml index bb8067999..0e7a63f66 100644 --- a/.pipelines/DSC-Official-PMC.yml +++ b/.pipelines/DSC-Official-PMC.yml @@ -25,6 +25,9 @@ variables: value: 'onebranch.azurecr.io/linux/ubuntu-2204:latest' - name: RepoRoot value: '$(Build.SourcesDirectory)/DSC' + - group: DSC-packages.microsoft.com + - name: SigningProfile + value: $(pgp_linux_cert_id) resources: repositories: @@ -114,6 +117,13 @@ extends: Copy-Item ./bin/*.deb "$(ob_outputDirectory)" displayName: 'Build x86_64-unknown-linux-musl' condition: succeeded() + - task: onebranch.pipeline.signing@1 + displayName: Sign deb and rpm packages + inputs: + command: 'sign' + signing_profile: '$(SigningProfile)' + files_to_sign: '**/*.rpm;**/*.deb' + search_root: '$(ob_outputDirectory)' - job: BuildLinuxArm64Musl dependsOn: SetPackageVersion @@ -165,6 +175,13 @@ extends: Copy-Item ./bin/*.deb "$(ob_outputDirectory)" displayName: 'Build aarch64-unknown-linux-musl' condition: succeeded() + - task: onebranch.pipeline.signing@1 + displayName: Sign deb and rpm packages + inputs: + command: 'sign' + signing_profile: '$(SigningProfile)' + files_to_sign: '**/*.rpm;**/*.deb' + search_root: '$(ob_outputDirectory)' - stage: PrepPackagesForEv2PMC displayName: Publish Linux Packages to packages.microsoft.com @@ -195,7 +212,6 @@ extends: value: $(RepoRoot)/.config/suppress.json - name: ob_sdl_tsa_configFile value: $(RepoRoot)/.config/tsaoptions.json - - group: 'DSC-packages.microsoft.com' steps: - checkout: self lfs: false diff --git a/.pipelines/EV2Specs/ServiceGroupRoot/Shell/Run/Run.ps1 b/.pipelines/EV2Specs/ServiceGroupRoot/Shell/Run/Run.ps1 index f4036c2d8..93b3d5c6f 100644 --- a/.pipelines/EV2Specs/ServiceGroupRoot/Shell/Run/Run.ps1 +++ b/.pipelines/EV2Specs/ServiceGroupRoot/Shell/Run/Run.ps1 @@ -17,6 +17,8 @@ #> $env:NO_COLOR = 1 +$env:TERM = 'dumb' +$PSStyle.OutputRendering = 'PlainText' function Get-MappedRepositoryIds { param( @@ -102,12 +104,14 @@ function Get-PackageObjects { $pkgRepo = $pkg.RepoId | Select-Object -First 1 $pkgDistribution = $pkg.Distribution | Select-Object -First 1 - $pkgName = $pkg.PackageFormat.Replace('PACKAGE_NAME', $PackageName).Replace('RELEASE_VERSION', $ReleaseVersion) - - if ($pkgName.EndsWith('.rpm')) { - $pkgName = $pkgName.Replace($ReleaseVersion, $ReleaseVersion.Replace('-', '_')) + $pkgReleaseVersion = $ReleaseVersion + if ($pkg.PackageFormat.EndsWith('.rpm')) { + # RPM requires no dashes in the version string, so replace any dashes with tildes + $pkgReleaseVersion = $pkgReleaseVersion.Replace('-', '~') } + $pkgName = $pkg.PackageFormat.Replace('PACKAGE_NAME', $PackageName).Replace('RELEASE_VERSION', $pkgReleaseVersion) + $packagePath = "$script:dscPackagesFolder/$pkgName" if (-not (Test-Path -Path $packagePath)) { throw "Package path $packagePath does not exist" @@ -149,6 +153,9 @@ function Publish-PackageToPMC { $packageType = $extension -replace '^\.' $packageListJson = pmc --config $ConfigPath package $packageType list --file $packagePath + if ($LASTEXITCODE -ne 0) { + throw "pmc package $packageType list failed with exit code $LASTEXITCODE; --config '$ConfigPath' package $packageType list --file '$packagePath'" + } $list = $packageListJson | ConvertFrom-Json $packageId = @() @@ -160,8 +167,11 @@ function Publish-PackageToPMC { $uploadResult = $null try { $uploadResult = pmc --config $ConfigPath package upload $packagePath --type $packageType + if ($LASTEXITCODE -ne 0) { + throw "pmc package upload failed with exit code $LASTEXITCODE; --config '$ConfigPath' package upload '$packagePath' --type '$packageType'" + } } catch { - $errorMessages.Add("Uploading package $($finalPackage.PackageName) to $pkgRepo failed. See errors above for details.") + $errorMessages.Add("Uploading package $($finalPackage.PackageName) to $pkgRepo failed: $($_.Exception.Message)") continue } @@ -178,13 +188,19 @@ function Publish-PackageToPMC { try { if ($packageType -eq 'rpm') { $rawUpdateResponse = pmc --config $ConfigPath repo package update $pkgRepo --add-packages $packageId + if ($LASTEXITCODE -ne 0) { + throw "pmc repo package update failed with exit code $LASTEXITCODE; --config '$ConfigPath' repo package update '$pkgRepo' --add-packages '$packageId'" + } } elseif ($packageType -eq 'deb') { $rawUpdateResponse = pmc --config $ConfigPath repo package update $pkgRepo $distribution --add-packages $packageId + if ($LASTEXITCODE -ne 0) { + throw "pmc repo package update failed with exit code $LASTEXITCODE; --config '$ConfigPath' repo package update '$pkgRepo' '$distribution' --add-packages '$packageId'" + } } else { throw "Unsupported package type: $packageType" } } catch { - $errorMessages.Add("Update for package $($finalPackage.PackageName) to $pkgRepo failed. See errors above for details.") + $errorMessages.Add("Update for package $($finalPackage.PackageName) to $pkgRepo failed: $($_.Exception.Message)") continue } @@ -198,8 +214,11 @@ function Publish-PackageToPMC { $rawPublishResponse = $null try { $rawPublishResponse = pmc --config $ConfigPath repo publish $pkgRepo + if ($LASTEXITCODE -ne 0) { + throw "pmc repo publish failed with exit code $LASTEXITCODE; --config '$ConfigPath' repo publish '$pkgRepo'" + } } catch { - $errorMessages.Add("Final publish for package $($finalPackage.PackageName) to $pkgRepo failed. See errors above for details.") + $errorMessages.Add("Final publish for package $($finalPackage.PackageName) to $pkgRepo failed: $($_.Exception.Message)") continue } @@ -277,13 +296,16 @@ try { $skipPublish = $metadataContent.SkipPublish $channel = if ($releaseVersion.Contains('-')) { 'preview' } else { 'stable' } - $packageName = $channel -eq 'preview' ? 'dsc-preview' : 'dsc' + $packageName = 'dsc' Write-Verbose "Release version: $releaseVersion, Channel: $channel" -Verbose # Get PMC repository list Write-Verbose "Getting PMC repository list" -Verbose $rawResponse = pmc --config $configPath repo list --limit 800 + if ($LASTEXITCODE -ne 0) { + throw "pmc repo list failed with exit code $LASTEXITCODE; --config '$configPath' repo list --limit 800" + } $response = $rawResponse | ConvertFrom-Json Write-Verbose "PMC repo list: limit=$($response.limit), count=$($response.count)" -Verbose $repoList = $response.results @@ -297,7 +319,7 @@ try { Write-Verbose "SkipPublish: $skipPublish" -Verbose Publish-PackageToPMC -PackageObject $packageObjects -ConfigPath $configPath -SkipPublish $skipPublish } catch { - Write-Error -ErrorAction Stop $_.Exception.Message + Write-Error (Get-Error | Out-String) return 1 } diff --git a/tools/packages.microsoft.com/mapping.json b/tools/packages.microsoft.com/mapping.json index bd2d77421..2a657062f 100644 --- a/tools/packages.microsoft.com/mapping.json +++ b/tools/packages.microsoft.com/mapping.json @@ -5,28 +5,28 @@ "distribution": [ "stable" ], - "PackageFormat": "PACKAGE_NAME_RELEASE_VERSION-1_x86_64.rpm" + "PackageFormat": "PACKAGE_NAME-RELEASE_VERSION-1.x86_64.rpm" }, { "url": "microsoft-rhel9.0-prod", "distribution": [ "stable" ], - "PackageFormat": "PACKAGE_NAME_RELEASE_VERSION-1_x86_64.rpm" + "PackageFormat": "PACKAGE_NAME-RELEASE_VERSION-1.x86_64.rpm" }, { "url": "microsoft-rhel8.0-prod", "distribution": [ "stable" ], - "PackageFormat": "PACKAGE_NAME_RELEASE_VERSION-1_aarch64.rpm" + "PackageFormat": "PACKAGE_NAME-RELEASE_VERSION-1.aarch64.rpm" }, { "url": "microsoft-rhel9.0-prod", "distribution": [ "stable" ], - "PackageFormat": "PACKAGE_NAME_RELEASE_VERSION-1_aarch64.rpm" + "PackageFormat": "PACKAGE_NAME-RELEASE_VERSION-1.aarch64.rpm" }, { "url": "microsoft-debian-bullseye-prod",