Skip to content

Update Version and Upload Package #20

Update Version and Upload Package

Update Version and Upload Package #20

Workflow file for this run

name: Update Version and Upload Package
on:
release:
types: [published]
permissions:
contents: read
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
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 bump2version build twine
- name: Extract version from tag
id: extract_version
run: |
# Extract the version from the Git tag
tag=$(echo ${GITHUB_REF} | sed 's/refs\/tags\///')
echo "VERSION=$tag" >> $GITHUB_ENV
- name: Configure Git
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
- name: Update version in pyproject.toml
run: |
# Use bump2version to update version in pyproject.toml
bump2version --new-version $VERSION patch # or minor/major based on your needs
# Check if there are any changes to commit
if [ -n "$(git status --porcelain)" ]; then
git commit -am "Update version to $VERSION"
git push
git push --tags
else
echo "No changes to commit"
fi
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}