name: Cross compile wireguard-tools

on:
  workflow_dispatch:

jobs:
  builds-for-windows:
    runs-on: ubuntu-20.04
    steps:
      - name: clone repository
        run: |
          git clone https://git.zx2c4.com/wireguard-tools
          cd wireguard-tools
      - name: setup Deno
        uses: denoland/setup-deno@v1.1.0
        with:
          deno-version: canary
      - name: create build directory
        run: mkdir build
      - name: compile binary for windows
        run: deno compile --allow-read --allow-write --allow-run --allow-env --unstable --target x86_64-pc-windows-msvc --output ./build/wg-quick ./src/wg-quick.ts
      - uses: actions/upload-artifact@v2
        with:
          name: wg-quick
          path: build/wg-quick.exe
          
      - name: Release binaries 
        uses: softprops/action-gh-release@v1
        with:
          tag_name: wireguard-tools
          files: ./build/wg-quick*
        env:
          GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
