Skip to content

ci: Release libtortillas to crates.io on merge to main branch #144

Merged
artrixdotdev merged 8 commits intomainfrom
ci/release
Sep 14, 2025
Merged

ci: Release libtortillas to crates.io on merge to main branch #144
artrixdotdev merged 8 commits intomainfrom
ci/release

Conversation

@artrixdotdev
Copy link
Owner

@artrixdotdev artrixdotdev commented Sep 12, 2025

This PR intends to publish an alpha tagged release to https://crates.io on every merge to the main branch. Before this PR can be merged, a refactor needs to be implemented onto the PeerId struct to strip the text and commit hash from the VERSION before it is used to create a PeerId, otherwise we would be breaking the PeerIdFormat::Azureus spec.

See #145

Possible related issues:

Summary by CodeRabbit

  • New Features

    • Automatic prerelease publishing to crates.io with alpha versions derived from the short Git SHA for early access.
  • Documentation

    • Added package metadata (description, repository, keywords, categories, readme) to improve crate discoverability.
  • Chores

    • CI workflows updated: added reusable workflow invocation, adjusted triggers for main and PRs (disabled direct push trigger), and formatting/structure refinements without changing job logic.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 12, 2025

Walkthrough

Adds a prerelease "Publish Prerelease" GitHub Actions workflow, makes the CI checks workflow callable via workflow_call (disables direct push trigger), and adds package metadata to crates/libtortillas/Cargo.toml. No runtime code or public API changes.

Changes

Cohort / File(s) Change summary
CI workflow trigger adjustments
.github/workflows/checks.yml
Added workflow_call trigger; commented/removed push trigger for main; retained pull_request on main; only formatting/indentation changes to workflow file; job/step logic unchanged.
New prerelease publishing workflow
.github/workflows/release.yml
Added new workflow "Publish Prerelease" triggered on push to main for Cargo/Rust file changes; invokes checks via workflow_call; computes prerelease version <base>-alpha.<shortSHA>; sets crate version for libtortillas, verifies package, and publishes to crates.io using CARGO_REGISTRY_TOKEN.
Crate metadata additions
crates/libtortillas/Cargo.toml
Added package metadata fields: description, repository, keywords, categories, and readme under [package]; no dependency or API changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant GH as GitHub
  participant ReleaseWF as .github/workflows/release.yml
  participant ChecksWF as .github/workflows/checks.yml
  participant Cargo as crates.io / cargo

  Dev->>GH: Push to main (Cargo.toml / .rs changes)
  GH->>ReleaseWF: trigger "Publish Prerelease"
  rect rgba(200,220,255,0.25)
    note right of ReleaseWF: Run CI gate
    ReleaseWF->>ChecksWF: workflow_call (run checks)
    ChecksWF-->>ReleaseWF: status (success/failure)
  end
  alt checks succeed
    ReleaseWF->>ReleaseWF: derive BASE_VERSION (cargo pkgid)
    ReleaseWF->>ReleaseWF: compute PRERELEASE_VERSION = BASE_VERSION-alpha.<7-char SHA>
    ReleaseWF->>ReleaseWF: cargo set-version -p libtortillas --no-workspace
    ReleaseWF->>Cargo: cargo package && cargo publish (with CARGO_REGISTRY_TOKEN)
    Cargo-->>ReleaseWF: publish result
  else checks fail
    ReleaseWF-->>GH: workflow fails
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely summarizes the primary change: adding CI to publish the libtortillas crate to crates.io on merges to main. It uses the conventional "ci:" prefix, names the crate, and specifies the trigger (merge to main), which matches the added release workflow and related metadata changes in the diff.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ci/release

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d56420 and b9a5f95.

📒 Files selected for processing (2)
  • .github/workflows/release.yml (1 hunks)
  • crates/libtortillas/Cargo.toml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/libtortillas/Cargo.toml
  • .github/workflows/release.yml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (2)
crates/libtortillas/Cargo.toml (1)

6-6: Fix grammar and capitalization in description.

Use “An asynchronous” and capitalize “BitTorrent.”

Apply:

-description = "A asynchronous library based on the actor model for interacting with the bittorrent protocol"
+description = "An asynchronous library based on the actor model for interacting with the BitTorrent protocol"
.github/workflows/release.yml (1)

17-19: Consider concurrency control to avoid overlapping publishes.

Back-to-back merges could race; serialize by ref.

Add:

concurrency:
  group: prerelease-${{ github.ref }}
  cancel-in-progress: false
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 813070e and b9dbac5.

📒 Files selected for processing (3)
  • .github/workflows/checks.yml (1 hunks)
  • .github/workflows/release.yml (1 hunks)
  • crates/libtortillas/Cargo.toml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/checks.yml

40-40: the runner of "actions-rs/cargo@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (4)
crates/libtortillas/Cargo.toml (1)

7-9: Metadata looks good for crates.io.

.github/workflows/checks.yml (1)

3-9: Trigger strategy makes sense.

Disabling push-to-main here and invoking via reusable workflow is fine given release.yml calls it.

.github/workflows/release.yml (2)

3-11: Confirm trigger scope.

This publishes on any Rust/Cargo change anywhere in the repo. If you intend to publish only when libtortillas changes, narrow paths to crates/libtortillas/**.

Suggested tweak:

-      paths:
-         - "**/Cargo.toml"
-         - "**/Cargo.lock"
-         - "**/*.rs"
+      paths:
+         - "crates/libtortillas/**"

41-43: Ensure CARGO_REGISTRY_TOKEN is set in repo secrets.

Without it, publish will fail. Also validate crates.io ownership for libtortillas.

artrixdotdev and others added 2 commits September 12, 2025 23:11
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@coderabbitai coderabbitai bot added the high prio GET DONE ASAP!! label Sep 14, 2025
@artrixdotdev artrixdotdev merged commit e40895c into main Sep 14, 2025
3 checks passed
@artrixdotdev artrixdotdev deleted the ci/release branch September 14, 2025 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

high prio GET DONE ASAP!!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant