name: Build/release

on:
  push:
    tags:
      - "*"

jobs:
  release:
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        os: [macos-latest, windows-latest, ubuntu-latest]

    steps:
      - name: Check out Git repository
        uses: actions/checkout@v2

      - name: Install Node.js, NPM and Yarn
        uses: actions/setup-node@v2
        with:
          node-version: 16

      - name: Build/release macOS Electron app
        uses: samuelmeuli/action-electron-builder@v1
        if: runner.os == 'macOS'
        with:
          skip_build: true
          # GitHub token, automatically provided to the action
          # (No need to define this secret in the repo settings)
          github_token: ${{ secrets.github_token }}

          args: "--x64 --arm64"

          mac_certs: ${{ secrets.mac_certs }}
          mac_certs_password: ${{ secrets.mac_certs_password }}

          # If the commit is tagged with a version (e.g. "v1.0.0"),
          # release the app after building
          release: ${{ startsWith(github.ref, 'refs/tags/v') }}

      - name: Build/release Windows Electron app
        uses: samuelmeuli/action-electron-builder@v1
        if: runner.os == 'Windows'
        with:
          skip_build: true
          # GitHub token, automatically provided to the action
          # (No need to define this secret in the repo settings)
          github_token: ${{ secrets.github_token }}

          args: "--ia32 --x64 --arm64"

          mac_certs: ${{ secrets.mac_certs }}
          mac_certs_password: ${{ secrets.mac_certs_password }}

          # If the commit is tagged with a version (e.g. "v1.0.0"),
          # release the app after building
          release: ${{ startsWith(github.ref, 'refs/tags/v') }}

      - name: Build/release Linux Electron app
        uses: samuelmeuli/action-electron-builder@v1
        if: runner.os == 'Linux'
        with:
          skip_build: true
          # GitHub token, automatically provided to the action
          # (No need to define this secret in the repo settings)
          github_token: ${{ secrets.github_token }}

          args: "--linux appimage --x64 --arm64"

          # If the commit is tagged with a version (e.g. "v1.0.0"),
          # release the app after building
          release: ${{ startsWith(github.ref, 'refs/tags/v') }}
