Skip to content

Commit

Permalink
Add scripts for managing release process
Browse files Browse the repository at this point in the history
These are very minorly adapted from the scripts in fontations.
  • Loading branch information
cmyr committed May 21, 2024
1 parent e0b1cb4 commit 7efe6d2
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
35 changes: 35 additions & 0 deletions resources/scripts/bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# See usage() for usage

source "$(dirname -- "$0";)/rel-common.sh"

# Helpers
function usage() {
echo "Usage: ./bump-version.sh crate1 crate2 crateN bump"
echo " ./bump-version.sh fontbe fontc patch"
echo "bump is as defined by cargo release: major minor or patch"
}

# What is it you want us to do?
if [ $# -eq 0 ]; then
die_with_usage "No arguments provided, must specify crate(s)"
fi

# bump is the last argument, crate list is everythign else
bump="${@:$#}"
set -- "${@:1:$(($#-1))}"
crates=("$@")

# Validate
[[ "$bump" =~ ^(major|minor|patch)$ ]] || die_with_usage "Invalid bump, must be major, minor, or patch"

validate_crates "${crates[@]}"

# Do the thing. We set errexit so step failure should break us out.
for crate in "${crates[@]}"
do
cargo release version "${bump}" -p "${crate}" -x
done

echo "NEXT STEPS"
echo "Commit these changes to a new branch, get it approved and merged, and switch to the up-to-date main."
19 changes: 19 additions & 0 deletions resources/scripts/rel-common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set -o nounset
set -o errexit

# Colors courtesy of https://stackoverflow.com/a/20983251
TEXT_RESET=$(tput sgr0)
COLOR_RED=$(tput setaf 1)

function die_with_usage() {
>&2 echo "${COLOR_RED}${1}${TEXT_RESET}"
usage
exit 1
}

function validate_crates() {
for crate in "$@"
do
[ -d "$crate" ]|| die_with_usage "Invalid crate: ${crate}"
done
}
44 changes: 44 additions & 0 deletions resources/scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
# See usage() for usage

source "$(dirname -- "$0";)/rel-common.sh"

# Helpers
function usage() {
echo "Usage:"
echo " # release everything changed"
echo " ./release.sh"
echo
echo " # release one crate"
echo " ./release.sh fontc"
echo
echo "Typically you should be running this after bump-version.sh"
}

# What is it you want us to do?
if [ $# -gt 1 ]; then
die_with_usage "Specify 0 - meaning all - or 1 packages"
fi
crate_specifier=""
if [ $# -eq 1 ]; then
crates=("$@")
validate_crates "${crates[@]}"
crate_specifier="-p ${crates[0]}"
fi

# Do the thing. We set errexit so step failure should break us out.

echo "Dry run..."
cargo release publish ${crate_specifier}

echo "Doing the thing; ${COLOR_RED}PRESS CTRL+C if anything looks suspicious${TEXT_RESET}"

echo "Publish to crates.io"
cargo release publish -x ${crate_specifier} # this prompts y/N
echo "Generate tags"
cargo release tag -x ${crate_specifier} # this prompts y/N
echo "Pushing tag to github"
git push --tags

echo "NEXT STEPS"
echo "You probably want to create a release on github"

0 comments on commit 7efe6d2

Please sign in to comment.