forked from abhinavsingh/proxy.py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
write-scm-version.sh
executable file
·46 lines (39 loc) · 1.14 KB
/
write-scm-version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
#
# write-scm-version.sh exists because `proxy.py``
# auto-detects it's next version from git. Hence,
# for `proxy.py` to work `proxy/common/_scm_version.py`
# file must be auto-generated with necessary information.
#
# For CI/CD, this file is generated via `tox` integration.
# For local development (without editable install), you
# must run this script to pre-populate `_scm_version.py`.
#
# This file is integrated by default within `Makefile`.
# For every make target invocation, `_scm_version.py` file
# will be re-written.
# Guessed Version 2.3.2.dev146+gad54132.d20211114
VERSION=$(python -m setuptools_scm --version | \
# 2.3.2.dev146+gad54132.d20211114
awk '{print $3}')
# Store default IFS
OLDIFS=$IFS
IFS="+"
set -- $VERSION
SEMVER=$1
DATE_AND_HASH=$2
IFS="."
set -- $SEMVER
MAJOR=$1
MINOR=$2
PATCH=$3
DISTANCE=$4
# Reset IFS
IFS=$OLDIFS
echo "# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
version = '${VERSION}'
version_tuple = (${MAJOR}, ${MINOR}, '${PATCH}', '${DISTANCE}', '${DATE_AND_HASH}')" > \
proxy/common/_scm_version.py
echo $MAJOR.$MINOR.$PATCH.$DISTANCE