mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 08:41:34 +11:00
Try to make release dry run a bit simpler
This commit is contained in:
parent
7429219a4b
commit
1f04470cf5
24
release.sh
24
release.sh
|
@ -24,8 +24,16 @@ if [ ! "$NO_COMMIT" = "" ] && [ ! "$NO_COMMIT" = "--no-commit" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
function maybe_git() {
|
||||||
|
if [ "$NO_COMMIT" = "--no-commit" ]; then
|
||||||
|
echo "Would run: git $*"
|
||||||
|
else
|
||||||
|
git "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Check that no out-standing changes in git
|
# Check that no out-standing changes in git
|
||||||
if [ -n "$(git status --porcelain)" ]; then
|
if [ ! "$NO_COMMIT" = "" ] && [ -n "$(git status --porcelain)" ]; then
|
||||||
echo "Uncommitted changes, please commit first"
|
echo "Uncommitted changes, please commit first"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -46,18 +54,18 @@ for PROJECT_TOML_FILE in agb/Cargo.toml agb-*/Cargo.toml; do
|
||||||
|
|
||||||
# Also update the lock file
|
# Also update the lock file
|
||||||
(cd "$DIRECTORY" && cargo update)
|
(cd "$DIRECTORY" && cargo update)
|
||||||
git add "$DIRECTORY/Cargo.toml" "$DIRECTORY/Cargo.lock" || echo "Failed to git add a file, continuing anyway"
|
maybe_git add "$DIRECTORY/Cargo.toml" "$DIRECTORY/Cargo.lock" || echo "Failed to git add a file, continuing anyway"
|
||||||
|
|
||||||
if [ "$DIRECTORY" = "agb" ]; then
|
if [ "$DIRECTORY" = "agb" ]; then
|
||||||
# also update the agb version in the template and the examples
|
# also update the agb version in the template and the examples
|
||||||
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
|
maybe_git add template/Cargo.toml
|
||||||
|
|
||||||
for EXAMPLE_TOML_FILE in examples/*/Cargo.toml book/games/*/Cargo.toml; do
|
for EXAMPLE_TOML_FILE in examples/*/Cargo.toml book/games/*/Cargo.toml; do
|
||||||
EXAMPLE_DIR=$(dirname "$EXAMPLE_TOML_FILE")
|
EXAMPLE_DIR=$(dirname "$EXAMPLE_TOML_FILE")
|
||||||
sed -E -i -e "/agb =/ s/version = \"[^\"]+\"/version = \"$VERSION\"/" "$EXAMPLE_DIR/Cargo.toml"
|
sed -E -i -e "/agb =/ s/version = \"[^\"]+\"/version = \"$VERSION\"/" "$EXAMPLE_DIR/Cargo.toml"
|
||||||
(cd "$EXAMPLE_DIR" && cargo update)
|
(cd "$EXAMPLE_DIR" && cargo update)
|
||||||
git add "$EXAMPLE_DIR"/{Cargo.toml,Cargo.lock} || echo "Failed to git add a file, continuing anyway"
|
maybe_git add "$EXAMPLE_DIR"/{Cargo.toml,Cargo.lock} || echo "Failed to git add a file, continuing anyway"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
PROJECT_NAME_WITH_UNDERSCORES=$(echo -n "$DIRECTORY" | tr - _)
|
PROJECT_NAME_WITH_UNDERSCORES=$(echo -n "$DIRECTORY" | tr - _)
|
||||||
|
@ -66,7 +74,7 @@ for PROJECT_TOML_FILE in agb/Cargo.toml agb-*/Cargo.toml; do
|
||||||
sed -i -E -e "s/($PROJECT_NAME_WITH_UNDERSCORES = .*version = \")[^\"]+(\".*)/\1$VERSION\2/" "$CARGO_TOML_FILE"
|
sed -i -E -e "s/($PROJECT_NAME_WITH_UNDERSCORES = .*version = \")[^\"]+(\".*)/\1$VERSION\2/" "$CARGO_TOML_FILE"
|
||||||
(cd "$(dirname "$CARGO_TOML_FILE")" && cargo generate-lockfile)
|
(cd "$(dirname "$CARGO_TOML_FILE")" && cargo generate-lockfile)
|
||||||
|
|
||||||
git add "$CARGO_TOML_FILE" "${CARGO_TOML_FILE/.toml/.lock}" || echo "Failed to git add a file, continuing anyway"
|
maybe_git add "$CARGO_TOML_FILE" "${CARGO_TOML_FILE/.toml/.lock}" || echo "Failed to git add a file, continuing anyway"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -81,13 +89,11 @@ for EXAMPLE_TOML_FILE in examples/*/Cargo.toml book/games/*/Cargo.toml; do
|
||||||
(cd "$EXAMPLE_DIR" && cargo check --release)
|
(cd "$EXAMPLE_DIR" && cargo check --release)
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ! "$NO_COMMIT" = "--no-commit" ]; then
|
|
||||||
# Commit the Cargo.toml changes
|
# Commit the Cargo.toml changes
|
||||||
git commit -m "Release v$VERSION"
|
maybe_git commit -m "Release v$VERSION"
|
||||||
|
|
||||||
# Tag the version
|
# Tag the version
|
||||||
git tag -a "$TAGNAME" -m "v$VERSION"
|
maybe_git tag -a "$TAGNAME" -m "v$VERSION"
|
||||||
|
|
||||||
echo "Done! Push with"
|
echo "Done! Push with"
|
||||||
echo "git push --atomic origin master $TAGNAME"
|
echo "git push --atomic origin master $TAGNAME"
|
||||||
fi
|
|
Loading…
Reference in a new issue