kind: pipeline
type: docker
name: linux-amd64-taggedver

platform:
  arch: amd64
  os: linux

steps:
- name: build_golang
  image: golang
  commands:
  - cd dlserver
  - go mod download
  - go build .
  - CGO_ENABLED=0 GOOS=windows -ldflags -H=windowsgui go build -a -installsuffix cgo -o dlserver.exe .

- name: get_win_ffmpeg
  image: busybox
  commands:
  - mkdir -p tmp
  - cd tmp
  # local cache, local pls
  - echo "10.43.14.171 nextcloud.martyn.berlin" >> /etc/hosts
  # original url : wget http://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-4.3.1-essentials_build.zip
  - wget -O ffmpeg.zip https://nextcloud.martyn.berlin/s/WdHk8sfZ28JXqjH/download
  - unzip ffmpeg.zip

- name: get_win_ytdl
  image: busybox
  commands:
  - mkdir -p tmp
  - cd tmp
  - wget https://github.com/ytdl-org/youtube-dl/releases/download/2020.09.14/youtube-dl.exe

- name: build_godot_windows
  image: barichello/godot-ci:3.2.3
  commands:
  - cp dlserver/dlserver.exe godot/
  - cp tmp/ffmpeg-4.3.1-essentials_build/bin/ffmpeg.exe godot/
  - cp tmp/youtube-dl.exe godot/
  - cd godot/
  - mkdir -v -p build/windows
  - godot -v --export "win64" build/windows/asingcrow.exe
  - ls build/windows

- name: package
  image: alpine
  commands:
  - apk add --no-cache zip
  - cd godot/build/windows
  - zip asingcrow-release.zip asingcrow.exe asingcrow.pck

- name: release
  image: plugins/gitea-release
  settings:
    api_key: 
      from_secret: gitea_release_token
    base_url: https://git.martyn.berlin/
    files: 
    - godot/build/windows/asingcrow-release.zip
    title: Built in CI
    prerelease: true
  when:
    event: tag
