Skip to content

Building AI agents, atomically

Update python-publish.yml

Kenny Vaneetveldea62e61e4b5b3
diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml
index 6baa6a1..0f4fb53 100644
--- a/.github/workflows/python-publish.yml
+++ b/.github/workflows/python-publish.yml
@@ -1,51 +1,71 @@
-name: Create Pull Request
+name: Upload Python Package
on:
- push:
- branches:
- - main
+ release:
+ types: [published]
+
+permissions:
+ contents: write
+ pull-requests: write
jobs:
- create_pull_request:
+ deploy:
runs-on: ubuntu-latest
+
steps:
- - name: Checkout repository
- uses: actions/checkout@v2
-
- - name: Set up Git
- run: |
- git config user.name "github-actions[bot]"
- git config user.email "github-actions[bot]@users.noreply.github.com"
-
- - name: Create version-bump branch if it doesn't exist
- run: |
- git fetch origin
- if ! git rev-parse --verify origin/version-bump; then
- git checkout -b version-bump
- git push origin version-bump
- else
- git checkout version-bump
- fi
-
- - name: Make changes
- run: |
- # Your commands to make changes go here
- echo "Making changes..."
-
- - name: Commit changes
- run: |
- git add .
- git commit -m "Bump version"
-
- - name: Push changes
- run: |
- git push origin version-bump
-
- - name: Create Pull Request
- uses: peter-evans/create-pull-request@v6
- with:
- token: ${{ secrets.GITHUB_TOKEN }}
- branch: version-bump
- title: "Version Bump"
- body: "This PR bumps the version."
- base: main
+ - 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: Bump version in pyproject.toml
+ run: |
+ VERSION=$(echo $GITHUB_REF | sed 's/refs\/tags\/v//')
+ sed -i "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
+ shell: bash
+
+ - name: Commit changes
+ run: |
+ git config --global user.name "github-actions[bot]"
+ git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
+ git add pyproject.toml
+ git commit -m "Bump version to $VERSION"
+
+ - name: Create Pull Request
+ id: cpr
+ uses: peter-evans/create-pull-request@v6
+ with:
+ commit-message: "Bump version to $VERSION"
+ branch: version-bump
+ base: main
+ title: "Bump version to $VERSION"
+ body: "This PR bumps the version to $VERSION."
+ labels: version-bump
+
+ - name: Install GitHub CLI
+ run: sudo apt-get install gh
+
+ - name: Checkout base branch
+ run: git checkout main
+
+ - name: Merge Pull Request
+ run: |
+ gh pr merge ${{ steps.cpr.outputs.pull-request-number }} --squash --admin --delete-branch
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ - 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 }}