mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-26 09:06:33 +11:00
Merge pull request #107 from gwilymk/update-agb-when-releasing
Update agb when releasing
This commit is contained in:
commit
500f271182
1 changed files with 29 additions and 13 deletions
42
release.sh
42
release.sh
|
@ -5,10 +5,11 @@ set -e
|
||||||
|
|
||||||
PROJECT=$1
|
PROJECT=$1
|
||||||
VERSION=$2
|
VERSION=$2
|
||||||
|
NO_COMMIT=$3
|
||||||
|
|
||||||
# Sanity check that we actually have a version
|
# Sanity check that we actually have a version
|
||||||
if [ "$VERSION" = "" ]; then
|
if [ "$VERSION" = "" ]; then
|
||||||
echo "Usage $0 <project> <version>"
|
echo "Usage $0 <project> <version> [--no-commit]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -18,6 +19,12 @@ if [ ! "$(echo "$VERSION" | grep -E "^[0-9]+\.[0-9]+\.[0-9]+$")" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if no commit option is valid
|
||||||
|
if [ ! "$NO_COMMIT" = "" ] && [ ! "$NO_COMMIT" = "--no-commit" ]; then
|
||||||
|
echo "Must pass either no last argument or --no-commit"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Set up $DIRECTORY and $TAGNAME
|
# Set up $DIRECTORY and $TAGNAME
|
||||||
case "$PROJECT" in
|
case "$PROJECT" in
|
||||||
agb)
|
agb)
|
||||||
|
@ -49,16 +56,12 @@ if [ ! -z "$(git status --porcelain)" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check that we are in the master branch
|
# Check that we are in the master branch, but only if actually committing
|
||||||
if [ "$(git symbolic-ref --short HEAD)" != "master" ]; then
|
if [ ! "$NO_COMMIT" = "--no-commit" ] && [ "$(git symbolic-ref --short HEAD)" != "master" ]; then
|
||||||
echo "You must be in the master branch before releasing"
|
echo "You must be in the master branch before releasing"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Sanity check to make sure the build works
|
|
||||||
(cd agb && cargo test)
|
|
||||||
(cd agb-image-converter && cargo test)
|
|
||||||
|
|
||||||
# Update the version in Cargo.toml
|
# Update the version in Cargo.toml
|
||||||
sed -i -e "s/^version = \".*\"/version = \"$VERSION\"/" "$DIRECTORY/Cargo.toml"
|
sed -i -e "s/^version = \".*\"/version = \"$VERSION\"/" "$DIRECTORY/Cargo.toml"
|
||||||
|
|
||||||
|
@ -70,13 +73,26 @@ if [ "$PROJECT" = "agb" ]; then
|
||||||
# also update the agb version in the template
|
# also update the agb version in the template
|
||||||
sed -i -e "s/^agb = \".*\"/agb = \"$VERSION\"/" template/Cargo.toml
|
sed -i -e "s/^agb = \".*\"/agb = \"$VERSION\"/" template/Cargo.toml
|
||||||
git add template/Cargo.toml
|
git add template/Cargo.toml
|
||||||
|
else
|
||||||
|
PROJECT_NAME_WITH_UNDERSCORES=$(echo -n "$PROJECT" | tr - _)
|
||||||
|
sed -i -E -e "s/($PROJECT_NAME_WITH_UNDERSCORES = .*version = \")[^\"]+(\".*)/\1$VERSION\2/" agb/Cargo.toml
|
||||||
|
|
||||||
|
(cd agb && cargo update)
|
||||||
|
git add agb/Cargo.toml agb/Cargo.lock
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Commit the Cargo.toml changes
|
# Sanity check to make sure the build works
|
||||||
git commit -m "Release $PROJECT v$VERSION"
|
(cd agb && cargo test)
|
||||||
|
(cd agb-image-converter && cargo test)
|
||||||
|
(cd agb-macros && cargo test)
|
||||||
|
|
||||||
# Tag the version
|
if [ ! "$NO_COMMIT" = "--no-commit" ]; then
|
||||||
git tag -a $TAGNAME -m "$PROJECT - v$VERSION"
|
# Commit the Cargo.toml changes
|
||||||
|
git commit -m "Release $PROJECT v$VERSION"
|
||||||
|
|
||||||
echo "Done! Push with"
|
# Tag the version
|
||||||
echo "git push --atomic origin master $TAGNAME"
|
git tag -a $TAGNAME -m "$PROJECT - v$VERSION"
|
||||||
|
|
||||||
|
echo "Done! Push with"
|
||||||
|
echo "git push --atomic origin master $TAGNAME"
|
||||||
|
fi
|
Loading…
Add table
Reference in a new issue