Skip to content

Commit

Permalink
Sync scripts/get-version with pulumi/pulumi
Browse files Browse the repository at this point in the history
  • Loading branch information
ellismg committed Sep 13, 2019
1 parent b80736c commit 6e0099c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions scripts/get-version
Expand Up @@ -23,7 +23,8 @@ if git describe --tags --exact-match "${COMMITISH}" >/dev/null 2>&1; then
exit 0
fi

# Otherwise, increment the patch version, add the -dev tag and some
# Otherwise, increment the minor version version (if the package is 1.X or later) or the
# patch version (if the package is pre 1.0), add the -alpha tag and some
# commit metadata. If there's no existing tag, pretend a v0.0.0 was
# there so we'll produce v0.0.1-dev builds.
if git describe --tags --abbrev=0 "${COMMITISH}" > /dev/null 2>&1; then
Expand All @@ -39,11 +40,18 @@ MAJOR=$(cut -d. -f1 <<< "${TAG}")
MINOR=$(cut -d. -f2 <<< "${TAG}")
PATCH=$(cut -d. -f3 <<< "${TAG}")

if [ "${MAJOR}" = "v0" ]; then
PATCH=$((${PATCH}+1))
else
MINOR=$((${MINOR}+1))
PATCH=0
fi

# We want to include some additional information. To the base tag we
# add a timestamp and commit hash. We use the timestamp of the commit
# itself, not the date it was authored (so it will change when someone
# rebases a PR into master, for example).
echo -n "${MAJOR}.${MINOR}.$((${PATCH}+1))-dev.$(git show -s --format='%ct+g%h' ${COMMITISH})"
echo -n "${MAJOR}.${MINOR}.${PATCH}-alpha.$(git show -s --format='%ct+g%h' ${COMMITISH})"
if [ ! -z "${DIRTY_TAG}" ]; then
echo -n ".${DIRTY_TAG}"
fi
Expand Down

0 comments on commit 6e0099c

Please sign in to comment.