name: build

run-name: ${{ gitea.actor }} build MouseSoft Draw.IO Export

on:
  push:
    branches:
      - "**"

jobs:
  build:
    runs-on: ubuntu-latest
    # container:
    #   image: git.mousesoft.ru/ms/gitea-runner-images:python-ubuntu-latest
    steps:
      - name: check-out repository code
        uses: https://gitea.com/actions/checkout@v4
        with:
          fetch-depth: 0
          fetch-tags: true

      - name: set-up go
        uses: https://gitea.com/actions/setup-go@v3
        with:
          go-version: ">=1.22"

      - name: test
        run: make clean vendor lint test

      - name: cache
        uses: https://gitea.com/actions/cache@v4
        with:
          path: |
            out/*.tar.gz
          key: ms_drawio-export_${{ github.sha }}

      - name: build amd64 binary
        if: steps.cache.outputs.cache-hit != 'true'
        run: GOARCH=amd64 make clean build

      - name: upload amd64 binary artifact
        uses: https://gitea.com/actions/upload-artifact@v3
        with:
          name: drawio-export-amd64
          path: out/bin/*
          overwrite: true

      - name: build arm64 binary
        if: steps.cache.outputs.cache-hit != 'true'
        run: GOARCH=arm64 make clean build

      - name: upload arm64 binary artifact
        uses: https://gitea.com/actions/upload-artifact@v3
        with:
          name: drawio-export-arm64
          path: out/bin/*
          overwrite: true
