Skip to content

Comments

feat: Add a workflow to publish the crate through OIDC token exchange#16

Open
jasonz-dfinity wants to merge 2 commits intodfinity:mainfrom
jasonz-dfinity:jason/trusted-publish
Open

feat: Add a workflow to publish the crate through OIDC token exchange#16
jasonz-dfinity wants to merge 2 commits intodfinity:mainfrom
jasonz-dfinity:jason/trusted-publish

Conversation

@jasonz-dfinity
Copy link
Contributor

No description provided.

@cla-idx-bot
Copy link

cla-idx-bot bot commented Feb 17, 2026

Dear @jasonz-dfinity,

In order to potentially merge your code in this open-source repository and therefore proceed with your contribution, we need to have your approval on DFINITY's CLA.

If you decide to agree with it, please visit this issue and read the instructions there. Once you have signed it, re-trigger the workflow on this PR to see if your code can be merged.

— The DFINITY Foundation

@jasonz-dfinity jasonz-dfinity requested review from a team as code owners February 19, 2026 22:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a GitHub Actions release workflow to publish this Rust crate to crates.io using OIDC-based authentication.

Changes:

  • Introduces a release.published triggered workflow for publishing to crates.io.
  • Adds crates.io auth via rust-lang/crates-io-auth-action and passes the issued token to cargo publish.
  • Adds a guard step to verify Cargo.toml version matches the git tag version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

publish-crate:
runs-on: ubuntu-latest
environment: release
permissions:
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Job-level permissions only grants id-token: write, which removes default contents: read. actions/checkout typically needs contents: read to fetch the repository, so this workflow can fail with insufficient permissions. Add contents: read (and any other required scopes) alongside id-token: write.

Suggested change
permissions:
permissions:
contents: read

Copilot uses AI. Check for mistakes.
- name: Verify version matches tag
run: |
CARGO_VERSION=$(grep -m1 '^version' Cargo.toml | sed 's/.*"\(.*\)".*/\1/')
TAG_VERSION=${GITHUB_REF#refs/tags/v}
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TAG_VERSION=${GITHUB_REF#refs/tags/v} assumes tags are prefixed with v. If the tag is 1.1.1 (no v), TAG_VERSION becomes refs/tags/1.1.1 and the version check will always fail. Use GITHUB_REF_NAME/github.ref_name (or github.event.release.tag_name) and strip a leading v only if present.

Suggested change
TAG_VERSION=${GITHUB_REF#refs/tags/v}
TAG_VERSION="${GITHUB_REF_NAME#v}"

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +35
- name: Publish to crates.io
run: cargo publish
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow runs cargo publish without setting up a Rust toolchain. In this repo’s CI, Rust is installed explicitly via rustup, so publishing may be non-reproducible or break if the runner image changes. Add a Rust toolchain setup step (matching the version policy used in CI) before running cargo commands.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants