72 lines
2.1 KiB
YAML
72 lines
2.1 KiB
YAML
name: Publish FastVideo to PyPI on Version Change
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'pyproject.toml' # Trigger when pyproject.toml changes
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
check-version-change:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version-changed: ${{ steps.check-version.outputs.changed }}
|
|
new-version: ${{ steps.check-version.outputs.new-version }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 2
|
|
|
|
- name: Check if version changed
|
|
id: check-version
|
|
run: |
|
|
# Get current commit's version
|
|
NEW_VERSION=$(grep -oP "version\\s*=\\s*\"\\K[^\"]+\"" pyproject.toml)
|
|
echo "New version: $NEW_VERSION"
|
|
|
|
# Get previous version from git history
|
|
OLD_VERSION=$(git show HEAD~1:./pyproject.toml | grep -oP "version\\s*=\\s*\"\\K[^\"]+\"" || echo "0.0.0")
|
|
echo "Old version: $OLD_VERSION"
|
|
|
|
if [ "$NEW_VERSION" != "$OLD_VERSION" ]; then
|
|
echo "Version changed from $OLD_VERSION to $NEW_VERSION"
|
|
echo "changed=true" >> $GITHUB_OUTPUT
|
|
echo "new-version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "Version did not change"
|
|
echo "changed=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
build-publish-main:
|
|
needs: check-version-change
|
|
if: ${{ needs.check-version-change.outputs.version-changed == 'true' || github.event_name == 'workflow_dispatch' }}
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
id-token: write # Needed for OIDC Trusted Publishing
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.10'
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v3
|
|
|
|
- name: Install build dependencies
|
|
run: uv pip install --system build twine wheel
|
|
|
|
- name: Build package
|
|
run: |
|
|
python -m build
|
|
|
|
- name: Publish release distributions to PyPI
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
with:
|
|
packages-dir: dist/ |