Skip to content

Commit

Permalink
Merge pull request #599 from phaazon/release/next
Browse files Browse the repository at this point in the history
Update rollout script.
  • Loading branch information
hadronized committed Apr 13, 2022
2 parents 9d5f0ae + 8bb14a5 commit acb9e23
Showing 1 changed file with 39 additions and 24 deletions.
63 changes: 39 additions & 24 deletions scripts/rollout
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,61 @@ crates=(
luminance-front
)

function publish_crate() {
read "go?Publish $1 to crates.io? (Y/n) "
go=${go:-"Y"}
(test $go = "Y" && cd $1 && cargo package && cargo publish)
function auto_publish_crate() {
echo "Publishing $1 to creates.io…"

ret=1
try=1
while [ $ret != 0 ]
do
echo " try $try"
(cd $1 && cargo publish)
ret=$?

if [ $ret != 0 ]
then
try=$(($try + 1))
sleep 5
else
break
fi
done
}

function get_crate_version() {
cargo read-manifest --manifest-path $1/Cargo.toml | jq -r ".version" | sed s/\.0$//
}

function create_git_tag() {
function auto_create_git_tag() {
echo "Current tags for $1:"
git tag | rg ^$1-\\d
read "go?Create tag $1-$2? (Y/n) "
go=${go:-"Y"}
(test $go = "Y" && git tag $1-$2 && echo -e " created git tag $1-\e[034;3m$2\e[0;0m")
echo "Creating tag $1-$2?"
(git tag $1-$2 && echo -e " created git tag $1-\e[034;3m$2\e[0;0m")
}

function push_git_tags() {
read "go?Push tags? (Y/n) "
go=${go:-"Y"}
(test $go = "Y" && git push origin --tags)
function auto_push_git_tags() {
echo "Pushing tags"
git push origin --tags
}

case "$*" in
"all")
# Perform a full roll out of all the crates, respecting the order in which they should be published.
for crate in ${crates[@]}; do
version=$(get_crate_version $crate)
echo -e "\e[032;1mRolling out \e[039;0m$crate-\e[034;3m$version\e[0;0m"
function rollout() {
for crate in $*; do
version=$(get_crate_version $crate)
echo -e "\e[032;1mRolling out \e[039;0m$crate-\e[034;3m$version\e[0;0m"

publish_crate $crate
create_git_tag $crate $version
done
auto_publish_crate $crate
auto_create_git_tag $crate $version
done

push_git_tags
auto_push_git_tags
}

case "$*" in
"auto")
rollout ${crates[@]}
;;

*)
echo "unknown argument"
exit 1
rollout $*
;;
esac

0 comments on commit acb9e23

Please sign in to comment.