From 6276b84a011dd0ef1e29b92d7a3c05ac1c1f4da7 Mon Sep 17 00:00:00 2001 From: Robert Chu Date: Wed, 14 Apr 2021 21:49:22 -0700 Subject: [PATCH] Switches to use version.py file for python package version. --- .github/workflows/publish.yml | 16 +++++++++++----- docker/Dockerfile.example | 2 +- script_runner/version.py | 4 ++++ script_runner/version.py.tmpl | 4 ++++ setup.py | 12 +++++++++++- 5 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 script_runner/version.py create mode 100644 script_runner/version.py.tmpl diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1bd5d15..0d850a3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -41,6 +41,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip wheel setuptools pipenv + rm ./script_runner/version.py # pipenv lock --dev --requirements > requirements.dev.txt # pip install -r requirements.txt # - name: Lint with flake8 @@ -52,11 +53,16 @@ jobs: # - name: Test with pytest # run: | # pytest + - name: Inject package version + uses: nowactions/envsubst@v1 + with: + input: ./script_runner/version.py.tmpl + output: ./script_runner/version.py + env: + SCRIPT_RUNNER_VERSION: ${{ steps.prep.outputs.version }} - name: Build python package run: | python setup.py sdist - env: - SCRIPT_RUNNER_VERSION: ${{ steps.prep.outputs.version }} - name: Deploy to PyPI if: success() && startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 @@ -131,7 +137,7 @@ jobs: publish-docker-example: needs: publish-pypi if: startsWith(github.ref, 'refs/tags') - name: Build and push script-runner-server-example docker image + name: Publish script-runner-example to dockerhub runs-on: ubuntu-latest steps: - name: Check out the repo @@ -192,7 +198,7 @@ jobs: deploy-aws-example: needs: publish-docker-example if: startsWith(github.ref, 'refs/tags') - name: Deploy swabseq-analysis-example to AWS + name: Deploy script-runner-example to AWS runs-on: ubuntu-latest steps: - name: Check out the repo @@ -295,7 +301,7 @@ jobs: deploy-azure-example: needs: publish-docker-example if: startsWith(github.ref, 'refs/tags') - name: Deploy swabseq-analysis-example to Azure + name: Deploy script-runner-example to Azure runs-on: ubuntu-latest steps: - name: Check out the repo diff --git a/docker/Dockerfile.example b/docker/Dockerfile.example index 098647a..563c396 100644 --- a/docker/Dockerfile.example +++ b/docker/Dockerfile.example @@ -8,7 +8,7 @@ FROM rocker/verse:3.6.3 # get and install bcl2fastq RUN cd /tmp \ && wget https://www.dropbox.com/s/idi0xfu0thurk7q/bcl2fastq2-v2-20-0-linux-x86-64.zip \ - && unzip bcl2fastq2-v2-20-0-linux-x86-64.zip -p \ + && unzip -p bcl2fastq2-v2-20-0-linux-x86-64.zip bcl2fastq2-v2.20.0.422-Linux-x86_64.rpm \ | tar xvz -C / usr/local/bin/bcl2fastq \ && rm /tmp/bcl2fastq2* diff --git a/script_runner/version.py b/script_runner/version.py new file mode 100644 index 0000000..84c6df9 --- /dev/null +++ b/script_runner/version.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +__all__ = ('__version__',) +__version__ = "latest" diff --git a/script_runner/version.py.tmpl b/script_runner/version.py.tmpl new file mode 100644 index 0000000..2a21097 --- /dev/null +++ b/script_runner/version.py.tmpl @@ -0,0 +1,4 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +__all__ = ('__version__',) +__version__ = "$SCRIPT_RUNNER_VERSION" diff --git a/setup.py b/setup.py index 841ad2a..fb50724 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,16 @@ import os from distutils.core import setup +def get_version(): + """ + Gets the latest version number out of the package, + saving us from maintaining it in multiple places. + """ + local_results = {} + with open('script_runner/version.py') as version_file: + exec(version_file.read(), {}, local_results) + return local_results['__version__'] + setup( name="script-runner-api", packages=[ @@ -8,7 +18,7 @@ "script_runner.api", ], scripts=["script_runner/main.py"], - version=os.environ.get("SCRIPT_RUNNER_VERSION", "latest"), + version=get_version(), license="MIT", description="Provides an API server + celery worker module for running arbitrary scripts.", author="Robert Chu",