Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consolidate version logic #490

Merged
merged 2 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions scripts/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -eou pipefail

version=`git fetch --tags &>/dev/null | git tag -l | sort --version-sort | tail -n1 | cut -c 2-`

branch=`git rev-parse --abbrev-ref HEAD`
if [[ $branch != 'master' ]]; then
version=${version}-${branch}
fi

num_changes=`git status --porcelain | wc -l`
if [[ $num_changes -ne 0 ]]; then
commit=`git rev-parse --short HEAD`
version=${version}-${commit}
fi

echo $version
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: doctl
version-script: git fetch --tags &>/dev/null | git tag -l | sort --version-sort | tail -n1 | cut -c 2-
version-script: scripts/version.sh
version: git
summary: A command line tool for DigitalOcean services
description: doctl is a command line tool for DigitalOcean services using the API.
Expand Down