Skip to content

Commit 7c555d5

Browse files
committed
Generate correct tag names on release
1 parent a8eae23 commit 7c555d5

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

.circleci/get_version.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
error_message = f'Version {version} does not match the expected format'
12+
raise ValueError(error_message)
13+
base_version = match.group(1)
14+
alpha_version = match.group(2)
15+
print(f'{base_version}a{alpha_version}')
16+
17+
18+
if __name__ == '__main__':
19+
main()

.circleci/publish_pypi.sh

Lines changed: 16 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 7 additions & 3 deletions
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)