- test.yml: use uv venv instead of pip --break-system-packages - release.yml: inline test job that must pass before version bump; only triggers on source file changes (src/, src-tauri/, package.json) - sidecar-release.yml: inline Python test job that must pass before sidecar version bump - Both coordinators use `needs: test` so builds never start if tests fail Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
138 lines
5.1 KiB
YAML
138 lines
5.1 KiB
YAML
name: Sidecar Release
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- 'client/**'
|
|
- 'server/**'
|
|
- 'backend/**'
|
|
- 'pyproject.toml'
|
|
- 'local-transcription-headless.spec'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
test:
|
|
name: Run Tests
|
|
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
run: |
|
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
|
|
- name: Python tests
|
|
run: |
|
|
uv venv .testvenv
|
|
VIRTUAL_ENV=.testvenv uv pip install pytest httpx pytest-asyncio anyio fastapi pydantic pyyaml uvicorn requests
|
|
.testvenv/bin/python -m pytest backend/tests/ client/tests/ -v --tb=short
|
|
|
|
bump-sidecar-version:
|
|
name: Bump sidecar version and tag
|
|
needs: test
|
|
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version: ${{ steps.bump.outputs.version }}
|
|
tag: ${{ steps.bump.outputs.tag }}
|
|
has_changes: ${{ steps.check_changes.outputs.has_changes }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 2
|
|
|
|
- name: Check for backend changes
|
|
id: check_changes
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
echo "has_changes=true" >> $GITHUB_OUTPUT
|
|
exit 0
|
|
fi
|
|
CHANGED=$(git diff --name-only HEAD~1 HEAD -- client/ server/ backend/ pyproject.toml local-transcription-headless.spec 2>/dev/null || echo "")
|
|
if [ -n "$CHANGED" ]; then
|
|
echo "has_changes=true" >> $GITHUB_OUTPUT
|
|
echo "Backend changes detected: $CHANGED"
|
|
else
|
|
echo "has_changes=false" >> $GITHUB_OUTPUT
|
|
echo "No backend changes detected, skipping sidecar build"
|
|
fi
|
|
|
|
- name: Configure git
|
|
if: steps.check_changes.outputs.has_changes == 'true'
|
|
run: |
|
|
git config user.name "Gitea Actions"
|
|
git config user.email "actions@gitea.local"
|
|
|
|
- name: Bump sidecar patch version
|
|
if: steps.check_changes.outputs.has_changes == 'true'
|
|
id: bump
|
|
run: |
|
|
CURRENT=$(grep '^version = ' pyproject.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
|
|
echo "Current sidecar version: ${CURRENT}"
|
|
|
|
MAJOR=$(echo "${CURRENT}" | cut -d. -f1)
|
|
MINOR=$(echo "${CURRENT}" | cut -d. -f2)
|
|
PATCH=$(echo "${CURRENT}" | cut -d. -f3)
|
|
NEW_PATCH=$((PATCH + 1))
|
|
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
|
|
echo "New sidecar version: ${NEW_VERSION}"
|
|
|
|
sed -i "s/^version = \"${CURRENT}\"/version = \"${NEW_VERSION}\"/" pyproject.toml
|
|
|
|
echo "version=${NEW_VERSION}" >> $GITHUB_OUTPUT
|
|
echo "tag=sidecar-v${NEW_VERSION}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Commit and tag
|
|
if: steps.check_changes.outputs.has_changes == 'true'
|
|
env:
|
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
|
run: |
|
|
NEW_VERSION="${{ steps.bump.outputs.version }}"
|
|
TAG="${{ steps.bump.outputs.tag }}"
|
|
git add pyproject.toml
|
|
git commit -m "chore: bump sidecar version to ${NEW_VERSION} [skip ci]"
|
|
git tag "${TAG}"
|
|
|
|
REMOTE_URL=$(git remote get-url origin | sed "s|://|://gitea-actions:${BUILD_TOKEN}@|")
|
|
git pull --rebase "${REMOTE_URL}" main || true
|
|
git push "${REMOTE_URL}" HEAD:main
|
|
git push "${REMOTE_URL}" "${TAG}"
|
|
|
|
- name: Create Gitea release
|
|
if: steps.check_changes.outputs.has_changes == 'true'
|
|
env:
|
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
|
run: |
|
|
REPO_API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
|
TAG="${{ steps.bump.outputs.tag }}"
|
|
VERSION="${{ steps.bump.outputs.version }}"
|
|
RELEASE_NAME="Sidecar v${VERSION}"
|
|
|
|
curl -s -X POST \
|
|
-H "Authorization: token ${BUILD_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\": \"${TAG}\", \"name\": \"${RELEASE_NAME}\", \"body\": \"Automated sidecar build.\", \"draft\": false, \"prerelease\": false}" \
|
|
"${REPO_API}/releases"
|
|
echo "Created release: ${RELEASE_NAME}"
|
|
|
|
- name: Trigger per-OS sidecar builds
|
|
if: steps.check_changes.outputs.has_changes == 'true'
|
|
env:
|
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
|
run: |
|
|
REPO_API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
|
TAG="${{ steps.bump.outputs.tag }}"
|
|
|
|
for workflow in build-sidecar-linux.yml build-sidecar-windows.yml build-sidecar-macos.yml; do
|
|
echo "Dispatching ${workflow} for ${TAG}..."
|
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
|
|
-H "Authorization: token ${BUILD_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"ref\": \"main\", \"inputs\": {\"tag\": \"${TAG}\"}}" \
|
|
"${REPO_API}/actions/workflows/${workflow}/dispatches")
|
|
echo " -> HTTP ${HTTP_CODE}"
|
|
done
|