Files
AudioBookRequest/.github/workflows/build.yaml
T
2025-04-09 08:16:49 +02:00

97 lines
2.7 KiB
YAML

name: Type check and Build
on:
push:
paths:
- "**.py"
- "**.html"
- "**.css"
- "**.yaml"
- "Dockerfile"
pull_request:
paths:
- "**.py"
- "**.html"
- "**.css"
- "**.yaml"
- "Dockerfile"
release:
types: [created]
jobs:
test:
name: Test types
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.9"
- name: Install sqlite3
run: |
sudo apt-get update
sudo apt-get install -y sqlite3
- run: uv sync --all-extras --dev
- run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
- uses: jakebailey/pyright-action@v2
with:
extra-args: app # only check apps dir
- name: Check Alembic Migrations
run: |
uv run alembic upgrade heads
uv run alembic check
build:
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Determine tags
id: vars
run: |
if [ "${{ github.event_name }}" == "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
MAJOR=$(echo $VERSION | cut -d. -f1)
MINOR=$(echo $VERSION | cut -d. -f2)
PATCH=$(echo $VERSION | cut -d. -f3)
echo "::set-output name=tags::${{ secrets.DOCKER_HUB_USERNAME }}/audiobookrequest:$VERSION,${{ secrets.DOCKER_HUB_USERNAME }}/audiobookrequest:$MAJOR.$MINOR,${{ secrets.DOCKER_HUB_USERNAME }}/audiobookrequest:$MAJOR,${{ secrets.DOCKER_HUB_USERNAME }}/audiobookrequest:latest"
echo "::set-output name=version::$VERSION"
else
echo "::set-output name=tags::${{ secrets.DOCKER_HUB_USERNAME }}/audiobookrequest:nightly"
github_sha_hash=${{ github.sha }}
echo "::set-output name=version::nightly:${github_sha_hash:0:7}"
fi
- name: Build and push
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.vars.outputs.tags }}
build-args: |
VERSION=${{ steps.vars.outputs.version }}