|
4 | 4 | # versions. Note: the version returned by this script will NOT include the "v"
|
5 | 5 | # prefix that is included in the Git tag.
|
6 | 6 | #
|
7 |
| -# If $CODER_FORCE_DEV_VERSION is set to "true", the returned version will be a |
8 |
| -# dev version even if the current commit is tagged. |
| 7 | +# If $CODER_RELEASE is set to "true", the returned version will equal the |
| 8 | +# current git tag. If the current commit is not tagged, this will fail. |
9 | 9 | #
|
10 |
| -# If $CODER_NO_DEV_VERSION is set to "true", the script will fail if the current |
11 |
| -# commit is not tagged. |
| 10 | +# If $CODER_RELEASE is not set, the returned version will always be a dev |
| 11 | +# version. |
12 | 12 |
|
13 | 13 | set -euo pipefail
|
14 | 14 | # shellcheck source=scripts/lib.sh
|
15 | 15 | source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
16 | 16 | cdroot
|
17 | 17 |
|
18 |
| -# $current will equal $last_tag if we currently have the tag checked out. |
19 |
| -last_tag="$(git describe --tags --abbrev=0)" |
20 |
| -current="$(git describe --always)" |
21 |
| - |
22 |
| -version="$last_tag" |
| 18 | +version="$(git describe --tags --abbrev=0)" |
23 | 19 |
|
24 | 20 | # If the HEAD has extra commits since the last tag then we are in a dev version.
|
25 | 21 | #
|
26 | 22 | # Dev versions are denoted by the "-devel+" suffix with a trailing commit short
|
27 | 23 | # SHA.
|
28 |
| -if [[ "${CODER_FORCE_DEV_VERSION:-}" == *t* ]] || [[ "$last_tag" != "$current" ]]; then |
29 |
| - if [[ "${CODER_NO_DEV_VERSION:-}" == *t* ]]; then |
30 |
| - # make won't exit on $(shell cmd) failures :( |
| 24 | +if [[ "${CODER_RELEASE:-}" == *t* ]]; then |
| 25 | + # $version will equal `git describe --always` if we currently have the tag |
| 26 | + # checked out. |
| 27 | + if [[ "$version" != "$(git describe --always)" ]]; then |
| 28 | + # make won't exit on $(shell cmd) failures, so we have to kill it :( |
31 | 29 | if [[ "$(ps -o comm= "$PPID" || true)" == *make* ]]; then
|
32 |
| - log "ERROR: version.sh attemped to generate a dev version string when CODER_NO_DEV_VERSION was set" |
| 30 | + log "ERROR: version.sh attemped to generate a dev version string when CODER_RELEASE was set" |
33 | 31 | kill "$PPID" || true
|
34 | 32 | exit 1
|
35 | 33 | fi
|
36 | 34 |
|
37 |
| - error "version.sh attemped to generate a dev version string when CODER_NO_DEV_VERSION was set" |
| 35 | + error "version.sh attemped to generate a dev version string when CODER_RELEASE was set" |
38 | 36 | fi
|
| 37 | +else |
39 | 38 | version+="-devel+$(git rev-parse --short HEAD)"
|
40 | 39 | fi
|
41 | 40 |
|
|
0 commit comments