Skip to content

Update pyproject.toml #36

Update pyproject.toml

Update pyproject.toml #36

Workflow file for this run

name: Auto-release on Main
on:
push:
branches:
- main
permissions:
contents: write
jobs:
version_and_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Extract and Increment Version
id: version
run: |
# Extract current version from pyproject.toml
current_version=$(grep -Po '(?<=^version = ")[^"]*' pyproject.toml)
# Split version into major, minor, and patch
IFS='.' read -r major minor patch <<< "$current_version"
# Increment patch version
new_version="$major.$minor.$((patch + 1))"
# Update version in pyproject.toml
sed -i "s/^version = \".*\"/version = \"$new_version\"/" pyproject.toml
# Update version in __init__.py
sed -i "s/__version__ *= *['\"][^'\"]*['\"]/__version__ = '$new_version'/" src/flexistack/__init__.py
# Use environment file for output
echo "new_version=$new_version" >> $GITHUB_ENV
- name: Commit updated version
run: |
git config --local user.name "github-actions"
git config --local user.email "actions@github.com"
git commit -am "Bump version to ${{ env.new_version }}"
git tag ${{ env.new_version }}
git push origin main --tags
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.new_version }}
release_name: ${{ env.new_version }}
draft: false
prerelease: false
- name: Build package
run: python -m build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}