Repository navigation
Add Rust SDK crates.io release pipeline #1337
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
Merged
Branden Bonaby (bbonaby)
merged 7 commits into
main
from
user/bbonaby/rust-crates-publishing
Oct 6, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8effeab
Add Rust crates publishing pipeline
bbonaby 787f3cf
Address crates publishing review feedback
bbonaby ce31451
Require crates.io validation before ESRP publication
bbonaby d5d8089
Fix crate packaging registry selection
bbonaby bce76d3
Package unpublished crate dependencies offline
bbonaby 13a7372
Use the dependency mirror for crate packaging
bbonaby 382cfba
Merge main and update crates release pipeline
bbonaby 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 |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
| # | ||
| # MXC Crates.io Release Pipeline (ESRP) | ||
| # | ||
| # Packages mxc-sdk and submits it to crates.io through ESRP. | ||
| # | ||
| # Crate versions come from src/Cargo.toml at that ref. | ||
| # | ||
| # Setup and prerequisites: .azure-pipelines/README.md | ||
|
|
||
| trigger: none | ||
| pr: none | ||
|
|
||
| name: $(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r) | ||
|
|
||
| resources: | ||
| repositories: | ||
| - repository: 1ESPipelineTemplates | ||
| type: git | ||
| name: 1ESPipelineTemplates/1ESPipelineTemplates | ||
| ref: refs/tags/release | ||
|
|
||
| parameters: | ||
| - name: dryRun | ||
| displayName: 'Dry run β run Cargo publication checks without uploading' | ||
| type: boolean | ||
| default: true | ||
|
|
||
| variables: | ||
| - group: MXC-ESRP-Signing | ||
|
|
||
| extends: | ||
| template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates | ||
| parameters: | ||
| pool: | ||
| name: Azure-Pipelines-1ESPT-ExDShared | ||
| image: windows-2022 | ||
| os: windows | ||
| customBuildTags: | ||
| - ES365AIMigrationTooling | ||
|
|
||
| sdl: | ||
| sourceAnalysisPool: | ||
| name: Azure-Pipelines-1ESPT-ExDShared | ||
| image: windows-latest | ||
| os: windows | ||
|
|
||
| stages: | ||
| # Create the crate artifact consumed by the publish stage. | ||
| - stage: Package_Crates_For_Release | ||
| displayName: 'Package Crates' | ||
| dependsOn: [] | ||
| jobs: | ||
| - template: templates/Package.Crates.Job.yml@self | ||
|
|
||
| - stage: Publish_to_CratesIo | ||
| displayName: 'Publish Crates.io Packages' | ||
| dependsOn: Package_Crates_For_Release | ||
| condition: succeeded() | ||
| jobs: | ||
| - template: templates/Publish.CratesIo.Job.yml@self | ||
| parameters: | ||
| ESRPInfo: | ||
| serviceName: $(serviceName) | ||
| tenantId: $(tenantId) | ||
| azureKeyVaultName: $(azureKeyVaultName) | ||
| authCertName: $(authCertName) | ||
| signCertName: $(signCertName) | ||
| clientId: $(clientId) | ||
| OwnersEmail: $(Build.RequestedForEmail) | ||
| ApproversEmail: $(Build.RequestedForEmail) | ||
| dryRun: ${{ parameters.dryRun }} |
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
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 |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
| # | ||
| # Packages mxc-sdk into a .crate file using `cargo package --no-verify`. The | ||
| # publish template always performs Cargo's crates.io dry run before a | ||
| # production ESRP release. | ||
| # | ||
| # The steps hold no logic: Invoke-CratePackage.ps1 does the packaging and | ||
| # validates the single published crate, and the same command reproduces a leg | ||
| # locally. | ||
|
|
||
| parameters: | ||
| - name: cratesArtifactName | ||
| type: string | ||
| default: mxc-crates-package | ||
|
|
||
| jobs: | ||
| - job: package_crates | ||
| displayName: Package Crates | ||
| pool: | ||
| name: Azure-Pipelines-1ESPT-ExDShared | ||
| image: ubuntu-latest | ||
| os: linux | ||
|
|
||
| variables: | ||
| outDir: $(Build.SourcesDirectory)/out/crates | ||
|
|
||
| templateContext: | ||
| rust: | ||
| rustToolchain: | ||
| toolchainFeed: https://microsoft.pkgs.visualstudio.com/Dart/_packaging/Mxc-Azure-Feed/nuget/v3/index.json | ||
| version: 'ms-prod-1.93' | ||
|
|
||
| steps: | ||
| - checkout: self | ||
|
|
||
| # Configure and authenticate the private registry explicitly before the | ||
| # 1ES task installs the internal Rust toolchain. | ||
| - template: Cargo.Setup.Private.yml@self | ||
| parameters: | ||
| authenticate: true | ||
|
|
||
| - task: 1ES.Build.Rust.Setup@1 | ||
|
|
||
| - task: PowerShell@2 | ||
| displayName: Package mxc-sdk | ||
| inputs: | ||
| targetType: filePath | ||
| filePath: $(Build.SourcesDirectory)/scripts/ci/Invoke-CratePackage.ps1 | ||
| arguments: -OutDir '$(outDir)' -PackageRegistry 'Mxc-Azure-Feed' | ||
| pwsh: true | ||
| workingDirectory: $(Build.SourcesDirectory) | ||
|
|
||
| - task: 1ES.PublishPipelineArtifact@1 | ||
| displayName: Publish crate package artifact | ||
| inputs: | ||
| path: $(outDir) | ||
| artifactName: ${{ parameters.cratesArtifactName }} |
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 |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
| # | ||
| # Publishes mxc-sdk to crates.io through ESRP Release under the | ||
| # microsoft-oss-releases account. Consumes the mxc-crates-package artifact. | ||
| # | ||
| # Dry runs invoke Cargo against the checked-out workspace. Real releases submit | ||
| # one packaged crate per ESRP task; each task waits for completion before the | ||
| # crate is submitted. CI keeps the crate parameter synchronized. | ||
| # | ||
| # The pool enforces 1ES network isolation (CFSClean), so this job performs no | ||
| # crates.io reads. | ||
|
|
||
| parameters: | ||
| - name: ESRPInfo | ||
| type: object | ||
| - name: publishCrates | ||
| type: object | ||
| # Keep this list internal to the template so release operators cannot | ||
| # override the Cargo-validated publication order at queue time. | ||
| default: | ||
| # BEGIN MXC-SDK PUBLISH CRATES | ||
| - mxc-sdk | ||
| # END MXC-SDK PUBLISH CRATES | ||
| - name: dryRun | ||
| type: boolean | ||
| default: true | ||
| - name: cratesArtifactName | ||
| type: string | ||
| default: mxc-crates-package | ||
|
|
||
| jobs: | ||
| - job: validate_crates_publication | ||
| displayName: Validate crates.io publication | ||
| pool: | ||
| name: Azure-Pipelines-1ESPT-ExDShared | ||
| image: ubuntu-latest | ||
| os: linux | ||
| templateContext: | ||
| rust: | ||
| rustToolchain: | ||
| toolchainFeed: https://microsoft.pkgs.visualstudio.com/Dart/_packaging/Mxc-Azure-Feed/nuget/v3/index.json | ||
| version: 'ms-prod-1.93' | ||
| steps: | ||
| - checkout: self | ||
|
|
||
| - template: Cargo.Setup.Private.yml@self | ||
| parameters: | ||
| authenticate: true | ||
|
|
||
| - task: 1ES.Build.Rust.Setup@1 | ||
|
|
||
| - pwsh: | | ||
| $ErrorActionPreference = 'Stop' | ||
| $crates = [string[]] ($env:PUBLISH_CRATES_JSON | ConvertFrom-Json) | ||
| $arguments = [System.Collections.Generic.List[string]]::new() | ||
| $arguments.Add('publish') | ||
| $arguments.Add('--dry-run') | ||
| $arguments.Add('--locked') | ||
|
Comment on lines
+57
to
+59
|
||
| $arguments.Add('--manifest-path') | ||
| $arguments.Add('src/Cargo.toml') | ||
| foreach ($crate in $crates) | ||
| { | ||
| $arguments.Add('-p') | ||
| $arguments.Add($crate) | ||
| } | ||
| Write-Host "cargo $($arguments -join ' ')" | ||
| cargo @arguments | ||
| if ($LASTEXITCODE -ne 0) { throw "cargo publish --dry-run failed with exit $LASTEXITCODE" } | ||
| displayName: Cargo publish dry run | ||
| env: | ||
| PUBLISH_CRATES_JSON: ${{ convertToJson(parameters.publishCrates) }} | ||
|
|
||
| - ${{ if eq(parameters.dryRun, false) }}: | ||
| - job: publish_crates | ||
| displayName: Publish crates to crates.io (ESRP) | ||
| dependsOn: validate_crates_publication | ||
| condition: succeeded() | ||
| pool: | ||
| name: Azure-Pipelines-1ESPT-ExDShared | ||
| image: windows-2022 | ||
| os: windows | ||
| templateContext: | ||
| type: releaseJob | ||
| isProduction: true | ||
| inputs: | ||
| - input: pipelineArtifact | ||
| artifactName: ${{ parameters.cratesArtifactName }} | ||
| targetPath: $(Pipeline.Workspace)/crates | ||
| variables: | ||
| cratesDir: $(Pipeline.Workspace)/crates | ||
| steps: | ||
| - pwsh: | | ||
| $ErrorActionPreference = 'Stop' | ||
| $ref = $env:SOURCE_REF | ||
| Write-Host "Run was queued against: $ref" | ||
| if ($ref -cnotlike 'refs/tags/v?*') | ||
| { | ||
| throw "Crates.io publication requires refs/tags/v*; queued ref was '$ref'." | ||
| } | ||
| Write-Host "Releasing from tag $($ref.Substring('refs/tags/'.Length))" | ||
| displayName: Require a version tag | ||
| env: | ||
| SOURCE_REF: $(Build.SourceBranch) | ||
|
|
||
| - ${{ each crate in parameters.publishCrates }}: | ||
| - task: EsrpRelease@12 | ||
|
bbonaby marked this conversation as resolved.
|
||
| displayName: "Publish ${{ crate }} to crates.io" | ||
| inputs: | ||
| connectedservicename: ${{ parameters.ESRPInfo.serviceName }} | ||
| usemanagedidentity: false | ||
| keyvaultname: ${{ parameters.ESRPInfo.azureKeyVaultName }} | ||
| authcertname: ${{ parameters.ESRPInfo.authCertName }} | ||
| signcertname: ${{ parameters.ESRPInfo.signCertName }} | ||
| clientid: ${{ parameters.ESRPInfo.clientId }} | ||
| intent: 'PackageDistribution' | ||
| contenttype: 'Rust' | ||
| contentsource: 'Folder' | ||
| folderlocation: $(cratesDir)\${{ crate }} | ||
| owners: ${{ parameters.ESRPInfo.OwnersEmail }} | ||
| approvers: ${{ parameters.ESRPInfo.ApproversEmail }} | ||
| waitforreleasecompletion: true | ||
| serviceendpointurl: 'https://api.esrp.microsoft.com' | ||
| mainpublisher: 'ESRPRELPACMAN' | ||
| domaintenantid: ${{ parameters.ESRPInfo.tenantId }} | ||
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.