Skip to content

Commit 845d97a

Browse files
author
Alex
committed
chore: strip Gitea registry refs for crates.io publish
1 parent 5a9470d commit 845d97a

6 files changed

Lines changed: 98 additions & 11 deletions

File tree

.cargo/config.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,3 @@
22
global-credential-providers = ["cargo:token"]
33

44
# terraphim-core is consumed from the Terraphim org registry (public-read).
5-
[registries.terraphim]
6-
index = "sparse+https://git.terraphim.cloud/api/packages/terraphim/cargo/"

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
workflow_dispatch:
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
RUST_BACKTRACE: 1
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: dtolnay/rust-toolchain@stable
19+
with:
20+
components: rustfmt, clippy
21+
- uses: Swatinem/rust-cache@v2
22+
- run: cargo fmt --all -- --check
23+
- run: cargo clippy --workspace --all-targets -- -D warnings
24+
- run: cargo build --workspace
25+
- run: cargo test --workspace --lib --no-fail-fast
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Publish Crates
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
crate_list:
6+
description: Space-separated crate package names to publish in order
7+
required: true
8+
type: string
9+
dry_run:
10+
description: Run cargo publish --dry-run only
11+
required: false
12+
default: "true"
13+
type: choice
14+
options: ["true", "false"]
15+
16+
env:
17+
CARGO_TERM_COLOR: always
18+
19+
jobs:
20+
publish:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: dtolnay/rust-toolchain@stable
27+
- uses: Swatinem/rust-cache@v2
28+
- name: Publish crates in dependency order
29+
env:
30+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
31+
CRATE_LIST: ${{ inputs.crate_list }}
32+
DRY_RUN: ${{ inputs.dry_run }}
33+
run: |
34+
set -euo pipefail
35+
for crate in $CRATE_LIST; do
36+
manifest="crates/$crate/Cargo.toml"
37+
if [ ! -f "$manifest" ]; then
38+
echo "Missing manifest for $crate at $manifest" >&2
39+
exit 1
40+
fi
41+
version=$(grep -m1 '^version' "$manifest" | sed 's/.*"\(.*\)".*/\1/')
42+
# Check crates.io with auth to avoid rate limits
43+
if curl -fsS -H "Authorization: ${CARGO_REGISTRY_TOKEN}" "https://crates.io/api/v1/crates/$crate/$version" >/dev/null 2>&1; then
44+
echo "$crate $version already exists on crates.io; skipping"
45+
continue
46+
fi
47+
if [ "$DRY_RUN" = "true" ]; then
48+
cargo publish --manifest-path "$manifest" --dry-run
49+
else
50+
set +e
51+
output=$(cargo publish --manifest-path "$manifest" 2>&1)
52+
exit_code=$?
53+
set -e
54+
if [ "$exit_code" -ne 0 ]; then
55+
if echo "$output" | grep -qi "already exists"; then
56+
echo "$crate $version already exists on crates.io; skipping"
57+
continue
58+
fi
59+
echo "$output" >&2
60+
echo "ERROR: Failed to publish $crate" >&2
61+
exit 1
62+
fi
63+
fi
64+
done

crates/terraphim_config/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ path = "src/bin/main.rs"
1818
name = "terraphim-config"
1919

2020
[dependencies]
21-
terraphim_rolegraph = { version = "1.0.0", registry = "terraphim" }
22-
terraphim_types = { version = "1.0.0", registry = "terraphim" }
23-
terraphim_automata = { version = "1.19.2", registry = "terraphim", features = ["remote-loading"] }
24-
terraphim_persistence = { path = "../terraphim_persistence", version = "1.0.0", registry = "terraphim" }
25-
terraphim_settings = { path = "../terraphim_settings", version = "1.0.0", registry = "terraphim" }
21+
terraphim_rolegraph = { version = "1.0.0" }
22+
terraphim_types = { version = "1.0.0" }
23+
terraphim_automata = { version = "1.19.2", features = ["remote-loading"] }
24+
terraphim_persistence = { path = "../terraphim_persistence", version = "1.0.0" }
25+
terraphim_settings = { path = "../terraphim_settings", version = "1.0.0" }
2626

2727
opendal = { version = "0.54", features = [
2828
"services-dashmap",
@@ -71,4 +71,4 @@ openrouter = []
7171
tempfile = { workspace = true }
7272

7373
env_logger = "0.11"
74-
terraphim_test_utils = { version = "1.20.3", registry = "terraphim" }
74+
terraphim_test_utils = { version = "1.20.3" }

crates/terraphim_persistence/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ readme = "../../README.md"
1313

1414

1515
[dependencies]
16-
terraphim_settings = { path = "../terraphim_settings", version = "1.0.0", registry = "terraphim" }
17-
terraphim_types = { version = "1.0.0", registry = "terraphim" }
16+
terraphim_settings = { path = "../terraphim_settings", version = "1.0.0" }
17+
terraphim_types = { version = "1.0.0" }
1818

1919
tracing-subscriber = { version = "0.3", features = [
2020
"env-filter",

crates/terraphim_settings/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ thiserror = { workspace = true }
2020
twelf = { version = "0.15.0", features = ["json", "toml", "env", "clap"] }
2121
serde = { workspace = true, features = ["derive"] }
2222

23-
terraphim_onepassword_cli = { path = "../terraphim_onepassword_cli", version = "1.0.0", optional = true, registry = "terraphim" }
23+
terraphim_onepassword_cli = { path = "../terraphim_onepassword_cli", version = "1.0.0", optional = true }
2424
tokio = { workspace = true, features = ["rt"], optional = true }
2525

2626

0 commit comments

Comments
 (0)