name: Release Build

on:
  push:
    tags: ["v*"]
  workflow_dispatch:

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always
  BINARY_NAME: mhws-tex-decompressor

jobs:
  build:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: x86_64-pc-windows-msvc

      - name: Build
        run: cargo build --verbose --release

      - name: Prepare release package
        run: |
          mkdir release
          copy target/release/${{ env.BINARY_NAME }}.exe release/

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ env.BINARY_NAME }}-windows-x64
          path: release/

      - name: Create Release
        uses: softprops/action-gh-release@v2
        if: github.ref_type == 'tag'
        with:
          draft: true
          files: release/*
          name: Release ${{ github.ref_name }}
          body: |
            ## ${{ github.ref_name }}

            ### Changes
            - Please fill in the changes
