name: FModel Builder

on:
  workflow_dispatch:
    inputs:
        appVersion:
          description: 'FModel Version And Release Tag'
          required: true
          default: '4.0.X.X'

jobs:
  build:
    runs-on: windows-latest

    steps:
      - name: GIT Checkout
        uses: actions/checkout@v2
        with:
          submodules: 'true'

      - name: Fetch Submodules Recursively
        run: git submodule update --init --recursive

      - name: .NET 6 Setup
        uses: actions/setup-dotnet@v2
        with:
          dotnet-version: '6.0.x'

      - name: .NET Restore
        run: dotnet restore FModel

      - name: .NET Publish
        run: dotnet publish FModel -c Release --no-self-contained -r win-x64 -f net6.0-windows -o "./FModel/bin/Publish/" -p:PublishReadyToRun=false -p:PublishSingleFile=true -p:DebugType=None -p:GenerateDocumentationFile=false -p:DebugSymbols=false -p:AssemblyVersion=${{ github.event.inputs.appVersion }} -p:FileVersion=${{ github.event.inputs.appVersion }}

      - name: ZIP File
        uses: papeloto/action-zip@v1
        with:
          files: ./FModel/bin/Publish/FModel.exe
          dest: FModel.zip # will end up in working directory not the Publish folder

      - name: GIT Release
        uses: marvinpinto/action-automatic-releases@latest
        with:
          title: "FModel v${{ github.event.inputs.appVersion }}"
          automatic_release_tag: ${{ github.event.inputs.appVersion }}
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          prerelease: false
          files: FModel.zip
