name: Test and Build on: push: tags: - 'v*.*.*' env: REGISTRY: git.prettyhefty.com IMAGE_NAME: bill/ffmpeg-worker jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install uv run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: Add uv to PATH run: echo "$HOME/.local/bin" >> $GITHUB_PATH - name: Set up Python run: $HOME/.local/bin/uv python install 3.12 - name: Install dependencies run: $HOME/.local/bin/uv sync - name: Install FFmpeg run: | if command -v ffmpeg &> /dev/null; then echo "FFmpeg already installed" elif command -v sudo &> /dev/null; then sudo apt-get update && sudo apt-get install -y ffmpeg else apt-get update && apt-get install -y ffmpeg fi - name: Run tests run: $HOME/.local/bin/uv run pytest tests/ -v --ignore=tests/test_integration.py build: needs: test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Extract version from tag id: version run: | VERSION=${GITHUB_REF#refs/tags/} echo "VERSION=$VERSION" >> $GITHUB_OUTPUT if [[ "$VERSION" == *-alpha* ]] || [[ "$VERSION" == *-beta* ]] || [[ "$VERSION" == *-rc* ]]; then echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT else echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT fi - name: Log in to Container Registry run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ env.REGISTRY }} -u ${{ gitea.actor }} --password-stdin - name: Build and push Docker image run: | docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }} . docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }} if [ "${{ steps.version.outputs.IS_PRERELEASE }}" = "false" ]; then docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest fi - name: List images run: docker images | grep ffmpeg-worker