Update python-package.yml #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Upload Python Package to PyPi | |
on: | |
push: | |
branches: | |
- cmbagent | |
workflow_dispatch: | |
release: | |
types: [published] | |
permissions: # Ensure the workflow has permission to push changes | |
contents: write # Allow write access for pushing to the repository | |
jobs: | |
bump_version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: true | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Install bump2version | |
run: python -m pip install bump2version | |
- name: Bump version (patch) | |
run: | | |
bump2version patch --current-version $(grep -Eo '__version__ = "[^"]*' cmbagent_autogen/version.py | cut -d'"' -f2) cmbagent_autogen/version.py | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Commit and push version bump | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
git add cmbagent_autogen/version.py | |
git commit -m "Bump version" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
deploy: | |
needs: bump_version | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- 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: Build package | |
run: python -m build | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |