File: tag_release.sh

package info (click to toggle)
rust-capstone 0.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 824 kB
  • sloc: sh: 341; ansic: 6; makefile: 2
file content (48 lines) | stat: -rwxr-xr-x 986 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
#
# Tag the HEAD based on version in Cargo.toml

set -eu

cd "$(dirname $0)/.."

Error() {
    echo "Error:" "$@" >&2
    exit 1
}

extract_toml_value() {
    grep "^$1" Cargo.toml | sed 's/^[^ =].*=.*"\([^"]\+\)"$/\1/' | head -n1
}

git diff --exit-code HEAD || Error "Uncommitted changes"

PACKAGE_NAME="$(extract_toml_value name)"
PACKAGE_VERSION="${PACKAGE_VERSION:-$(extract_toml_value version)}"
DESCRIPTION="${PACKAGE_NAME} v${PACKAGE_VERSION}"
TAG_NAME="${PACKAGE_NAME}-v${PACKAGE_VERSION}"
GIT_COMMIT="${GIT_COMMIT:-$(git rev-parse HEAD)}"

echo "Commit log:"
git log -1 $GIT_COMMIT | cat

echo
echo -n "Create git tag: TAG_NAME=\"$TAG_NAME\" DESCRIPTION=\"$DESCRIPTION\" at $GIT_COMMIT? (y/N) "

read -r answer
case "$answer" in
    y|Y) ;;
    *)
        echo "Exiting"
        exit 1
        ;;
esac

set -x
git tag -s -m "${DESCRIPTION}" "${TAG_NAME}" "${GIT_COMMIT}"
set +x

echo
echo "Don't forget to push tags upstream:"
echo
echo "    git push origin --tags"