name: MoviePilot Release
on:
  workflow_dispatch:
  push:
    branches:
      - main
    paths:
      - version.py

jobs:
  build:
    runs-on: ubuntu-latest
    name: Build Docker Image
    steps:
      -
        name: Checkout
        uses: actions/checkout@v3

      -
        name: Release Version
        id: release_version
        run: |
          app_version=$(cat version.py |sed -ne "s/APP_VERSION\s=\s'v\(.*\)'/\1/gp")
          echo "app_version=$app_version" >> $GITHUB_ENV

      -
        name: Generate Release
        uses: actions/create-release@latest
        with:
          tag_name: v${{ env.app_version }}
          release_name: v${{ env.app_version }}
          body: |
            ${{ github.event.commits[0].message }}
          draft: false
          prerelease: false
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
