mirror of
https://github.com/open-webui/computer.git
synced 2026-11-22 21:50:43 -05:00
115 lines
3.3 KiB
YAML
115 lines
3.3 KiB
YAML
name: Publish to PyPI
|
|
|
|
on:
|
|
pull_request:
|
|
types: [closed]
|
|
branches: [release]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
detect-version-change:
|
|
if: github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'main'
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version_changed: ${{ steps.check.outputs.changed }}
|
|
version: ${{ steps.check.outputs.version }}
|
|
steps:
|
|
- name: Checkout current commit
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 2 # need parent to diff against
|
|
|
|
- name: Check for version bump
|
|
id: check
|
|
run: |
|
|
# Extract version from current commit
|
|
CURRENT=$(python3 -c "
|
|
import re, pathlib
|
|
text = pathlib.Path('pyproject.toml').read_text()
|
|
m = re.search(r'^version\s*=\s*\"([^\"]+)\"', text, re.M)
|
|
print(m.group(1))
|
|
")
|
|
|
|
# Extract version from previous commit
|
|
git show HEAD~1:pyproject.toml > /tmp/prev_pyproject.toml 2>/dev/null || true
|
|
if [ -f /tmp/prev_pyproject.toml ]; then
|
|
PREVIOUS=$(python3 -c "
|
|
import re, pathlib
|
|
text = pathlib.Path('/tmp/prev_pyproject.toml').read_text()
|
|
m = re.search(r'^version\s*=\s*\"([^\"]+)\"', text, re.M)
|
|
print(m.group(1) if m else '')
|
|
")
|
|
else
|
|
PREVIOUS=""
|
|
fi
|
|
|
|
echo "current=$CURRENT"
|
|
echo "previous=$PREVIOUS"
|
|
|
|
if [ "$CURRENT" != "$PREVIOUS" ] && [ -n "$CURRENT" ]; then
|
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
|
echo "version=$CURRENT" >> "$GITHUB_OUTPUT"
|
|
echo "Version changed: $PREVIOUS -> $CURRENT"
|
|
else
|
|
echo "changed=false" >> "$GITHUB_OUTPUT"
|
|
echo "No version change detected"
|
|
fi
|
|
|
|
build:
|
|
needs: detect-version-change
|
|
if: needs.detect-version-change.outputs.version_changed == 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "22"
|
|
cache: npm
|
|
cache-dependency-path: cptr/frontend/package-lock.json
|
|
|
|
- name: Build frontend
|
|
working-directory: cptr/frontend
|
|
run: |
|
|
npm ci
|
|
npm run build
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install build tools
|
|
run: pip install hatchling build
|
|
|
|
- name: Build package
|
|
run: python -m build
|
|
|
|
- name: Upload dist artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: dist
|
|
path: dist/
|
|
|
|
publish:
|
|
needs: [detect-version-change, build]
|
|
runs-on: ubuntu-latest
|
|
environment: pypi # GitHub environment for deployment protection
|
|
permissions:
|
|
id-token: write # required for trusted publishing (OIDC)
|
|
steps:
|
|
- name: Download dist artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: dist
|
|
path: dist/
|
|
|
|
- name: Publish to PyPI
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
# No API token needed - uses OIDC trusted publishing.
|
|
# Configure at: https://pypi.org/manage/project/cptr/settings/publishing/
|