From 75e94a194beb8c145bc8f2fa69e24a9879a9a5e1 Mon Sep 17 00:00:00 2001 From: Wazzabeee Date: Sun, 21 Apr 2024 11:48:05 +0200 Subject: [PATCH] feat: add tags and automatic versioning --- .github/workflows/ci.yml | 44 ++++++++++++++++++++++++---------------- setup.py | 14 ++++++++++--- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce688a0..106a645 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,20 +45,30 @@ jobs: continue-on-error: true release: - needs: [ test, good-practices ] - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.11.5' - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - pip install setuptools wheel twine - python setup.py sdist bdist_wheel - twine upload dist/* + needs: [test, good-practices] + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Bump version and push tag + uses: anothrNick/github-tag-action@1.26.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DEFAULT_BUMP: auto + MAJOR_PATTERN: '^BREAKING CHANGE:' + MINOR_PATTERN: '^feat:' + PATCH_PATTERN: '^fix:' + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.11.5' + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + pip install setuptools wheel twine + python setup.py sdist bdist_wheel + twine upload dist/* \ No newline at end of file diff --git a/setup.py b/setup.py index 8058d9e..ea06ed5 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,19 @@ +import subprocess from setuptools import setup, find_packages -with open("VERSION") as version_file: - version = version_file.read().strip() + +def get_version(): + try: + # Get the latest tag from Git + version = subprocess.check_output(["git", "describe", "--tags"]).strip().decode("utf-8") + except Exception: + version = "0.1.0" + return version + setup( name="copy-spotter", - version=version, + version=get_version(), packages=find_packages(), install_requires=[ "beautifulsoup4==4.10.0",