mirror of
https://github.com/markbeep/AudioBookRequest.git
synced 2026-04-27 03:49:59 -05:00
127 lines
3.6 KiB
YAML
127 lines
3.6 KiB
YAML
name: Type check and Build
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- "**.py"
|
|
- "**.html"
|
|
- "**.css"
|
|
- "**.yaml"
|
|
- "uv.lock"
|
|
- "package-lock.json"
|
|
- "Dockerfile"
|
|
release:
|
|
types: [created]
|
|
|
|
jobs:
|
|
test:
|
|
name: Test types
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres
|
|
env:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: postgres
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v5
|
|
with:
|
|
version: "0.8.22"
|
|
|
|
- name: Install sqlite3
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y sqlite3
|
|
|
|
- run: uv sync --all-extras
|
|
|
|
- run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
|
|
|
|
- uses: jakebailey/pyright-action@v2
|
|
with:
|
|
extra-args: app # only check apps dir
|
|
|
|
- name: Check SQLite Alembic Migrations
|
|
run: |
|
|
uv run alembic upgrade heads
|
|
uv run alembic check
|
|
uv run alembic downgrade base
|
|
uv run alembic upgrade heads
|
|
uv run alembic check
|
|
|
|
- name: Check PSQL Alembic Migrations
|
|
run: |
|
|
uv run alembic upgrade heads
|
|
uv run alembic check
|
|
uv run alembic downgrade base
|
|
uv run alembic upgrade heads
|
|
uv run alembic check
|
|
env:
|
|
ABR_DB__POSTGRES_HOST: localhost
|
|
ABR_DB__POSTGRES_PORT: 5432
|
|
ABR_DB__POSTGRES_USER: postgres
|
|
ABR_DB__POSTGRES_PASSWORD: postgres
|
|
ABR_DB__POSTGRES_DB: postgres
|
|
ABR_DB__USE_POSTGRES: true
|
|
|
|
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 }}"
|
|
# Remove leading 'v' if present
|
|
VERSION="${VERSION#v}"
|
|
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 }}
|