Skip to content
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
15 changes: 10 additions & 5 deletions scripts/version.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# this script updateds version information
# this script updates version information

# version details
export BUILD_DATE=`date -u +'%Y-%m-%dT%H:%M:%S%:z'`
Expand All @@ -9,13 +9,18 @@ export GIT_SHA=`git rev-parse HEAD`
export GIT_SHA_SHORT=`git rev-parse --short HEAD`
export VERSION_PKG="github.com/mycontroller-org/esphome_api/cli/version"

# update tag, if available
if [ ${GIT_BRANCH} = "HEAD" ]; then
# update tag, if available (detached HEAD on a release tag, e.g. v1.4.0)
if [ "${GIT_BRANCH}" = "HEAD" ]; then
export GIT_BRANCH=`git describe --abbrev=0 --tags`
fi

# update version number
export VERSION=`echo ${GIT_BRANCH} | awk 'match($0, /([0-9]*\.[0-9]*)$/) { print substr($0, RSTART, RLENGTH) }'`
# Prefer full semver X.Y.Z (e.g. v1.4.0 -> 1.4.0).
# Do not use X.Y at end of string: that turns v1.4.0 into 4.0.
export VERSION=`echo "${GIT_BRANCH}" | awk 'match($0, /[0-9]+\.[0-9]+\.[0-9]+/) { print substr($0, RSTART, RLENGTH); exit }'`
if [ -z "$VERSION" ]; then
# fallback: major.minor only (e.g. branch release/1.4)
export VERSION=`echo "${GIT_BRANCH}" | awk 'match($0, /[0-9]+\.[0-9]+/) { print substr($0, RSTART, RLENGTH); exit }'`
fi
if [ -z "$VERSION" ]; then
# takes version from versions file and adds devel suffix with that
STATIC_VERSION=`grep esphomectl= versions.txt | awk -F= '{print $2}'`
Expand Down
2 changes: 1 addition & 1 deletion versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# this version number will be used for development builds
esphomectl=1.4
esphomectl=1.4.0
Loading