Skip to content

Commit 58e7d3a

Browse files
fix: migrate Rust crate publishing from cargo publish to ESRP Release
Replace direct cargo publish (CARGO_REGISTRY_TOKEN) with the official ESRP Release pipeline (EsrpRelease@11 with contenttype: Rust). Per EngHub guidance (aka.ms/esrp-crates-io), all Microsoft Rust packages must publish through ESRP under the microsoft-oss-releases crates.io account for code signing, malware scanning, and archival. Pipeline changes: - Build stage: cargo package → copy .crate to workspace - Publish stage: EsrpRelease@11 replaces cargo publish - Uses shared ESRP config (no separate CRATES_IO_TOKEN needed) Also updates PUBLISHING.md to reflect ESRP for Rust. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1f12833 commit 58e7d3a

File tree

2 files changed

+48
-22
lines changed

2 files changed

+48
-22
lines changed

PUBLISHING.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,17 @@ Publishing uses the ADO pipeline (`pipelines/esrp-publish.yml` with target `nuge
161161

162162
### Policy
163163

164-
The Rust crate is published to [crates.io](https://crates.io) via `cargo publish`
165-
in the ADO pipeline (`pipelines/esrp-publish.yml` with target `rust`).
164+
The Rust crate is published to [crates.io](https://crates.io) via **ESRP Release**
165+
using the ADO pipeline (`pipelines/esrp-publish.yml` with target `rust`).
166+
All crates are published under the official
167+
[`microsoft-oss-releases`](https://crates.io/users/microsoft-oss-releases) account.
166168

167-
> **Note:** ESRP does not currently support crates.io. Publishing uses a
168-
> crates.io API token stored as `CRATES_IO_TOKEN` in ADO pipeline variables.
169+
- Personal `cargo publish` with `CARGO_REGISTRY_TOKEN` is **not** used
170+
- ESRP handles code signing, malware scanning, and code archival
171+
- Crates must be packaged as `.crate` files via `cargo package`
172+
173+
> **To yank a crate**, file an IcM incident with the ESRP Release team.
174+
> Programmatic yanking is not currently supported.
169175
170176
### Published Packages
171177

@@ -175,8 +181,9 @@ in the ADO pipeline (`pipelines/esrp-publish.yml` with target `rust`).
175181

176182
### Prerequisites
177183

178-
- A crates.io API token stored as `CRATES_IO_TOKEN` (secret) in ADO pipeline variables
179-
- The token must belong to an account that owns the `agentmesh` crate
184+
- ESRP Release onboarding completed (same as PyPI/npm)
185+
- Crate is published under the `microsoft-oss-releases` crates.io account
186+
- No additional secrets needed beyond the shared ESRP configuration
180187

181188
### Building Locally
182189

@@ -314,7 +321,7 @@ The unified ESRP pipeline (`pipelines/esrp-publish.yml`) supports these targets:
314321
| `pypi` | PyPI | ESRP Release |
315322
| `npm` | npmjs.com (`@microsoft`) | ESRP Release |
316323
| `nuget` | NuGet.org | DotNetCoreCLI push |
317-
| `rust` | crates.io | `cargo publish` |
324+
| `rust` | crates.io | ESRP Release |
318325
| `go` | proxy.golang.org | Git tag |
319326
| `all` | All of the above ||
320327

pipelines/esrp-publish.yml

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -394,40 +394,59 @@ stages:
394394
395395
- script: |
396396
cargo package --list
397-
cargo package --allow-dirty
397+
cargo package
398398
echo "=== Packaged crate ==="
399-
ls -la target/package/
399+
ls -la target/package/*.crate
400+
# ESRP requires a zip containing the .crate file(s)
401+
mkdir -p $(Pipeline.Workspace)/rust-packages
402+
cp target/package/*.crate $(Pipeline.Workspace)/rust-packages/
400403
workingDirectory: 'packages/agent-mesh/sdks/rust/agentmesh'
401404
displayName: 'Package crate'
402405
403406
- task: PublishPipelineArtifact@1
404407
inputs:
405-
targetPath: 'packages/agent-mesh/sdks/rust/agentmesh/target/package'
408+
targetPath: '$(Pipeline.Workspace)/rust-packages'
406409
artifact: 'rust-agentmesh'
407410
publishLocation: 'pipeline'
408411
displayName: 'Publish crate artifact'
409412

410413
- stage: Publish_Rust
411-
displayName: 'Publish to crates.io'
414+
displayName: 'Publish to crates.io via ESRP'
412415
dependsOn: Build_Rust
413416
condition: and(succeeded(), eq('${{ parameters.dryRun }}', false), or(eq('${{ parameters.target }}', 'rust'), eq('${{ parameters.target }}', 'all')))
414417
jobs:
415418
- job: PublishCrate
416-
displayName: 'Publish agentmesh to crates.io'
419+
displayName: 'ESRP Publish agentmesh to crates.io'
417420
steps:
418-
- checkout: self
421+
- task: DownloadPipelineArtifact@2
422+
inputs:
423+
artifact: 'rust-agentmesh'
424+
targetPath: '$(Pipeline.Workspace)/rust-publish'
425+
displayName: 'Download crate artifact'
419426

420427
- script: |
421-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${{ parameters.rustVersion }}
422-
echo "##vso[task.prependpath]$HOME/.cargo/bin"
423-
displayName: 'Install Rust ${{ parameters.rustVersion }}'
428+
echo "=== Crates to publish ==="
429+
ls -la $(Pipeline.Workspace)/rust-publish/
430+
displayName: 'List crate packages'
424431
425-
- script: |
426-
cargo publish
427-
workingDirectory: 'packages/agent-mesh/sdks/rust/agentmesh'
428-
displayName: 'Publish to crates.io'
429-
env:
430-
CARGO_REGISTRY_TOKEN: $(CRATES_IO_TOKEN)
432+
- task: EsrpRelease@11
433+
displayName: 'ESRP Publish to crates.io'
434+
inputs:
435+
connectedservicename: 'Agent Governance Toolkit'
436+
usemanagedidentity: true
437+
keyvaultname: '$(ESRP_KEYVAULT_NAME)'
438+
signcertname: '$(ESRP_CERT_IDENTIFIER)'
439+
clientid: '$(ESRP_CLIENT_ID)'
440+
intent: 'PackageDistribution'
441+
contenttype: 'Rust'
442+
contentsource: 'Folder'
443+
folderlocation: '$(Pipeline.Workspace)/rust-publish'
444+
waitforreleasecompletion: true
445+
owners: '$(ESRP_OWNERS)'
446+
approvers: '$(ESRP_APPROVERS)'
447+
serviceendpointurl: 'https://api.esrp.microsoft.com'
448+
mainpublisher: 'ESRPRELPACMAN'
449+
domaintenantid: '$(ESRP_DOMAIN_TENANT_ID)'
431450

432451
# =======================================================
433452
# GO — github.com/microsoft/agent-governance-toolkit module

0 commit comments

Comments
 (0)