From 2a5b5a6d49bb9725d68950ce35a90b7baf190534 Mon Sep 17 00:00:00 2001 From: azzamsa Date: Tue, 30 Nov 2021 08:40:05 +0700 Subject: [PATCH] build: fails the release script if untracked files exists --- scripts/release.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/release.sh b/scripts/release.sh index 8a2703b..6f41f96 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -1,10 +1,20 @@ #!/usr/bin/env bash # inspired from git-cliff + +untracked_files=$(git ls-files . --exclude-standard --others) + +# check for untracked files +if [ -n "$untracked_files" ]; then + echo "warn: Please stash or remove the untracked files" + exit 1 +fi + + # takes the tag as an argument (e.g. v0.1.0) if [ -n "$1" ]; then # update the version - sed "0,/^version = .*$/s//version = \"${1#v}\"/" -i Cargo.toml + sed "0,/^version = .*$/s//version = \"${1#v}\"/" -i Cargo.toml # update the changelog git-cliff --tag "$1" > CHANGELOG.md git add -A && git commit -m "$1" @@ -13,4 +23,5 @@ if [ -n "$1" ]; then git tag -v "$1" else echo "warn: Please provide a tag" + exit 1 fi