Skip to content

Commit

Permalink
Only run publish workflow on new tag push
Browse files Browse the repository at this point in the history
  • Loading branch information
fwhigh committed May 14, 2021
1 parent 58b49e9 commit e92547d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: publish

on: push
on:
push:
tags:
- 'v*.*.*'

jobs:
build-n-publish:
Expand Down
13 changes: 10 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io
import os
import sys
import subprocess

from setuptools import find_packages, setup
from setuptools.command.install import install
Expand Down Expand Up @@ -49,11 +50,17 @@ class VerifyVersionCommand(install):
description = 'verify that the git tag matches our version'

def run(self):
tag = os.getenv('CIRCLE_TAG')
this_version = f'v{VERSION}'
cmd = "git describe --dirty --tags --long --match *.* --first-parent".split(" ")
try:
tag = subprocess.check_output(cmd).decode().strip()
except subprocess.CalledProcessError:
print('Unable to get version number from git tags')
tag = '<NONE>'

if tag != VERSION:
if tag != this_version:
info = "Git tag: {0} does not match the version of this app: {1}".format(
tag, VERSION
tag, this_version
)
sys.exit(info)

Expand Down

0 comments on commit e92547d

Please sign in to comment.