From d3c8b11405e3ac8817f55c196da278d8fe0cea45 Mon Sep 17 00:00:00 2001 From: Saibo-creator <53392976+Saibo-creator@users.noreply.github.com> Date: Wed, 21 Aug 2024 11:13:53 +0800 Subject: [PATCH] Replace static version with dynamic placeholder in setup.py and add GitHub Actions workflow for PyPI releases (#78) Co-authored-by: Saibo MBP --- .github/workflows/pipy_release.yml | 34 ++++++++++++++++++++++++++++++ setup.py | 3 +-- 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/pipy_release.yml diff --git a/.github/workflows/pipy_release.yml b/.github/workflows/pipy_release.yml new file mode 100644 index 0000000..929d9ce --- /dev/null +++ b/.github/workflows/pipy_release.yml @@ -0,0 +1,34 @@ +name: Publish Python 🐍 distributions 📦 to PyPI + +on: + push: + tags: + - '*' # Trigger on any tagging event + +jobs: + build-n-publish: + name: Build and publish Python 🐍 distributions 📦 to PyPI + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 # Updated to a specific version of the checkout action + with: + ref: main # Ensure it checks out the main branch + - name: Set up Python 3.8 + uses: actions/setup-python@v3 + with: + python-version: '3.8' + - name: Install setuptools and wheel + run: python -m pip install setuptools wheel + - name: Extract tag name + id: tag + run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3) + - name: Update version in setup.py + run: >- + sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py + - name: Build a binary wheel + run: >- + python setup.py sdist bdist_wheel + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/setup.py b/setup.py index 25a4f6d..cf08f8d 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,8 @@ from setuptools import setup, find_packages -from transformers_cfg import __version__ setup( name="transformers_cfg", - version=__version__, + version="{{VERSION_PLACEHOLDER}}", author="EPFL-dlab", author_email="saibo.geng@epfl.ch", description="Extension of Transformers library for Context-Free Grammar Constrained Decoding with EBNF grammars",