Skip to content

Commit

Permalink
update GitHub action upload to pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
paarnes authored Sep 1, 2024
1 parent 9945470 commit 7605490
Showing 1 changed file with 39 additions and 38 deletions.
77 changes: 39 additions & 38 deletions .github/workflows/pypi-package-upload-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,43 @@ on:
jobs:
build:
runs-on: ubuntu-latest

environment: all
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel build twine
- name: Get current version from pyproject.toml
id: get_version
run: echo "::set-output name=version::$(grep -oP '(?<=version = ")[^"]*' pyproject.toml)"

- name: Increment version
id: increment_version
run: echo "::set-output name=version::$(python -c "version='${{ steps.get_version.outputs.version }}'.split('.'); version[-1] = str(int(version[-1]) + 1); print('.'.join(version))")"

- name: Update version in pyproject.toml
run: sed -i "s/version = \".*\"/version = \"${{ steps.increment_version.outputs.version }}\"/" pyproject.toml

- name: Commit and push changes of pyproject.toml
run: |
git config user.name github-actions and push
git config user.email [email protected]
git add pyproject.toml
git commit -m "Bump version to ${{ steps.increment_version.outputs.version }}"
git push origin HEAD:${{ github.ref }}
- name: Build and upload to PyPI
run: |
python -m build
twine upload --password ${{ secrets.PYPI_TOKEN }} dist/*
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel build twine
- name: Get current version from pyproject.toml
id: get_version
run: echo "::set-output name=version::$(grep -oP '(?<=version = ")[^"]*' pyproject.toml)"

- name: Increment version
id: increment_version
run: echo "::set-output name=version::$(python -c "version='${{ steps.get_version.outputs.version }}'.split('.'); version[-1] = str(int(version[-1]) + 1); print('.'.join(version))")"

- name: Update version in pyproject.toml
run: sed -i "s/version = \".*\"/version = \"${{ steps.increment_version.outputs.version }}\"/" pyproject.toml

- name: Commit and push changes of pyproject.toml
run: |
git config user.name github-actions
git config user.email [email protected]
git add pyproject.toml
git commit -m "Bump version to ${{ steps.increment_version.outputs.version }}"
git push origin HEAD:${{ github.ref }}
- name: Build and upload to PyPI
run: |
python -m build
twine upload --password ${{ secrets.PYPI_TOKEN }} dist/*

0 comments on commit 7605490

Please sign in to comment.