-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4af47d
commit 731534a
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Upload Python Package to PyPi | ||
|
||
on: | ||
# push: | ||
# branches: | ||
# - main | ||
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/version.py | cut -d'"' -f2) --new-version $(bump2version --dry-run --list patch | grep new_version | sed -r s,"^.*=",,) cmbagent/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/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 }} |