Skip to content
Snippets Groups Projects
Commit 1efb39f5 authored by q3k's avatar q3k
Browse files

st3m: make version.py aware of CI

parent 5ab461c2
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ and the release process.
import subprocess
import sys
import os
class Tag:
......@@ -50,7 +51,7 @@ def tags_for_commit(release, commit):
return res
def get_version():
def get_git_based_version():
commit = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode().strip()
branches = (
subprocess.check_output(
......@@ -118,7 +119,15 @@ if len(sys.argv) > 1:
if sys.argv[1] == "-c":
fmt = "C"
v = get_version()
v = None
if os.environ.get('CI') is not None:
tag = os.environ.get('CI_COMMIT_TAG')
if tag is not None:
# If we're building a tag, just use that as a version.
v = tag
if v is None:
v = get_git_based_version()
if fmt == "C":
print('const char *st3m_version = "' + v + '";')
else:
......
......@@ -11,21 +11,12 @@ if [ ! -f sdkconfig.defaults ] || [ ! -f recovery/sdkconfig.defaults ]; then
exit 1
fi
if [ ! -z "${CI}" ]; then
if [ ! -z "${CI_COMMIT_TAG}" ]; then
# If we're building a tag, just use that as a version.
version="${CI_COMMIT_TAG}"
else
# Otherwise, let normal version machinery run, but fetch all changes
# and check out the correct branch. Otherwise we'll get weird version
# strings.
git fetch --unshallow origin "$CI_COMMIT_REF_NAME"
git checkout "$CI_COMMIT_REF_NAME"
version="$(python3 components/st3m/host-tools/version.py)"
fi
else
version="$(python3 components/st3m/host-tools/version.py)"
# Always fetch full history on Gitlab when not building a tag, otherwise we get bogus results.
if [ ! -z "${CI}" && -z "${CI_COMMIT_TAG}" ]; then
git fetch --unshallow origin "$CI_COMMIT_REF_NAME"
git checkout "$CI_COMMIT_REF_NAME"
fi
version="$(python3 components/st3m/host-tools/version.py)"
rm -rf sdkconfig build
rm -rf recovery/sdkconfig recovery/build
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment