@@ -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
1438if cargo clippy -- -D warnings; then
1539 echo ' Clippy check done.'
1640else
1741 echo ' Clippy check failed! Abort.'
1842 exit -1
1943fi
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.'
2346else
2447 echo ' Clippy check (no-default-features) failed! Abort.'
2548 exit -1
2649fi
27-
28- if cargo clippy --all-features; then
50+ if cargo clippy --all-features -- -D warnings; then
2951 echo ' Clippy check (all-features) done.'
3052else
3153 echo ' Clippy check (all-features) failed! Abort.'
3254 exit -1
3355fi
3456
57+ # run fmt (may change files and cause next git steps failed)
3558if cargo fmt; then
3659 echo ' Cargo fmt done.'
3760else
3861 echo ' Cargo fmt failed! Abort.'
3962 exit -1
4063fi
4164
65+ # git operations
4266if 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
4498else
4599 echo ' Git working tree is not clean! Abort.'
46100 exit -1
47101fi
48102
49- echo ' Ready to publish. '
50-
103+ # cargo publish
104+ echo " Ready to publish version ${VERSION} . "
51105for PROJECT in " ${PROJECTS[@]} " ; do
52106 echo " "
53107 echo " Publishing ${PROJECT} ..."
0 commit comments