-
Notifications
You must be signed in to change notification settings - Fork 263
Max/crates publishing tweaks #6343
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
mfahampshire
wants to merge
42
commits into
develop
Choose a base branch
from
max/crates-publishing-tweaks
base: develop
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 41 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
4d588a8
add semver validator action
mfahampshire a4a59c2
update runner
mfahampshire 20bc24c
Release 1.20.2
mfahampshire eb35e3e
update runner with sed for old version in CI
mfahampshire 53a6ba9
Add no commit to publish for the moment
mfahampshire 4462d6f
try switch to gh runner
mfahampshire eb1d952
switch runner back
mfahampshire 49444c5
get rid of npx for the moment
mfahampshire a0bb294
tweak version command
mfahampshire 3d3ef89
fix version bump command
mfahampshire 6964d89
configure git bot
mfahampshire 151514b
error check
mfahampshire 0e84493
remove `--from-git`
mfahampshire 986e194
make dryrun less opaque
mfahampshire a32548f
Reintroduce error check - keep logging dryrun in for debug (commented
mfahampshire 40b5b1c
fix grep check
mfahampshire 3ae1817
bring non-dry-run to parity
mfahampshire b033900
add node for npx semver check to action
mfahampshire 80e7cdf
updated sed command
mfahampshire 4175de5
revert erroneous version bump
mfahampshire 293456e
added semver check to publish workflow
mfahampshire dd59779
allow from other branches
mfahampshire bf6e8de
Release 1.20.2
30e9bed
allow from other branches again
mfahampshire d12b129
publishing guide
mfahampshire 065258f
Merge branch 'max/crates-publishing-tweaks' of github.com:nymtech/nym…
mfahampshire fcf2b26
Release 1.20.3
8126a0d
update publication runner
mfahampshire adaf5c3
Merge branch 'max/crates-publishing-tweaks' of github.com:nymtech/nym…
mfahampshire 82d2687
remove --allow-branch ; no commit, doesn't need branch restrictions
mfahampshire 5f04e39
remove another clashing flag
mfahampshire f5052b1
again
mfahampshire 7f517d8
exclude build.rs from crate for crates.io
mfahampshire 796c2df
various in process scripts to pick up deployment where it left off
mfahampshire 3141104
rename workflows
mfahampshire 0fe2a9f
Version bump fix from borked publish run
mfahampshire bce949e
temp push edit
mfahampshire 0b9bc24
add publishing doc + updated publish-resume ci
mfahampshire 3b7ff3f
move example from service-providers to sdk examples/ to remove circul…
mfahampshire dd4e60f
remove wildcard version import
mfahampshire 46c738d
Workflows and documentation for publication
mfahampshire 3a17e2f
add contracts/ patch + imports
mfahampshire 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,79 @@ | ||
| name: Publish to crates.io (dry run) | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: "Version to publish (e.g. 1.21.0)" | ||
| required: true | ||
| type: string | ||
|
|
||
| env: | ||
| CI_BOT_AUTHOR: "Nym bot" | ||
| CI_BOT_EMAIL: "nym-bot@users.noreply.github.com" | ||
|
|
||
| jobs: | ||
| publish-dry-run: | ||
| runs-on: arc-linux-latest | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Configure git identity | ||
| run: | | ||
| git config --global user.name "${{ env.CI_BOT_AUTHOR }}" | ||
| git config --global user.email "${{ env.CI_BOT_EMAIL }}" | ||
|
|
||
| - name: Install rust toolchain | ||
| uses: actions-rs/toolchain@v1 | ||
| with: | ||
| profile: minimal | ||
| toolchain: stable | ||
| override: true | ||
|
|
||
| - name: Install cargo-workspaces | ||
| run: cargo install cargo-workspaces | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
|
|
||
| - name: Validate version format | ||
| run: | | ||
| if ! npx semver "${{ inputs.version }}"; then | ||
| echo "Error: '${{ inputs.version }}' is not valid semver" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Get current version | ||
| id: current_version | ||
| run: | | ||
| VERSION=$(grep -oP '^\s*version\s*=\s*"\K[0-9]+\.[0-9]+\.[0-9]+' Cargo.toml | head -1) | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Update workspace dependencies | ||
| run: | | ||
| sed -i '/path = /s/version = "${{ steps.current_version.outputs.version }}"/version = "${{ inputs.version }}"/g' Cargo.toml | ||
|
|
||
| - name: Bump versions (local only) | ||
| run: | | ||
| cargo workspaces version custom ${{ inputs.version }} \ | ||
| --allow-branch ${{ github.ref_name }} \ | ||
| --no-git-commit \ | ||
|
|
||
| # Dry run may show cascading dependency errors because packages aren't | ||
| # actually uploaded - these are expected and ignored. We check for real | ||
| # errors like packaging failures, missing metadata, or invalid Cargo.toml. | ||
| - name: Publish (dry run) | ||
| run: | | ||
| output=$(cargo workspaces publish --dry-run --allow-dirty 2>&1) || true | ||
| echo "$output" | ||
|
|
||
| # Check for real errors (not cascading dependency errors) | ||
| # Cascading errors mention "crates.io index", real errors mention "Cargo.toml" | ||
| echo "$output" | grep -i "Cargo.toml" && exit 1 || true | ||
|
|
||
| # Show the list of packages published | ||
| - name: Show package versions | ||
| run: cargo workspaces list --long |
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,59 @@ | ||
| # This is in case, for whatever reason, a publication run fails, and we need to restart halfway down the list, of unbumped/unpublished crates. | ||
| name: Resume crates.io publish | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| resume_after: | ||
| description: "Last successfully published crate (will start from the next one)" | ||
| required: true | ||
| type: string | ||
| publish_interval: | ||
| description: "Seconds to wait between publishes" | ||
| required: false | ||
| default: "600" | ||
| type: string | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: arc-linux-latest | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Install rust toolchain | ||
| uses: actions-rs/toolchain@v1 | ||
| with: | ||
| profile: minimal | ||
| toolchain: stable | ||
| override: true | ||
|
|
||
| - name: Install cargo-workspaces | ||
| run: cargo install cargo-workspaces | ||
|
|
||
| # Get crates in publish order, skip up to and including resume_after | ||
| - name: Publish remaining crates | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| CRATES=$(cargo workspaces plan 2>/dev/null | sed -n '/^${{ inputs.resume_after }}$/,$p' | tail -n +2) | ||
|
|
||
| if [ -z "$CRATES" ]; then | ||
| echo "Error: No crates found after '${{ inputs.resume_after }}'" | ||
| echo "Check the crate name matches exactly from 'cargo workspaces plan'" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Will publish the following crates:" | ||
| echo "$CRATES" | ||
| echo "" | ||
|
|
||
| echo "$CRATES" | while read crate; do | ||
| echo "Publishing $crate..." | ||
| cargo publish -p "$crate" --allow-dirty | ||
| echo "Waiting ${{ inputs.publish_interval }}s before next publish..." | ||
| sleep ${{ inputs.publish_interval }} | ||
| done | ||
|
|
||
| - name: Show package versions | ||
| run: cargo workspaces list --long |
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,86 @@ | ||
| name: Publish crates to crates.io | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| publish_interval: | ||
| description: "Seconds to wait between publishes (600 for first publish, 60 after)" | ||
| required: false | ||
| default: "600" | ||
| type: string | ||
| backup_author: | ||
| description: "Second team member added as owner of the crate" | ||
| required: false | ||
| default: "jstuczyn" | ||
| type: string | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: arc-linux-latest | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Install rust toolchain | ||
| uses: actions-rs/toolchain@v1 | ||
| with: | ||
| profile: minimal | ||
| toolchain: stable | ||
| override: true | ||
|
|
||
| - name: Install cargo-workspaces | ||
| run: cargo install cargo-workspaces | ||
|
|
||
| # `--publish-as-is` skips version bumping since that's done in a separate CI job. | ||
| - name: Publish | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| cargo workspaces publish \ | ||
| --publish-as-is \ | ||
| --publish-interval ${{ inputs.publish_interval }} | ||
|
|
||
| - name: Show package versions | ||
| run: cargo workspaces list --long | ||
|
|
||
| - name: Add team as crate owners | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| TEAM="github:nymtech:core" | ||
| echo "Checking and adding $TEAM as owner to workspace crates..." | ||
|
|
||
| cargo workspaces list | while read crate; do | ||
| echo "Checking $crate..." | ||
|
|
||
| if cargo owner --list "$crate" 2>/dev/null | grep -q "$TEAM"; then | ||
| echo " $TEAM already owns $crate, skipping" | ||
| else | ||
| echo " Adding $TEAM as owner of $crate..." | ||
| cargo owner --add "$TEAM" "$crate" | ||
| sleep 2 | ||
| fi | ||
| done | ||
|
|
||
| echo "Done!" | ||
|
|
||
| - name: Add secondary member as crate owner | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| TEAM_MEMBER="${{ inputs.backup_author }}" | ||
| echo "Checking and adding $TEAM_MEMBER as owner to workspace crates..." | ||
|
|
||
| cargo workspaces list | while read crate; do | ||
| echo "Checking $crate..." | ||
|
|
||
| if cargo owner --list "$crate" 2>/dev/null | grep -q "$TEAM_MEMBER"; then | ||
| echo " $TEAM_MEMBER already owns $crate, skipping" | ||
| else | ||
| echo " Adding $TEAM_MEMBER as owner of $crate..." | ||
| cargo owner --add "$TEAM_MEMBER" "$crate" | ||
| sleep 2 | ||
| fi | ||
| done | ||
|
|
||
| echo "Done!" | ||
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,74 @@ | ||
| name: Bump crate versions | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: "Version to set (e.g. 1.21.0)" | ||
| required: true | ||
| type: string | ||
|
|
||
| env: | ||
| CI_BOT_AUTHOR: "Nym bot" | ||
| CI_BOT_EMAIL: "nym-bot@users.noreply.github.com" | ||
|
|
||
| jobs: | ||
| version-bump: | ||
| runs-on: arc-linux-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Configure git identity | ||
| run: | | ||
| git config --global user.name "${{ env.CI_BOT_AUTHOR }}" | ||
| git config --global user.email "${{ env.CI_BOT_EMAIL }}" | ||
|
|
||
| - name: Install rust toolchain | ||
| uses: actions-rs/toolchain@v1 | ||
| with: | ||
| profile: minimal | ||
| toolchain: stable | ||
| override: true | ||
|
|
||
| - name: Install cargo-workspaces | ||
| run: cargo install cargo-workspaces | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
|
|
||
| - name: Validate version format | ||
| run: | | ||
| if ! npx semver "${{ inputs.version }}"; then | ||
| echo "Error: '${{ inputs.version }}' is not valid semver" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Get current version | ||
| id: current_version | ||
| run: | | ||
| VERSION=$(grep -oP '^\s*version\s*=\s*"\K[0-9]+\.[0-9]+\.[0-9]+' Cargo.toml | head -1) | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Update workspace dependencies | ||
| run: | | ||
| sed -i '/path = /s/version = "${{ steps.current_version.outputs.version }}"/version = "${{ inputs.version }}"/g' Cargo.toml | ||
|
|
||
| - name: Bump versions | ||
| run: | | ||
| cargo workspaces version custom ${{ inputs.version }} \ | ||
| --no-git-commit \ | ||
| --yes | ||
|
|
||
| - name: Commit and push version bump | ||
| run: | | ||
| git add -A | ||
| git commit -m "crates release: bump version to ${{ inputs.version }}" | ||
| git push | ||
|
|
||
| - name: Show package versions | ||
| run: cargo workspaces list --long |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given how long the process takes, if it's not too difficult it could be useful to send zulip notifications on failures