Skip to content

Commit

Permalink
Update version scripts (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellismg authored and pgavlin committed Nov 21, 2018
1 parent 9638168 commit e59152a
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 17 deletions.
61 changes: 56 additions & 5 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
@@ -1,3 +1,3 @@
[[constraint]]
name = "github.com/pulumi/pulumi"
version = "v0.15.0"
branch = "master"
1 change: 1 addition & 0 deletions nodejs/eks/examples/examples_test.go
Expand Up @@ -45,6 +45,7 @@ func Test_Examples(t *testing.T) {
Dependencies: []string{
"@pulumi/eks",
},
ExpectRefreshChanges: true,
},
}
for _, ex := range examples {
Expand Down
45 changes: 34 additions & 11 deletions scripts/get-version
Expand Up @@ -9,20 +9,43 @@ DIRTY_TAG=""
# treat the worktree as dirty when it is not.
git update-index -q --refresh
if ! git diff-files --quiet; then
DIRTY_TAG="-dirty"
DIRTY_TAG="dirty"
fi

# If we have an exact tag, and it is not a -dev tag, just use it.
# If we have an exact tag, just use it.
if git describe --tags --exact-match "${COMMITISH}" >/dev/null 2>&1; then
TAG="$(git describe --tags --exact-match "${COMMITISH}")"
if [[ ! "${TAG}" =~ -dev$ ]]; then
echo "$(git describe --tags --exact-match "${COMMITISH}")${DIRTY_TAG}"
exit 0
echo -n "$(git describe --tags --exact-match "${COMMITISH}")"
if [ ! -z "${DIRTY_TAG}" ]; then
echo -n "+${DIRTY_TAG}"
fi

echo ""
exit 0
fi

# Otherwise, increment the patch version, add the -dev 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
TAG=$(git describe --tags --abbrev=0 "${COMMITISH}")
else
TAG="v0.0.0"
fi

# Strip off any pre-release tag we might have (e.g. from doing a -rc build)
TAG=${TAG%%-*}

MAJOR=$(cut -d. -f1 <<< "${TAG}")
MINOR=$(cut -d. -f2 <<< "${TAG}")
PATCH=$(cut -d. -f3 <<< "${TAG}")

# 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})"
if [ ! -z "${DIRTY_TAG}" ]; then
echo -n ".${DIRTY_TAG}"
fi

# Otherwise 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 "$(git describe --tags --abbrev=0 ${COMMITISH})-$(git show -s --format='%ct-g%h' ${COMMITISH})${DIRTY_TAG}"
echo ""

0 comments on commit e59152a

Please sign in to comment.