Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: Publish to PyPI

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
pull-requests: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true

- name: Cache Poetry dependencies
uses: actions/cache@v3
with:
path: |
~/.cache/pypoetry
.venv
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
poetry-${{ runner.os }}-

- name: Install dependencies
run: poetry install --no-interaction --no-ansi

- name: Check version consistency
id: version_check
run: |
# Extract version from pyproject.toml
PYPROJECT_VERSION=$(poetry version -s)
echo "pyproject_version=$PYPROJECT_VERSION" >> $GITHUB_OUTPUT

# Extract version from release tag (remove 'v' prefix if present)
RELEASE_TAG="${{ github.event.release.tag_name }}"
TAG_VERSION="${RELEASE_TAG#v}"
echo "tag_version=$TAG_VERSION" >> $GITHUB_OUTPUT

echo "PyProject version: $PYPROJECT_VERSION"
echo "Release tag version: $TAG_VERSION"

if [ "$PYPROJECT_VERSION" != "$TAG_VERSION" ]; then
echo "version_mismatch=true" >> $GITHUB_OUTPUT
echo "❌ Version mismatch detected!"
echo "PyProject version: $PYPROJECT_VERSION"
echo "Release tag version: $TAG_VERSION"
else
echo "version_mismatch=false" >> $GITHUB_OUTPUT
echo "✅ Version consistency check passed!"
fi

- name: Create version update PR
if: steps.version_check.outputs.version_mismatch == 'true'
run: |
# Configure git
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'

# Create new branch
BRANCH_NAME="update-version-to-${{ steps.version_check.outputs.tag_version }}"
git checkout -b "$BRANCH_NAME"

# Update version in pyproject.toml
poetry version "${{ steps.version_check.outputs.tag_version }}"

# Commit changes
git add pyproject.toml
git commit -m "Update version to ${{ steps.version_check.outputs.tag_version }} to match release tag

This automated commit updates the version in pyproject.toml to match the release tag ${{ github.event.release.tag_name }}.

Previous version: ${{ steps.version_check.outputs.pyproject_version }}
New version: ${{ steps.version_check.outputs.tag_version }}"

# Push branch
git push origin "$BRANCH_NAME"

# Create PR
gh pr create \
--title "🔖 Update version to ${{ steps.version_check.outputs.tag_version }}" \
--body "## Version Update

This PR automatically updates the version in \`pyproject.toml\` to match the release tag.

**Changes:**
- Update version from \`${{ steps.version_check.outputs.pyproject_version }}\` to \`${{ steps.version_check.outputs.tag_version }}\`

**Triggered by:** Release [${{ github.event.release.tag_name }}](${{ github.event.release.html_url }})

**Note:** The PyPI publishing workflow has been paused until this version mismatch is resolved. Once this PR is merged, please re-run the publishing workflow or create a new release." \
--head "$BRANCH_NAME" \
--base main \
--label "automated" \
--label "version-update"
env:
GH_TOKEN: ${{ github.token }}

- name: Stop workflow if version mismatch
if: steps.version_check.outputs.version_mismatch == 'true'
run: |
echo "❌ Stopping workflow due to version mismatch."
echo "A PR has been created to fix the version inconsistency."
echo "Please merge the PR and re-run this workflow or create a new release."
exit 1

- name: Run tests
run: poetry run pytest tests/ --cov=avidtools

- name: Run linting
run: poetry run ruff check avidtools

- name: Run type checking
run: timeout 60 poetry run mypy --config-file ./mypy.ini avidtools || echo "Type checking completed with timeout"

- name: Build package
run: poetry build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
48 changes: 48 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Run Tests

on:
pull_request:
branches:
- main

jobs:
IntegrationTests:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.12'

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -

# Cache poetry dependencies so that tests are faster if the lock file hasn't changed
- name: Cache Poetry dependencies
uses: actions/cache@v3
with:
path: |
~/.cache/pypoetry
~/.virtualenvs
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
poetry-${{ runner.os }}-

- name: Install dependencies with Poetry
run: poetry install --no-interaction --no-ansi

- name: Mypy Type Checking
run: make typecheck

- name: Ruff Linting and Formatting
run: make linting

- name: Run tests
run: make test
144 changes: 144 additions & 0 deletions .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: Update Version

on:
workflow_dispatch:
inputs:
version:
description: 'New version (e.g., 0.2.1)'
required: true
type: string
update_method:
description: 'How to update the version'
required: true
type: choice
options:
- 'create-pr'
- 'direct-commit-and-release'
default: 'create-pr'

jobs:
update-version:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true

- name: Validate version format
run: |
VERSION="${{ github.event.inputs.version }}"
if ! echo "$VERSION" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "❌ Invalid version format: $VERSION"
echo "Version must follow semantic versioning (e.g., 1.2.3)"
exit 1
fi
echo "✅ Version format is valid: $VERSION"

- name: Configure git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'

- name: Update version via PR
if: github.event.inputs.update_method == 'create-pr'
run: |
CURRENT_VERSION=$(poetry version -s)
NEW_VERSION="${{ github.event.inputs.version }}"

echo "Current version: $CURRENT_VERSION"
echo "New version: $NEW_VERSION"

# Update version
poetry version "$NEW_VERSION"

# Create branch
BRANCH_NAME="update-version-to-$NEW_VERSION"
git checkout -b "$BRANCH_NAME"

# Commit changes
git add pyproject.toml
git commit -m "🔖 Update version to $NEW_VERSION

Manual version update from $CURRENT_VERSION to $NEW_VERSION"

# Push branch
git push origin "$BRANCH_NAME"

# Create PR
gh pr create \
--title "🔖 Update version to $NEW_VERSION" \
--body "## Version Update

This PR updates the version in \`pyproject.toml\`.

**Changes:**
- Update version from \`$CURRENT_VERSION\` to \`$NEW_VERSION\`

**Triggered by:** Manual workflow dispatch (PR method)

**Next steps:** Merge this PR manually when ready." \
--head "$BRANCH_NAME" \
--base main \
--label "version-update"

echo "✅ PR created! Please review and merge manually."
env:
GH_TOKEN: ${{ github.token }}

- name: Update version and create release directly
if: github.event.inputs.update_method == 'direct-commit-and-release'
run: |
CURRENT_VERSION=$(poetry version -s)
NEW_VERSION="${{ github.event.inputs.version }}"

echo "Current version: $CURRENT_VERSION"
echo "New version: $NEW_VERSION"

# Update version
poetry version "$NEW_VERSION"

# Commit directly to main
git add pyproject.toml
git commit -m "🔖 Update version to $NEW_VERSION

Automatic version update from $CURRENT_VERSION to $NEW_VERSION

This commit was created automatically by the version update workflow
and will trigger a GitHub release and PyPI publishing."

# Push to main
git push origin main

# Create GitHub release
echo "🚀 Creating GitHub release for version $NEW_VERSION..."

gh release create "v$NEW_VERSION" \
--title "Release v$NEW_VERSION" \
--notes "## What's Changed

- Updated version to $NEW_VERSION

**Automatically generated release from version update workflow.**

This release was created automatically and will trigger PyPI publishing." \
--latest

echo "✅ Version updated and release v$NEW_VERSION created successfully!"
echo "🔄 This will trigger the PyPI publishing workflow automatically."
env:
GH_TOKEN: ${{ github.token }}
11 changes: 11 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include README.md
include LICENSE
include MANIFEST.in
recursive-include avidtools *.py
recursive-exclude tests *
recursive-exclude .github *
exclude .gitignore
exclude .ruff_cache
exclude .pytest_cache
exclude .mypy_cache
exclude *.egg-info
Loading