Skip to content

Commit 599000e

Browse files
tomasolclaude
andcommitted
chore: add workflow to publish obeli-sk fork to crates.io
Adds a `workflow_dispatch` GitHub Actions workflow that: - renames all publishable crate package names to the `obeli-sk-` prefix - sets the workspace version to the supplied version input - publishes via `cargo publish --workspace` (topological order, skips `publish = false` crates — guaranteed by rust-version = "1.91.0") Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f075094 commit 599000e

2 files changed

Lines changed: 181 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Publish obeli-sk fork to crates.io
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: >
8+
Version to publish, e.g. `1.0.0-obeli-sk.1`.
9+
Must be unique on crates.io — bump the trailing number for re-publishes.
10+
required: true
11+
type: string
12+
dry_run:
13+
description: Dry run — package but do not upload to crates.io
14+
required: false
15+
type: boolean
16+
default: false
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
publish:
23+
name: Publish crates
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 60
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
30+
31+
- name: Install Rust toolchain
32+
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
33+
34+
- name: Cache Cargo registry
35+
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
36+
with:
37+
cache-on-failure: true
38+
39+
- name: Rename crates and set version
40+
run: python3 scripts/rename_for_obeli_sk.py "${{ inputs.version }}"
41+
42+
- name: Verify rename output
43+
run: |
44+
echo "=== Workspace version ==="
45+
grep '^version' Cargo.toml | head -3
46+
echo "=== Sample workspace dep (boa_engine) ==="
47+
grep 'boa_engine' Cargo.toml | head -5
48+
echo "=== Sample package name (core/engine) ==="
49+
grep '^name' core/engine/Cargo.toml | head -2
50+
51+
# --no-verify skips a local test-build from the registry, avoiding the
52+
# chicken-and-egg problem when a freshly uploaded crate isn't yet indexed.
53+
# cargo publish --workspace resolves topological order automatically and
54+
# skips publish=false crates (behavior stabilized in Cargo 1.90; boa's
55+
# rust-version = "1.91.0" guarantees this).
56+
- name: Publish crates
57+
env:
58+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
59+
run: |
60+
FLAGS="--no-verify --allow-dirty"
61+
if [ "${{ inputs.dry_run }}" = "true" ]; then
62+
FLAGS="$FLAGS --dry-run"
63+
echo "DRY RUN — crates will not actually be uploaded."
64+
fi
65+
# shellcheck disable=SC2086
66+
cargo publish --workspace $FLAGS

scripts/rename_for_obeli_sk.py

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Renames boa crate package names to the `obeli-sk-` prefix and sets the workspace
4+
version, so they can be published to crates.io without conflicting with upstream.
5+
6+
Usage: python3 scripts/rename_for_obeli_sk.py <version>
7+
Example: python3 scripts/rename_for_obeli_sk.py 1.0.0-obeli-sk.1
8+
"""
9+
10+
import re
11+
import sys
12+
from pathlib import Path
13+
14+
if len(sys.argv) != 2:
15+
print(f"Usage: {sys.argv[0]} <version>", file=sys.stderr)
16+
sys.exit(1)
17+
18+
version = sys.argv[1]
19+
20+
# Map: original package name -> published crate name (hyphens for crates.io)
21+
RENAMES = {
22+
"boa_ast": "obeli-sk-boa-ast",
23+
"boa_engine": "obeli-sk-boa-engine",
24+
"boa_gc": "obeli-sk-boa-gc",
25+
"boa_icu_provider": "obeli-sk-boa-icu-provider",
26+
"boa_interner": "obeli-sk-boa-interner",
27+
"boa_macros": "obeli-sk-boa-macros",
28+
"boa_parser": "obeli-sk-boa-parser",
29+
"boa_runtime": "obeli-sk-boa-runtime",
30+
"boa_string": "obeli-sk-boa-string",
31+
"boa_wintertc": "obeli-sk-boa-wintertc",
32+
"small_btree": "obeli-sk-small-btree",
33+
"tag_ptr": "obeli-sk-tag-ptr",
34+
}
35+
36+
# Map: original package name -> path relative to repo root
37+
CRATE_PATHS = {
38+
"boa_ast": "core/ast",
39+
"boa_engine": "core/engine",
40+
"boa_gc": "core/gc",
41+
"boa_icu_provider": "core/icu_provider",
42+
"boa_interner": "core/interner",
43+
"boa_macros": "core/macros",
44+
"boa_parser": "core/parser",
45+
"boa_runtime": "core/runtime",
46+
"boa_string": "core/string",
47+
"boa_wintertc": "core/wintertc",
48+
"small_btree": "utils/small_btree",
49+
"tag_ptr": "utils/tag_ptr",
50+
}
51+
52+
root = Path(__file__).parent.parent
53+
54+
# ── 1. Update workspace Cargo.toml ──────────────────────────────────────────
55+
56+
root_cargo = root / "Cargo.toml"
57+
content = root_cargo.read_text()
58+
59+
# Update [workspace.package] version
60+
content = re.sub(
61+
r'^(version\s*=\s*)"[^"]+"',
62+
rf'\1"{version}"',
63+
content,
64+
flags=re.MULTILINE,
65+
)
66+
67+
# For each renamed crate, update its entry in [workspace.dependencies]:
68+
# Before: boa_ast = { version = "~1.0.0-dev", path = "core/ast" }
69+
# After: boa_ast = { package = "obeli-sk-boa-ast", version = "1.0.0-obeli-sk.1", path = "core/ast" }
70+
#
71+
# The workspace-dep key stays as the original name so that `boa_ast.workspace = true`
72+
# in individual crates continues to work; `package` tells cargo the real crate name.
73+
74+
for old_name, new_name in RENAMES.items():
75+
# Match an inline-table workspace dependency line for this crate.
76+
pattern = rf'^({re.escape(old_name)}\s*=\s*\{{)([^\n\}}]+)(\}})'
77+
78+
def make_replacer(new_name=new_name):
79+
def replacer(m):
80+
prefix, body, suffix = m.group(1), m.group(2), m.group(3)
81+
# Insert `package` if not already present
82+
if "package" not in body:
83+
body = f' package = "{new_name}",' + body
84+
# Replace the version constraint
85+
body = re.sub(r'version\s*=\s*"[^"]*"', f'version = "{version}"', body)
86+
return prefix + body + suffix
87+
return replacer
88+
89+
content = re.sub(pattern, make_replacer(), content, flags=re.MULTILINE)
90+
91+
root_cargo.write_text(content)
92+
print(f"Updated {root_cargo}")
93+
94+
# ── 2. Rename [package] name in each individual crate ────────────────────────
95+
96+
for old_name, new_name in RENAMES.items():
97+
cargo_toml = root / CRATE_PATHS[old_name] / "Cargo.toml"
98+
if not cargo_toml.exists():
99+
print(f"WARNING: {cargo_toml} not found, skipping")
100+
continue
101+
102+
content = cargo_toml.read_text()
103+
updated = re.sub(
104+
rf'^(name\s*=\s*)"({re.escape(old_name)})"',
105+
rf'\1"{new_name}"',
106+
content,
107+
flags=re.MULTILINE,
108+
)
109+
if updated == content:
110+
print(f"WARNING: no name replacement made in {cargo_toml}")
111+
else:
112+
cargo_toml.write_text(updated)
113+
print(f" {old_name!s:30s} -> {new_name}")
114+
115+
print(f"\nDone. Version set to {version!r}.")

0 commit comments

Comments
 (0)