Skip to content

Commit f563cf6

Browse files
committed
fix(ci): strip Gitea registry refs before crates.io publish
crates.io rejects manifests whose dependencies pin a non-default registry. terraphim_service et al. are mirrored on the Gitea registry for dev builds; the publish step now strips the registry = "terraphim" key (and matching [patch.crates-io] entries) at publish time, automating the manual strip that was previously done per-release.
1 parent 56ca2b0 commit f563cf6

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

.github/workflows/publish-crates.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,36 @@ jobs:
2525
- uses: actions/checkout@v4
2626
- uses: dtolnay/rust-toolchain@stable
2727
- uses: Swatinem/rust-cache@v2
28+
- name: Strip private-registry refs for crates.io publish
29+
run: |
30+
python3 - <<'PY'
31+
import re, pathlib
32+
# The Gitea `terraphim` registry mirrors crates.io for these deps.
33+
# crates.io rejects manifests whose deps pin a non-default registry,
34+
# so drop the `registry = "terraphim"` key everywhere and remove any
35+
# [patch.crates-io] entry that pins to it (a patch needs a source).
36+
root = pathlib.Path('Cargo.toml')
37+
lines = root.read_text().splitlines()
38+
out, inp = [], False
39+
for ln in lines:
40+
if ln.strip() == '[patch.crates-io]':
41+
inp = True; out.append(ln); continue
42+
if ln.startswith('['):
43+
inp = False
44+
if inp and 'registry = "terraphim"' in ln:
45+
continue
46+
out.append(ln)
47+
root.write_text("\n".join(out) + "\n")
48+
for f in pathlib.Path('.').rglob('Cargo.toml'):
49+
s = f.read_text()
50+
s = re.sub(r',\s*registry = "terraphim"', '', s)
51+
s = re.sub(r'registry = "terraphim",\s*', '', s)
52+
f.write_text(s)
53+
leftover = [str(p) for p in pathlib.Path('.').rglob('Cargo.toml')
54+
if 'registry = "terraphim"' in p.read_text()]
55+
assert not leftover, f"registry refs remain: {leftover}"
56+
print("Stripped terraphim-registry refs")
57+
PY
2858
- name: Publish crates in dependency order
2959
env:
3060
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

0 commit comments

Comments
 (0)