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
39 changes: 39 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Code Quality

on:
push:
branches: [ main, master, develop ]
pull_request:
branches: [ main, master, develop ]

jobs:
code-quality:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.13"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install UV
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Install dependencies
run: |
uv sync --extra dev

- name: Run Ruff (Linting)
run: |
uv run ruff check .

- name: Run Ruff (Format Check)
run: |
uv run ruff format --check .
56 changes: 56 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Pre-commit Checks

on:
push:
pull_request:

jobs:
pre-commit:
runs-on: ubuntu-latest
name: Code Quality Gate

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install UV
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Install dependencies
run: uv sync --extra dev

- name: Check Ruff linting
id: ruff-lint
run: |
echo "Running Ruff linting..."
if ! uv run ruff check .; then
echo "❌ Linting issues found!"
echo "Run 'uv run ruff check --fix .' to fix auto-fixable issues."
exit 1
else
echo "✅ No linting issues found!"
fi

- name: Check Ruff formatting
id: ruff-format
run: |
echo "Checking Ruff formatting..."
if ! uv run ruff format --check .; then
echo "❌ Format issues found!"
echo "Run 'uv run ruff format .' to fix formatting issues."
exit 1
else
echo "✅ Code format is correct!"
fi

- name: Success
if: success()
run: |
echo "🎉 All code quality checks passed!"
echo "Your code meets the quality standards."
159 changes: 159 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: Release Package

on:
workflow_dispatch:
inputs:
version_type:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
custom_version:
description: 'Custom version (optional, overrides version_type)'
required: false
type: string
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install UV
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Install dependencies
run: uv sync --extra dev

- name: Configure Git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"

- name: Get current version
id: current_version
run: |
CURRENT_VERSION=$(grep -E '^version = ' pyproject.toml | sed 's/version = "//' | sed 's/"//')
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Current version: $CURRENT_VERSION"

- name: Calculate new version
id: new_version
run: |
CURRENT_VERSION="${{ steps.current_version.outputs.current }}"

if [ -n "${{ github.event.inputs.custom_version }}" ]; then
NEW_VERSION="${{ github.event.inputs.custom_version }}"
echo "Using custom version: $NEW_VERSION"
elif [ "${{ github.event.inputs.version_type }}" = "major" ]; then
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{print $1+1".0.0"}')
elif [ "${{ github.event.inputs.version_type }}" = "minor" ]; then
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{print $1"."$2+1".0"}')
else
# patch (default)
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{print $1"."$2"."$3+1}')
fi

echo "new=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "New version: $NEW_VERSION"

- name: Update version in pyproject.toml
if: github.event_name == 'workflow_dispatch'
run: |
NEW_VERSION="${{ steps.new_version.outputs.new }}"
sed -i "s/version = \".*\"/version = \"$NEW_VERSION\"/" pyproject.toml
echo "Updated pyproject.toml with version $NEW_VERSION"

- name: Run pre-commit checks
run: |
echo "Running code quality checks..."
uv run ruff check .
uv run ruff format --check .

- name: Build package
run: |
echo "Building package..."
uv build

- name: Check package
run: |
echo "Checking built package..."
ls -la dist/
uv run python -m twine check dist/*

- name: Commit version bump
if: github.event_name == 'workflow_dispatch'
run: |
NEW_VERSION="${{ steps.new_version.outputs.new }}"
git add pyproject.toml uv.lock
git commit -m "Bump version to $NEW_VERSION" || echo "No changes to commit"
git tag "v$NEW_VERSION"
git push origin HEAD
git push origin "v$NEW_VERSION"

- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
echo "Publishing to PyPI..."
uv run python -m twine upload dist/*

- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event_name == 'workflow_dispatch' && format('v{0}', steps.new_version.outputs.new) || github.ref_name }}
release_name: Release ${{ github.event_name == 'workflow_dispatch' && steps.new_version.outputs.new || github.ref_name }}
body: |
## Changes in this Release

- Package version: ${{ github.event_name == 'workflow_dispatch' && steps.new_version.outputs.new || github.ref_name }}
- Built and published to PyPI

## Installation

```bash
pip install expert==${{ github.event_name == 'workflow_dispatch' && steps.new_version.outputs.new || github.ref_name }}
```

## Artifacts

The package has been published to PyPI and is available for installation.
draft: false
prerelease: false

- name: Upload Release Assets
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/
asset_name: expert-dist
asset_content_type: application/zip
Loading
Loading