stages:
  - build
  - release

variables:
  GOLANG_VERSION: "1.22"  # Adjust to the Go version you are using

build:
  image: golang:${GOLANG_VERSION}
  stage: build
  services:
    - docker
  before_script:
    - mkdir -p dist/
  script:
    - echo "Building for Windows"
    - GOOS=windows GOARCH=amd64 go build -o dist/falcon_windows.exe
    - echo "Building for macOS"
    - GOOS=darwin GOARCH=amd64 go build -o dist/falcon_mac
    - echo "Building for Linux"
    - GOOS=linux GOARCH=amd64 go build -o dist/falcon_linux
  artifacts:
    paths:
      - dist/

release:
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  stage: release
  script:
    - echo "Creating a release"
  release:
    name: "Release v${CI_COMMIT_TAG}"
    tag_name: "${CI_COMMIT_TAG}"
    description: "Release of falcon version for all platforms."
    assets:
      links:
        - name: "Download Windows version"
          url: "${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/dist/falcon_windows.exe"
        - name: "Download macOS version"
          url: "${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/dist/falcon_mac"
        - name: "Download Linux version"
          url: "${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/dist/falcon_linux"