Skip to content

Commit e206fd8

Browse files
author
boquanfu
committed
build: update publish script
1 parent 5bd9bae commit e206fd8

File tree

1 file changed

+60
-6
lines changed

1 file changed

+60
-6
lines changed

publish.sh

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,97 @@ PROJECTS=(
1111
float-pigment
1212
)
1313

14+
if [ "$1" == "" ]; then
15+
echo "Missing version. Usage: $0 [VERSION]"
16+
exit -1
17+
fi
18+
19+
VERSION="$1"
20+
21+
# run tests
22+
if cargo test; then
23+
echo 'Cargo test done.'
24+
else
25+
echo 'Cargo test failed! Abort.'
26+
exit -1
27+
fi
28+
29+
# update C++ headers
30+
if cargo run --bin float_pigment_cpp_binding_gen_tool; then
31+
echo 'float_pigment_cpp_binding_gen_tool done.'
32+
else
33+
echo 'float_pigment_cpp_binding_gen_tool failed! Abort.'
34+
exit -1
35+
fi
36+
37+
# run strict clippy
1438
if cargo clippy -- -D warnings; then
1539
echo 'Clippy check done.'
1640
else
1741
echo 'Clippy check failed! Abort.'
1842
exit -1
1943
fi
20-
21-
if cargo clippy --no-default-features; then
44+
if cargo clippy --no-default-features -- -D warnings; then
2245
echo 'Clippy check (no-default-features) done.'
2346
else
2447
echo 'Clippy check (no-default-features) failed! Abort.'
2548
exit -1
2649
fi
27-
28-
if cargo clippy --all-features; then
50+
if cargo clippy --all-features -- -D warnings; then
2951
echo 'Clippy check (all-features) done.'
3052
else
3153
echo 'Clippy check (all-features) failed! Abort.'
3254
exit -1
3355
fi
3456

57+
# run fmt (may change files and cause next git steps failed)
3558
if cargo fmt; then
3659
echo 'Cargo fmt done.'
3760
else
3861
echo 'Cargo fmt failed! Abort.'
3962
exit -1
4063
fi
4164

65+
# git operations
4266
if test -z '$(git status --porcelain)'; then
4367
echo 'Git status OK.'
68+
69+
# update version fields in cargo.toml
70+
if sed -i '' -E "s/version = \"[^\"]+\"/version = \"${VERSION}\"/" Cargo.toml; then
71+
echo 'Modified versions in Cargo.toml.'
72+
else
73+
echo 'Failed to modify version in Cargo.toml! Abort.'
74+
exit -1
75+
fi
76+
77+
# generate a new commit and tag it
78+
if git add Cargo.toml && git commit -m "chore: update version to publish"; then
79+
echo 'Generated a new version commit.'
80+
else
81+
echo 'Failed to commit! Abort.'
82+
exit -1
83+
fi
84+
if git tag "v${VERSION}"; then
85+
echo 'Git tag done.'
86+
else
87+
echo 'Git tag failed! Abort.'
88+
exit -1
89+
fi
90+
91+
# push to origin
92+
if git push && git push --tags; then
93+
echo 'Git tag pushed.'
94+
else
95+
echo 'Git tag push failed! Abort.'
96+
exit -1
97+
fi
4498
else
4599
echo 'Git working tree is not clean! Abort.'
46100
exit -1
47101
fi
48102

49-
echo 'Ready to publish.'
50-
103+
# cargo publish
104+
echo "Ready to publish version ${VERSION}."
51105
for PROJECT in "${PROJECTS[@]}"; do
52106
echo ""
53107
echo "Publishing ${PROJECT}..."

0 commit comments

Comments
 (0)