# Copyright 2022-2023 René Ferdinand Rivera Morell
# Use, modification, and distribution are subject to the
# Boost Software License, Version 1.0. (See accompanying file LICENSE.txt)

name: "Installer: Windows"

on:
  # Allow manual runs.
  workflow_dispatch:
  # Run on publishing of releases.
  release: { types: [published] }
  # And run on pushes, for main and release branches.
  push:
    branches: ["main", "release", "version/*"]
    paths-ignore:
      [
        ".circleci/**",
        ".cirrus.yml",
        ".drone.star",
        ".semaphore/**",
        ".travis.yml",
        "appveyor.yml",
        "azure-pipelines.yml",
        ".ci/azp-*.yml",
      ]

jobs:
  wix:
    strategy:
      matrix:
        include:
          - { name: "Windows: Wix", image: "" }
    name: ${{ matrix.name }}
    runs-on: "windows-latest"
    steps:
      - name: "Checkout"
        uses: actions/checkout@main
        with: { path: "b2" }
      - name: "Checkout"
        uses: actions/checkout@main
        with: { repository: "bfgroup/b2-pkg", path: "b2-pkg" }
      - name: "Install"
        run: |
          choco install vswhere
      - name: "Bootstrap"
        run: |
          cd "${{github.workspace}}/b2"
          ./bootstrap.bat
      - name: "Build"
        run: |
          $env:path += ';' + "${{github.workspace}}/b2"
          cd "${{github.workspace}}/b2-pkg"
          b2 --debug-configuration --b2root="${{github.workspace}}/b2" -j1 -d+2 windows-wix
      - name: "Upload"
        uses: actions/upload-artifact@main
        with:
          name: installer
          path: "./b2-pkg/stage/*.msi*"
      - name: "Publish"
        uses: softprops/action-gh-release@master
        if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
        with:
          files: "./b2-pkg/stage/*.msi*"
