Skip to content

Commit e661fc6

Browse files
author
Robert Chu
committed
Switches to use version.py file for python package version.
1 parent b21f3a7 commit e661fc6

4 files changed

Lines changed: 30 additions & 6 deletions

File tree

.github/workflows/publish.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
- name: Install dependencies
4242
run: |
4343
python -m pip install --upgrade pip wheel setuptools pipenv
44+
rm ./script_runner/version.py
4445
# pipenv lock --dev --requirements > requirements.dev.txt
4546
# pip install -r requirements.txt
4647
# - name: Lint with flake8
@@ -52,11 +53,16 @@ jobs:
5253
# - name: Test with pytest
5354
# run: |
5455
# pytest
56+
- name: Inject package version
57+
uses: nowactions/envsubst@v1
58+
with:
59+
input: ./script_runner/version.py.tmpl
60+
output: ./script_runner/version.py
61+
env:
62+
SCRIPT_RUNNER_VERSION: ${{ steps.prep.outputs.version }}
5563
- name: Build python package
5664
run: |
5765
python setup.py sdist
58-
env:
59-
SCRIPT_RUNNER_VERSION: ${{ steps.prep.outputs.version }}
6066
- name: Deploy to PyPI
6167
if: success() && startsWith(github.ref, 'refs/tags')
6268
uses: pypa/gh-action-pypi-publish@release/v1
@@ -131,7 +137,7 @@ jobs:
131137
publish-docker-example:
132138
needs: publish-pypi
133139
if: startsWith(github.ref, 'refs/tags')
134-
name: Build and push script-runner-server-example docker image
140+
name: Publish script-runner-example to dockerhub
135141
runs-on: ubuntu-latest
136142
steps:
137143
- name: Check out the repo
@@ -192,7 +198,7 @@ jobs:
192198
deploy-aws-example:
193199
needs: publish-docker-example
194200
if: startsWith(github.ref, 'refs/tags')
195-
name: Deploy swabseq-analysis-example to AWS
201+
name: Deploy script-runner-example to AWS
196202
runs-on: ubuntu-latest
197203
steps:
198204
- name: Check out the repo
@@ -295,7 +301,7 @@ jobs:
295301
deploy-azure-example:
296302
needs: publish-docker-example
297303
if: startsWith(github.ref, 'refs/tags')
298-
name: Deploy swabseq-analysis-example to Azure
304+
name: Deploy script-runner-example to Azure
299305
runs-on: ubuntu-latest
300306
steps:
301307
- name: Check out the repo

script_runner/version.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
__all__ = ('__version__',)
4+
__version__ = "latest"

script_runner/version.py.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
__all__ = ('__version__',)
4+
__version__ = "$SCRIPT_RUNNER_VERSION"

setup.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
import os
22
from distutils.core import setup
33

4+
def get_version():
5+
"""
6+
Gets the latest version number out of the package,
7+
saving us from maintaining it in multiple places.
8+
"""
9+
local_results = {}
10+
with open('script_runner/version.py') as version_file:
11+
exec(version_file.read(), {}, local_results)
12+
return local_results['__version__']
13+
414
setup(
515
name="script-runner-api",
616
packages=[
717
"script_runner",
818
"script_runner.api",
919
],
1020
scripts=["script_runner/main.py"],
11-
version=os.environ.get("SCRIPT_RUNNER_VERSION", "latest"),
21+
version=get_version(),
1222
license="MIT",
1323
description="Provides an API server + celery worker module for running arbitrary scripts.",
1424
author="Robert Chu",

0 commit comments

Comments
 (0)