Skip to content

Commit e40895c

Browse files
authored
ci: Release libtortillas to crates.io on merge to main branch (#144)
2 parents 5f05f6e + b9a5f95 commit e40895c

File tree

3 files changed

+107
-50
lines changed

3 files changed

+107
-50
lines changed

.github/workflows/checks.yml

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,68 @@
11
name: ✅ Checks
22
on:
3-
push:
4-
branches: [ "main" ]
5-
pull_request:
6-
branches: [ "main" ]
3+
# No long run pushes on main since it will be called by the release workflow
4+
# push:
5+
# branches: [ "main" ]
6+
pull_request:
7+
branches: ["main"]
8+
workflow_call:
79

810
env:
9-
CARGO_TERM_COLOR: always
10-
RUSTFLAGS: "-C target-cpu=native"
11-
CARGO_INCREMENTAL: 0
12-
RUST_BACKTRACE: 1
11+
CARGO_TERM_COLOR: always
12+
RUSTFLAGS: "-C target-cpu=native"
13+
CARGO_INCREMENTAL: 0
14+
RUST_BACKTRACE: 1
1315

1416
jobs:
15-
build_and_test:
16-
runs-on: ubuntu-latest
17-
steps:
18-
- name: 📥 Checkout code
19-
uses: actions/checkout@v4
17+
build_and_test:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: 📥 Checkout code
21+
uses: actions/checkout@v4
2022

21-
- name: 🦀 Install Rust toolchain
22-
uses: dtolnay/rust-toolchain@nightly
23-
with:
24-
components: clippy, rustfmt
23+
- name: 🦀 Install Rust toolchain
24+
uses: dtolnay/rust-toolchain@nightly
25+
with:
26+
components: clippy, rustfmt
2527

26-
- name: 💾 Rust Cache
27-
uses: Swatinem/rust-cache@v2
28-
with:
29-
shared-key: "build-cache"
28+
- name: 💾 Rust Cache
29+
uses: Swatinem/rust-cache@v2
30+
with:
31+
shared-key: "build-cache"
3032

31-
- name: 🔨 Build
32-
run: cargo build --verbose
33+
- name: 🔨 Build
34+
run: cargo build --verbose
3335

34-
- name: Install latest nextest release
35-
uses: taiki-e/install-action@nextest
36+
- name: Install latest nextest release
37+
uses: taiki-e/install-action@nextest
3638

37-
- name: 🧪 Run tests
38-
uses: actions-rs/cargo@v1
39-
with:
40-
command: nextest
41-
args: run --nocapture --no-fail-fast
39+
- name: 🧪 Run tests
40+
uses: actions-rs/cargo@v1
41+
with:
42+
command: nextest
43+
args: run --nocapture --no-fail-fast
4244

43-
lint:
44-
runs-on: ubuntu-latest
45-
steps:
46-
- name: 📥 Checkout code
47-
uses: actions/checkout@v4
45+
lint:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: 📥 Checkout code
49+
uses: actions/checkout@v4
4850

49-
- name: 🦀 Install Rust toolchain
50-
uses: dtolnay/rust-toolchain@nightly
51-
with:
52-
components: clippy, rustfmt
51+
- name: 🦀 Install Rust toolchain
52+
uses: dtolnay/rust-toolchain@nightly
53+
with:
54+
components: clippy, rustfmt
5355

54-
- name: 💾 Rust Cache
55-
uses: Swatinem/rust-cache@v2
56-
with:
57-
shared-key: "lint-cache"
56+
- name: 💾 Rust Cache
57+
uses: Swatinem/rust-cache@v2
58+
with:
59+
shared-key: "lint-cache"
5860

59-
- name: 🔍 Run linter
60-
run: cargo clippy --all-targets --all-features -- -D warnings
61+
- name: 🔍 Run linter
62+
run: cargo clippy --all-targets --all-features -- -D warnings
6163

62-
- name: 💅 Run format checker
63-
run: cargo fmt --check
64-
65-
- name: 📖 Run doc linter
66-
run: cargo doc --no-deps --document-private-items
64+
- name: 💅 Run format checker
65+
run: cargo fmt --check
66+
67+
- name: 📖 Run doc linter
68+
run: cargo doc --no-deps --document-private-items

.github/workflows/release.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Publish Prerelease
2+
3+
on:
4+
push:
5+
paths:
6+
# Only run if these files are changed
7+
- "**/Cargo.toml"
8+
- "**/Cargo.lock"
9+
- "**/*.rs"
10+
branches:
11+
- main
12+
13+
jobs:
14+
checks:
15+
uses: ./.github/workflows/checks.yml
16+
publish-crates-io:
17+
name: Publish prerelease to crates.io
18+
runs-on: ubuntu-latest
19+
needs: checks
20+
concurrency:
21+
group: prerelease-${{ github.ref }}
22+
cancel-in-progress: false
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Install Rust
27+
uses: dtolnay/rust-toolchain@nightly
28+
29+
- name: Install cargo-edit
30+
run: cargo install cargo-edit --locked
31+
32+
- name: Compute prerelease version
33+
id: version
34+
run: |
35+
BASE_VERSION=$(cargo pkgid -p libtortillas | sed 's/.*#//')
36+
PRERELEASE_VERSION="${BASE_VERSION}-alpha.${GITHUB_SHA::7}"
37+
echo "prerelease_version=$PRERELEASE_VERSION" >> $GITHUB_OUTPUT
38+
39+
- name: Set prerelease version
40+
run: |
41+
cargo set-version -p libtortillas --no-workspace ${{ steps.version.outputs.prerelease_version }}
42+
43+
- name: Verify package (pre-publish)
44+
run: cargo package -p libtortillas --allow-dirty
45+
46+
- name: Publish to crates.io
47+
env:
48+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
49+
run: cargo publish -p libtortillas --allow-dirty

crates/libtortillas/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ name = "libtortillas"
33
license = "MPL-2.0"
44
version = "0.0.0"
55
edition = "2024"
6+
description = "An asynchronous library based on the actor model for interacting with the BitTorrent protocol"
7+
repository = "https://github.com/artrixdotdev/tortillas"
8+
keywords = ["bittorrent", "p2p", "torrent"]
9+
categories = ["network-programming", "concurrency"]
10+
readme = "../../README.md"
11+
612

713
[dependencies]
814
serde = { workspace = true }

0 commit comments

Comments
 (0)