-
Notifications
You must be signed in to change notification settings - Fork 10
120 lines (100 loc) · 4.37 KB
/
publish.yml
File metadata and controls
120 lines (100 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Publish
on:
release:
types: [published]
workflow_dispatch:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
# Publish bashkit (core library) to crates.io
publish-bashkit:
name: Publish bashkit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Verify version matches tag
run: |
# Get tag from release event or skip check for workflow_dispatch
TAG_VERSION="${{ github.event.release.tag_name }}"
if [ -n "$TAG_VERSION" ]; then
TAG_VERSION="${TAG_VERSION#v}" # Remove 'v' prefix
CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
echo "Error: Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
exit 1
fi
echo "Version verified: $TAG_VERSION"
else
echo "Manual dispatch - skipping tag verification"
fi
- name: Strip git-only dependencies for publishing
# monty is a git dep (not yet on crates.io) — remove before publish.
# Must strip from ALL workspace crates because cargo resolves the
# whole workspace when publishing a single crate.
run: |
# --- bashkit core: remove monty dep and python feature ---
TOML=crates/bashkit/Cargo.toml
sed -i '/^monty = .*/d' "$TOML"
sed -i '/^python = \["dep:monty"\]/d' "$TOML"
sed -i '/^\[\[example\]\]/{N;N;/python_scripts/d}' "$TOML"
sed -i '/^\[\[example\]\]/{N;N;/python_external_functions/d}' "$TOML"
# --- bashkit-cli: remove python feature ---
CLI_TOML=crates/bashkit-cli/Cargo.toml
sed -i '/^python = \["bashkit\/python"\]/d' "$CLI_TOML"
sed -i 's/, "python"//; s/"python", //; s/\["python"\]/[]/' "$CLI_TOML"
# --- bashkit-js: remove python from features list ---
JS_TOML=crates/bashkit-js/Cargo.toml
sed -i 's/, "python"//; s/"python", //' "$JS_TOML"
# --- bashkit-python: remove python from features list ---
PY_TOML=crates/bashkit-python/Cargo.toml
sed -i 's/, "python"//; s/"python", //' "$PY_TOML"
echo "=== Verify no python feature references remain ==="
grep -rn '"python"' crates/*/Cargo.toml || echo "Clean — no python feature refs"
- name: Publish bashkit to crates.io
run: cargo publish -p bashkit --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# Publish bashkit-cli (depends on bashkit)
publish-bashkit-cli:
name: Publish bashkit-cli
runs-on: ubuntu-latest
needs: publish-bashkit
steps:
- uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Wait for crates.io index update
run: sleep 30
- name: Strip python feature from bashkit-cli
# python feature is stripped from bashkit during publish (monty is git-only)
run: |
TOML=crates/bashkit-cli/Cargo.toml
# Remove python feature and default that references it
sed -i '/^python = \["bashkit\/python"\]/d' "$TOML"
sed -i 's/, "python"//; s/"python", //; s/\["python"\]/[]/' "$TOML"
echo "--- bashkit-cli Cargo.toml after stripping ---"
cat "$TOML"
- name: Publish bashkit-cli to crates.io
run: cargo publish -p bashkit-cli --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# ============================================================================
# Verify all packages were published successfully
# ============================================================================
verify-publish:
name: Verify published versions
runs-on: ubuntu-latest
needs: [publish-bashkit, publish-bashkit-cli]
steps:
- uses: actions/checkout@v6
- name: Wait for crates.io propagation
run: sleep 60
- name: Verify crates.io versions
run: |
EXPECTED=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
echo "Expected version: $EXPECTED"
python3 scripts/verify_crates_publish.py --expected "$EXPECTED" bashkit bashkit-cli