| 1 |
#!/bin/bash -eu |
| 2 |
|
| 3 |
VERSION=$(grep "^__version__" dials_data/__init__.py | cut -d'"' -f 2) |
| 4 |
BASETAG=v${VERSION} |
| 5 |
git tag --list | grep "^${BASETAG}$" || { |
| 6 |
echo Searching for tag on remote |
| 7 |
if git fetch origin tag ${BASETAG}; then |
| 8 |
echo Tag found on remote. Deepening checkout... |
| 9 |
git fetch --shallow-exclude ${BASETAG} |
| 10 |
git fetch --deepen 1 |
| 11 |
else |
| 12 |
echo "Tag not found on remote. Let's make a new one!" |
| 13 |
git tag ${BASETAG} |
| 14 |
echo "##[warning]Tag ${BASETAG} is missing on your repository. Packages generated during the build will not have reliable version numbers" |
| 15 |
fi |
| 16 |
} |
| 17 |
|
| 18 |
DEPTH=$(git rev-list ${BASETAG}..HEAD --count --first-parent) |
| 19 |
REAL_VERSION=${VERSION%.0}.${DEPTH} |
| 20 |
echo Setting package version from ${VERSION} to ${REAL_VERSION} |
| 21 |
sed -i "s/^__version__ =.*/__version__ = \"${REAL_VERSION}\"/" dials_data/__init__.py |
| 22 |
sed -i "s/^version = .*$/version = ${REAL_VERSION}/" setup.cfg |
| 23 |
|
| 24 |
COMMIT=$(git rev-parse --verify HEAD) |
| 25 |
echo Setting package commit to ${COMMIT} |
| 26 |
sed -i "s/^__commit__ =.*/__commit__ = \"${COMMIT}\"/" dials_data/__init__.py |