-
Notifications
You must be signed in to change notification settings - Fork 314
[Ready for EngSys Review] ESRP Publishing #3187
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
Open
danieljurek
wants to merge
91
commits into
main
Choose a base branch
from
djurek/esrp-publish
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
91 commits
Select commit
Hold shift + click to select a range
cd3f8c5
Remove yank job; ESRP doesn't have direct programmatic support for that
danieljurek b7d1bc4
Rough changes to Pack-Crates.ps1 to produce .crate files
danieljurek bb19629
First cut at ESRP publishing
danieljurek ce9052c
Use *.crate package pattern, adjust Pack-Crates.ps1 to create package…
danieljurek dea5220
Extract package information from .crate file
danieljurek 86fdb07
Syntax
danieljurek da1123e
Syntax
danieljurek 6b8b7ef
Syntax
danieljurek 0eeed2f
Syntax
danieljurek 9480074
Compress-ReleaseCrate.ps1, wire into archetype-rust-release.yml
danieljurek 1f23b8d
Use managed identity
danieljurek 78da130
Redundant line
danieljurek 4ff0c80
Deployment scripts must be inline (no checkout)
danieljurek 2a62b91
Disable repo tagging to iterate on release, inline compression
danieljurek 8064fa0
Create output directory
danieljurek 0adddb2
:
danieljurek 048d022
EsrpRelease@10
danieljurek 194f4a2
Remove redundant keys
danieljurek 155142d
DomainTenantId
danieljurek d7c351f
Don't nest in zip?
danieljurek 8d8b357
Remove toolchain config
danieljurek 2cb1634
Add KV and signing info
danieljurek 606863c
Use ESRPRELPACMANTEST
danieljurek c66857d
Check that crate is publishable
danieljurek c5f84bf
Pack-Crates.ps1: Remove -PackageInfoDirectory, add -RequireDependenci…
danieljurek 465f1df
Wire up release intent
danieljurek 3525680
each artifact
danieljurek 7c399f9
Parameters
danieljurek a0832ce
Only specify an environment if not in a test pipeline
danieljurek 8f030be
Use environment: none if in TestPipeline
danieljurek 89b48df
Remove Environment param
danieljurek d9e4c26
(test) Depend on unreleased core
danieljurek 3bc2261
Remove azure_canary_core's dependency on azure_core
danieljurek ab2b2ab
Check existence
danieljurek 3eccd36
Naming
danieljurek 7ae6ad9
Log file paths
danieljurek d9e3786
backtick
danieljurek f302f99
Remove extra logging
danieljurek 40437b4
Test ESRP idempotency
danieljurek 892f1b6
Remove test step
danieljurek 93818a7
Update ci.yml files with release parameters
danieljurek e0692f3
Also require dependency order
danieljurek e1a3992
Wire up CHANGELOG.md and README.md
danieljurek 592a672
Test: remove package verison updating from release. Should fail Packing.
danieljurek 9841408
Better testing: turn off TestPipeline
danieljurek 07bfe40
Undo test changes
danieljurek 7a76bfb
Move RequireDependencies into pack.yml
danieljurek b47a18d
Move RequireDependencies into pack.yml
danieljurek 76e1390
Pack-Crates.ps1: Use PackageInfoDirectory
danieljurek ac8e1a0
-RequireDependencies
danieljurek 60893c1
Syntax
danieljurek 3526027
Formatting/cleanup
danieljurek 5d61c2f
cspell: allowCompoundWords: true
danieljurek b9ca6a8
Spelling
danieljurek c6a900c
Review feedback: No artifacts selected means "just build all artifact…
danieljurek 5ae05c6
convertToJson
danieljurek 2b51b99
Only create the stage if there are artifacts to release
danieljurek 71f0586
'False'
danieljurek 19cbea1
More error throwing
danieljurek 0d00a9e
Review feedback: Don't enable allowCompoundWords, also release_ names…
danieljurek ea9b318
Artifact ordering for Pack-Crates.ps1
danieljurek c7d7988
Add support for outputting release order of specified packages
danieljurek 3e51485
Use artifact ordering from artifacts
danieljurek 0c9b166
Log index
danieljurek ee30182
One PR per-release
danieljurek 164469e
Review feedback: -eq 'True'
danieljurek 24abf38
Test public API change
danieljurek 067a2ff
Cover is_below_freezing
danieljurek a1c1e4d
Remove TODO, APIView behavior is unchanged
danieljurek 439f703
Formatting
danieljurek a169a49
Format
danieljurek 3245143
Revert constant_example.rs
danieljurek f265701
Review feedback: quotes, Join-Path
danieljurek c405dfa
Build dependencies from source allowing exceptions for crates that ha…
danieljurek 09356e4
Better single package handling
danieljurek c8457fc
Use simplified packing process for release
danieljurek 2a27745
Output path
danieljurek 06dd993
Syntax
danieljurek 474f902
Comments
danieljurek 0d6f13d
Change releases to default: false
danieljurek 37e78b6
use cspell.json from main
danieljurek 85f5cef
Incorporate typespec into core/ci.yml
danieljurek 530dddf
Remove redundant single quotes in yaml
danieljurek c15eaf2
Refactor all packing to Pack-Crates.ps1
danieljurek 6eee1c8
Pack-Crates.ps1 artifact output
danieljurek cc1182f
release-order.json
danieljurek 53b122c
Formatting
danieljurek 08abce5
Review feedback
danieljurek 1ef0c18
$(ArtifactName) needs to have a value or macro syntax just dumps in t…
danieljurek 76aaab8
PowerShell: Edge cases around flattened arrays
danieljurek 952276c
Review feedback
danieljurek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,15 +55,52 @@ jobs: | |
ServiceDirectory: ${{ parameters.ServiceDirectory }} | ||
PackageInfoDirectory: $(Build.ArtifactStagingDirectory)/PackageInfo | ||
|
||
- task: Powershell@2 | ||
displayName: "Pack Crates" | ||
condition: and(succeeded(), ne(variables['NoPackagesChanged'],'true')) | ||
inputs: | ||
pwsh: true | ||
filePath: $(Build.SourcesDirectory)/eng/scripts/Pack-Crates.ps1 | ||
arguments: > | ||
-OutputPath '$(Build.ArtifactStagingDirectory)' | ||
-PackageInfoDirectory '$(Build.ArtifactStagingDirectory)/PackageInfo' | ||
- ${{ if eq('auto', parameters.ServiceDirectory) }}: | ||
- task: Powershell@2 | ||
displayName: Pack Crates | ||
condition: and(succeeded(), ne(variables['NoPackagesChanged'],'true')) | ||
inputs: | ||
pwsh: true | ||
filePath: $(Build.SourcesDirectory)/eng/scripts/Pack-Crates.ps1 | ||
arguments: > | ||
-OutputPath '$(Build.ArtifactStagingDirectory)' | ||
-PackageInfoDirectory '$(Build.ArtifactStagingDirectory)/PackageInfo' | ||
|
||
- ${{ else }}: | ||
- pwsh: | | ||
$artifacts = '${{ convertToJson(parameters.Artifacts) }}' | ConvertFrom-Json | ||
$isReleaseBuild = $true | ||
$artifactsToBuild = $artifacts | Where-Object { $_.releaseInBatch -eq 'True' } | ||
|
||
if (!$artifactsToBuild) { | ||
Write-Host "No packages to release. Building all packages in the service directory with no dependency validation." | ||
$artifactsToBuild = $artifacts | ||
$isReleaseBuild = $false | ||
} | ||
|
||
$packageNames = $artifactsToBuild.name | ||
|
||
Write-Host "##vso[task.setvariable variable=PackageNames]$($packageNames -join ',')" | ||
if ($isReleaseBuild) { | ||
Write-Host "##vso[task.setvariable variable=AdditionalPackageParams]-Release" | ||
} else { | ||
Write-Host "##vso[task.setvariable variable=AdditionalPackageParams]" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be cleaner to just invoke Pack-Crates here rather than setting devops variables and invoking them in a following step. Unless you want to track the error rates for the step separately |
||
displayName: Configure crate packing | ||
condition: and(succeeded(), ne(variables['NoPackagesChanged'],'true')) | ||
|
||
- task: Powershell@2 | ||
displayName: Pack Crates | ||
condition: and(succeeded(), ne(variables['NoPackagesChanged'],'true')) | ||
inputs: | ||
pwsh: true | ||
filePath: $(Build.SourcesDirectory)/eng/scripts/Pack-Crates.ps1 | ||
arguments: > | ||
-OutputPath '$(Build.ArtifactStagingDirectory)' | ||
-PackageNames $(PackageNames) | ||
-OutBuildOrderFile '$(Build.ArtifactStagingDirectory)/release-order.json' | ||
$(AdditionalPackageParams) | ||
|
||
|
||
- template: /eng/common/pipelines/templates/steps/publish-1es-artifact.yml | ||
parameters: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,16 +14,13 @@ parameters: | |
- name: DevFeedName | ||
type: string | ||
default: 'public/azure-sdk-for-rust' | ||
- name: Environment | ||
type: string | ||
default: 'cratesio' | ||
|
||
stages: | ||
- ${{ if eq(variables['System.TeamProject'], 'internal') }}: | ||
- ${{ if in(variables['Build.Reason'], 'Manual', '') }}: | ||
- ${{ each artifact in parameters.Artifacts }}: | ||
- stage: Release_${{artifact.safeName}} | ||
displayName: "Release: ${{artifact.name}}" | ||
- ${{ if gt(length(parameters.Artifacts), 0) }}: | ||
- stage: Release_Batch | ||
displayName: "Releasing: ${{length(parameters.Artifacts)}} crates" | ||
dependsOn: ${{parameters.DependsOn}} | ||
condition: and(succeeded(), ne(variables['SetDevVersion'], 'true'), ne(variables['Skip.Release'], 'true'), ne(variables['Build.Repository.Name'], 'Azure/azure-sdk-for-rust-pr')) | ||
variables: | ||
|
@@ -50,16 +47,17 @@ stages: | |
|
||
- template: /eng/common/pipelines/templates/steps/retain-run.yml | ||
|
||
- script: | | ||
echo "##vso[build.addbuildtag]${{artifact.name}}" | ||
displayName: Add build tag '${{artifact.name}}' | ||
- ${{ each artifact in parameters.Artifacts }}: | ||
- script: | | ||
echo "##vso[build.addbuildtag]${{artifact.name}}" | ||
displayName: Add build tag '${{artifact.name}}' | ||
|
||
- template: /eng/common/pipelines/templates/steps/create-tags-and-git-release.yml | ||
parameters: | ||
ArtifactLocation: $(Pipeline.Workspace)/${{parameters.PipelineArtifactName}}/${{artifact.name}} | ||
PackageRepository: Crates.io | ||
ReleaseSha: $(Build.SourceVersion) | ||
WorkingDirectory: $(Pipeline.Workspace)/_work | ||
- template: /eng/common/pipelines/templates/steps/create-tags-and-git-release.yml | ||
parameters: | ||
ArtifactLocation: $(Pipeline.Workspace)/${{parameters.PipelineArtifactName}}/${{artifact.name}} | ||
PackageRepository: Crates.io | ||
ReleaseSha: $(Build.SourceVersion) | ||
WorkingDirectory: $(Pipeline.Workspace)/_work | ||
|
||
- deployment: PublishPackage | ||
displayName: "Publish to Crates.io" | ||
|
@@ -71,7 +69,10 @@ stages: | |
- input: pipelineArtifact # Required, type of the input artifact | ||
artifactName: ${{parameters.PipelineArtifactName}} # Required, name of the pipeline artifact | ||
targetPath: $(Pipeline.Workspace)/drop # Optional, specifies where the artifact is downloaded to | ||
environment: ${{parameters.Environment}} | ||
${{if parameters.TestPipeline}}: | ||
environment: none | ||
${{else}}: | ||
environment: package-publish | ||
# This timeout shouldn't be necessary once we're able to parallelize better. Right now, | ||
# this is here to ensure larger areas (30+) libraries don't time out. | ||
timeoutInMinutes: 120 | ||
|
@@ -84,33 +85,76 @@ stages: | |
runOnce: | ||
deploy: | ||
steps: | ||
- template: /eng/pipelines/templates/steps/use-rust.yml@self | ||
parameters: | ||
Toolchain: stable | ||
|
||
- pwsh: | | ||
$additionalOwners = @('heaths', 'hallipr') | ||
$token = $env:CARGO_REGISTRY_TOKEN | ||
$crateName = '${{artifact.name}}' | ||
|
||
$manifestPath = "$(Pipeline.Workspace)/drop/$crateName/contents/Cargo.toml" | ||
Write-Host "> cargo publish --manifest-path `"$manifestPath`"" | ||
cargo publish --manifest-path $manifestPath | ||
if (!$?) { | ||
Write-Error "Failed to publish package: '$crateName'" | ||
exit 1 | ||
} | ||
|
||
$existingOwners = (cargo owner --list $crateName) -replace " \(.*", "" | ||
$missingOwners = $additionalOwners | Where-Object { $existingOwners -notcontains $_ } | ||
|
||
foreach ($owner in $missingOwners) { | ||
Write-Host "> cargo owner --add $owner $crateName" | ||
cargo owner --add $owner $crateName | ||
} | ||
displayName: Publish Crate | ||
env: | ||
CARGO_REGISTRY_TOKEN: $(azure-sdk-cratesio-token) | ||
Write-Host "Setting ArtifactName to empty" | ||
Write-Host "##vso[task.setvariable variable=ArtifactName;]" | ||
displayName: Initialize ArtifactName variable | ||
|
||
# This loop over artifacts is used to produce the correct number | ||
# of ESRP release tasks. It has the side effect of also setting | ||
# the artifact name by looking up the index of the current | ||
# "artifact.name" in the parameters.Artifacts array, using that | ||
# as an "index" and then using that same index to look up the | ||
# actual artifact to release in the release-order.json file. | ||
- ${{ each artifact in parameters.Artifacts }}: | ||
- pwsh: | | ||
danieljurek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# From the DevOps template artifact loop calculate the current index | ||
$indexItem = '${{ artifact.name }}' | ||
[array] $indexList = ConvertFrom-Json '${{ convertToJson(parameters.Artifacts.*.name) }}' | ||
$index = $indexList.IndexOf($indexItem) | ||
Write-Host "Index of template artifact: $index" | ||
|
||
[array] $artifacts = Get-Content '$(Pipeline.Workspace)/drop/release-order.json' | ConvertFrom-Json | ||
|
||
$artifactName = $artifacts[$index] | ||
|
||
Write-Host "Releasing artifact: $artifactName" | ||
|
||
$artifactRootPath = '$(Pipeline.Workspace)/drop' | ||
$outDir = '$(Pipeline.Workspace)/esrp-release' | ||
|
||
if (Test-Path $outDir) { | ||
Write-Host "Cleaning output directory: $outDir" | ||
Remove-Item -Path $outDir -Recurse -Force | ||
} | ||
New-Item -ItemType Directory -Path $outDir -Force | Out-Null | ||
|
||
$packageMetadataPath = "$artifactRootPath/PackageInfo/$artifactName.json" | ||
if (!(Test-Path $packageMetadataPath)) { | ||
Write-Error "Package metadata file not found: $packageMetadataPath" | ||
exit 1 | ||
} | ||
|
||
$packageMetadata = Get-Content -Raw $packageMetadataPath | ConvertFrom-Json | ||
$packageVersion = $packageMetadata.version | ||
Write-Host "Package version: $packageVersion" | ||
|
||
$cratePath = "$artifactRootPath/$artifactName/$artifactName-$packageVersion.crate" | ||
Copy-Item ` | ||
-Path $cratePath ` | ||
-Destination $outDir | ||
Write-Host "Contents of $outDir" | ||
Get-ChildItem -Path $outDir | ForEach-Object { Write-Host $_.FullName } | ||
displayName: 'Copy crate for ESRP' | ||
|
||
- task: EsrpRelease@10 | ||
displayName: 'ESRP Release' | ||
inputs: | ||
connectedservicename: 'Azure SDK PME Managed Identity' | ||
ClientId: '5f81938c-2544-4f1f-9251-dd9de5b8a81b' | ||
DomainTenantId: '975f013f-7f24-47e8-a7d3-abc4752bf346' | ||
Usemanagedidentity: true | ||
KeyVaultName: 'kv-azuresdk-codesign' | ||
SignCertName: 'azure-sdk-esrp-release-certificate' | ||
intent: 'packagedistribution' | ||
contenttype: 'Rust' | ||
contentsource: 'Folder' | ||
folderlocation: '$(Pipeline.Workspace)/esrp-release' | ||
waitforreleasecompletion: true | ||
owners: ${{ coalesce(variables['Build.RequestedForEmail'], '[email protected]') }} | ||
approvers: ${{ coalesce(variables['Build.RequestedForEmail'], '[email protected]') }} | ||
serviceendpointurl: 'https://api.esrp.microsoft.com/' | ||
mainpublisher: 'ESRPRELPACMANTEST' | ||
|
||
- job: UpdatePackageVersion | ||
displayName: "API Review and Package Version Update" | ||
|
@@ -130,69 +174,32 @@ stages: | |
displayName: Download ${{parameters.PipelineArtifactName}} artifact | ||
artifact: ${{parameters.PipelineArtifactName}} | ||
|
||
- template: /eng/common/pipelines/templates/steps/create-apireview.yml | ||
parameters: | ||
ArtifactPath: $(Pipeline.Workspace)/${{parameters.PipelineArtifactName}} | ||
Artifacts: ${{parameters.Artifacts}} | ||
ConfigFileDir: $(Pipeline.Workspace)/${{parameters.PipelineArtifactName}}/PackageInfo | ||
MarkPackageAsShipped: true | ||
ArtifactName: ${{parameters.PipelineArtifactName}} | ||
SourceRootPath: $(System.DefaultWorkingDirectory) | ||
PackageName: ${{artifact.name}} | ||
|
||
# Apply the version increment to each library, which updates the Cargo.toml and changelog files. | ||
- task: PowerShell@2 | ||
displayName: Increment ${{artifact.name}} version | ||
inputs: | ||
targetType: filePath | ||
filePath: $(Build.SourcesDirectory)/eng/scripts/Update-PackageVersion.ps1 | ||
arguments: > | ||
-ServiceDirectory '${{parameters.ServiceDirectory}}' | ||
-PackageName '${{artifact.name}}' | ||
- ${{ each artifact in parameters.Artifacts }}: | ||
- template: /eng/common/pipelines/templates/steps/create-apireview.yml | ||
parameters: | ||
ArtifactPath: $(Pipeline.Workspace)/${{parameters.PipelineArtifactName}} | ||
Artifacts: ${{parameters.Artifacts}} | ||
ConfigFileDir: $(Pipeline.Workspace)/${{parameters.PipelineArtifactName}}/PackageInfo | ||
MarkPackageAsShipped: true | ||
ArtifactName: ${{parameters.PipelineArtifactName}} | ||
SourceRootPath: $(System.DefaultWorkingDirectory) | ||
PackageName: ${{artifact.name}} | ||
|
||
# Apply the version increment to each library, which updates the Cargo.toml and changelog files. | ||
- task: PowerShell@2 | ||
displayName: Increment ${{artifact.name}} version | ||
inputs: | ||
targetType: filePath | ||
filePath: $(Build.SourcesDirectory)/eng/scripts/Update-PackageVersion.ps1 | ||
arguments: > | ||
-ServiceDirectory '${{parameters.ServiceDirectory}}' | ||
-PackageName '${{artifact.name}}' | ||
|
||
- template: /eng/common/pipelines/templates/steps/create-pull-request.yml | ||
parameters: | ||
PRBranchName: increment-package-version-${{parameters.ServiceDirectory}}-$(Build.BuildId) | ||
CommitMsg: "Increment package version after release of ${{ artifact.name }}" | ||
CommitMsg: "Increment package version after release of ${{ join(', ', parameters.Artifacts.*.name) }}" | ||
PRTitle: "Increment versions for ${{parameters.ServiceDirectory}} releases" | ||
CloseAfterOpenForTesting: '${{parameters.TestPipeline}}' | ||
${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}: | ||
BaseBranchName: main | ||
|
||
- ${{ if eq(parameters.TestPipeline, true) }}: | ||
- job: ManualApproval | ||
displayName: "Manual approval" | ||
dependsOn: PublishPackage | ||
condition: ne(variables['Skip.PublishPackage'], 'true') | ||
pool: server | ||
timeoutInMinutes: 120 # 2 hours | ||
steps: | ||
- task: ManualValidation@1 | ||
timeoutInMinutes: 60 # 1 hour | ||
inputs: | ||
notifyUsers: '' # Required, but empty string allowed | ||
allowApproversToApproveTheirOwnRuns: true | ||
instructions: "Approve yank of ${{ artifact.name }}" | ||
onTimeout: 'resume' | ||
|
||
- job: YankCrates | ||
displayName: "Yank Crates" | ||
dependsOn: ManualApproval | ||
condition: and(succeeded(), ne(variables['Skip.PublishPackage'], 'true')) | ||
steps: | ||
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml | ||
|
||
- download: current | ||
displayName: Download ${{parameters.PipelineArtifactName}} artifact | ||
artifact: ${{parameters.PipelineArtifactName}} | ||
|
||
- task: PowerShell@2 | ||
displayName: Yank Crates | ||
env: | ||
CARGO_REGISTRY_TOKEN: $(azure-sdk-cratesio-token) | ||
inputs: | ||
targetType: filePath | ||
filePath: $(Build.SourcesDirectory)/eng/scripts/Yank-Crates.ps1 | ||
arguments: | ||
-CrateNames '${{artifact.name}}' | ||
-PackageInfoDirectory '$(Pipeline.Workspace)/${{parameters.PipelineArtifactName}}/PackageInfo' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.