Skip to content

Commit 845a039

Browse files
committed
Generate correct tag names on release
1 parent a8eae23 commit 845a039

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

.circleci/get_version.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import re
2+
3+
import setuptools_scm
4+
5+
6+
def main():
7+
version = setuptools_scm.get_version()
8+
expected_version_regex = r'(\d+\.\d+\.\d+)a(\d+).+$'
9+
match = re.match(expected_version_regex, version)
10+
if not match:
11+
raise ValueError(f'Version {version} does not match the expected format')
12+
base_version = match.group(1)
13+
alpha_version = match.group(2)
14+
print(f'{base_version}a{alpha_version}')
15+
16+
17+
if __name__ == '__main__':
18+
main()

.circleci/publish_pypi.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
export SETUPTOOLS_SCM_PRETEND_VERSION=`python -m setuptools_scm | sed "s/.* //"`
6+
if [ "${CIRCLE_BRANCH-:}" = "master" ]; then
7+
export SETUPTOOLS_SCM_PRETEND_VERSION=`echo $SETUPTOOLS_SCM_PRETEND_VERSION | sed "s/\+.*$//"`
8+
elif [ "${CIRCLE_BRANCH-:}" = "girder-5" ]; then
9+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10+
pip install setuptools-scm
11+
export SETUPTOOLS_SCM_PRETEND_VERSION=$(python "$SCRIPT_DIR/get_version.py")
12+
fi
13+
14+
python -m build
15+
twine check dist/*
16+
twine upload --skip-existing dist/*

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def prerelease_local_scheme(version):
1717
"""
1818
from setuptools_scm.version import get_local_node_and_date
1919

20-
if os.getenv('CIRCLE_BRANCH') in ('master', ):
20+
if os.getenv('CIRCLE_BRANCH') in ('master', 'girder-5'):
2121
return ''
2222
else:
2323
return get_local_node_and_date(version)

tox.ini

+7-3
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,22 @@ commands =
9090
npm run format
9191

9292
[testenv:release]
93+
allowlist_externals =
94+
{toxinidir}/.circleci/publish_pypi.sh
95+
skip_install = true
96+
skipsdist = true
9397
passenv =
9498
TWINE_USERNAME
9599
TWINE_PASSWORD
96100
TWINE_REPOSITORY_URL
97101
CIRCLE_BRANCH
98102
deps =
99103
build
104+
setuptools-git
105+
setuptools-scm
100106
twine
101107
commands =
102-
python -m build
103-
twine check dist/*
104-
twine upload --skip-existing dist/*
108+
{toxinidir}/.circleci/publish_pypi.sh
105109

106110
[flake8]
107111
max-line-length = 100

0 commit comments

Comments
 (0)