From 8a3136d2e9d31b75eb2a3d246b650d1a2fd2de94 Mon Sep 17 00:00:00 2001 From: Andy Hebrank Date: Tue, 17 Jan 2023 16:55:11 -0500 Subject: [PATCH 1/2] set version from tag --- .github/workflows/publish.yml | 11 +++++++++++ README.md | 2 +- setup.py | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3cf7200..ed2606a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,6 +7,17 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Set version from tag + if: startsWith(github.ref, 'refs/tags') + run: | + # from refs/tags/1.2.3 get 1.2.3 + VERSION=$(echo $GITHUB_REF | sed 's#.*/##') + PLACEHOLDER='version="develop"' + VERSION_FILE='setup.py' + grep "$PLACEHOLDER" "$VERSION_FILE" + sed -i "s/$PLACEHOLDER/version=\"${VERSION}\"/" "$VERSION_FILE" + shell: bash + - name: install dependencies & build run: | pip3 install setuptools wheel diff --git a/README.md b/README.md index b4d9223..a133c11 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ It will optionally verify that the POST request originated from a particular IP ### Installation ```bash -pip install . +pip install gwh ``` ### Repository Configuration diff --git a/setup.py b/setup.py index 09afb73..6bb59ed 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,7 @@ setup( name="gwh", + version="develop", author='Andy Hebrank', author_email='ahebrank@gmail.com', packages=['gwh'], From 7345dba81977d84edb2ae6c17d5a99057b181e94 Mon Sep 17 00:00:00 2001 From: Andy Hebrank Date: Wed, 18 Jan 2023 08:55:42 -0500 Subject: [PATCH 2/2] limit to semantic version tags --- .github/workflows/publish.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ed2606a..2362b8a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,7 @@ -on: [push, pull_request] +on: + push: + tags: + - '*.*.*' jobs: publish: @@ -11,9 +14,10 @@ jobs: if: startsWith(github.ref, 'refs/tags') run: | # from refs/tags/1.2.3 get 1.2.3 - VERSION=$(echo $GITHUB_REF | sed 's#.*/##') + VERSION=$( basename $GITHUB_REF ) PLACEHOLDER='version="develop"' VERSION_FILE='setup.py' + # fail out if placeholder not found grep "$PLACEHOLDER" "$VERSION_FILE" sed -i "s/$PLACEHOLDER/version=\"${VERSION}\"/" "$VERSION_FILE" shell: bash