Skip to content

Update pypi_upload.yml #5

Update pypi_upload.yml

Update pypi_upload.yml #5

Workflow file for this run

name: Release to PyPI
on:
pull_request:
types: [closed]
branches:
- main
push:
branches:
- kevinlu1248-patch-4
jobs:
release:
# if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Get current version
run: |
export VERSION=$(sed -n 's/^version = "\(.*\)"$/\1/p' pyproject.toml)
echo "Current version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Bump version
run: |
echo "Bumping version..."
old_version=$(sed -n 's/^version = "\(.*\)"$/\1/p' pyproject.toml)
new_version=$(echo $old_version | awk -F'.' '{$NF+=1; print $0}' OFS='.')
sed -i "s/version = \\\"\(.*\)\\\"/version = \\\\"$new_version\\\\"/" pyproject.toml
echo "New version: $new_version"
echo "version=$new_version" >> $GITHUB_OUTPUT
- name: Build package
run: python -m build
- name: Publish to PyPI
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload --skip-existing dist/*
- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.bump-version.outputs.version }}
release_name: Release ${{ steps.bump-version.outputs.version }}