Skip to content

Commit

Permalink
Replace static version with dynamic placeholder in setup.py and add G…
Browse files Browse the repository at this point in the history
…itHub Actions workflow for PyPI releases (#78)

Co-authored-by: Saibo MBP <[email protected]>
  • Loading branch information
Saibo-creator and Saibo MBP authored Aug 21, 2024
1 parent 6055ac5 commit d3c8b11
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/pipy_release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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="[email protected]",
description="Extension of Transformers library for Context-Free Grammar Constrained Decoding with EBNF grammars",
Expand Down

0 comments on commit d3c8b11

Please sign in to comment.