From 2dc817a91aea0cfb4d69db01202f6a009e6e534d Mon Sep 17 00:00:00 2001 From: Llewellyn Falco Date: Sun, 8 May 2022 20:05:46 +0000 Subject: [PATCH] e version file for auto update on release Co-Authored-By: 4dsherwood <10386643+4dsherwood@users.noreply.github.com> Co-Authored-By: Bernhard Raml <1769280+SwamyDev@users.noreply.github.com> --- .github/workflows/publish.yml | 8 ++++++++ setup.py | 9 ++++++++- version.py | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 version.py diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a4516ab..06cdc0f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,6 +15,14 @@ jobs: uses: actions/setup-python@v2 with: python-version: '3.x' + - name: Determine version from git tag + id: version + run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} + + - name: set version + run: | + rm ./version.py + echo version_number = \"${{ steps.version.outputs.tag }}\" > ./version.py - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/setup.py b/setup.py index fe4c0c7..ebe7f4c 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,9 @@ import os import codecs +import re +from pathlib import Path + from setuptools import setup @@ -10,10 +13,14 @@ def read(fname): file_path = os.path.join(os.path.dirname(__file__), fname) return codecs.open(file_path, encoding='utf-8').read() +HERE = Path(__file__).parent +_version_file_contents = (HERE / "version.py").read_text() +matched = re.search(r'"(.*)"', _version_file_contents) +VERSION = matched.group(1) if matched is not None else "UNKNOWN VERSION" setup( name='pytest-approvaltests', - version='0.2.3', + version=VERSION, author='Emily Bache', author_email='emily@bacheconsulting.com', maintainer='Emily Bache', diff --git a/version.py b/version.py new file mode 100644 index 0000000..da33388 --- /dev/null +++ b/version.py @@ -0,0 +1 @@ +version_number = "v5.0.1"