variables:
  GIT_DEPTH: "1"

stages:
  - prepare
  - build
  - deploy

macOS_bin:
  stage: prepare
  tags:
    - linux
  artifacts:
    paths:
      - bin
  script:
    - wget -O - https://cdn01.moecube.com/ygopro-build-materials/mycard-mat/mycard-mat-macos.tar.gz | tar zxf -

windows_bin:
  stage: prepare
  tags:
    - linux
  artifacts:
    paths:
      - bin
  script:
    - wget -O - https://cdn01.moecube.com/ygopro-build-materials/mycard-mat/mycard-mat-windows.tar.gz | tar zxf -

windows:
  stage: build
  dependencies:
    - windows_bin
  tags:
    - vs
  variables:
    CSC_KEY_PASSWORD: $WINDOWS_CSC_KEY_PASSWORD
    CSC_LINK: $WINDOWS_CSC_LINK
  script:
    - npm ci
    - npm run dist:windows
    #- dir dist
  artifacts:
    paths:
      - dist/
linux:
  image: node:16
  stage: build
  tags:
    - linux
  script:
    - apt update ; apt -y install python3 build-essential git
    - npm ci
    - npm run dist
    #- ls -la dist
  artifacts:
    paths:
      - dist/
macOS:
  stage: build
  dependencies:
    - macOS_bin
  tags:
    - macOS
  variables:
    CSC_KEY_PASSWORD: $MACOS_CSC_KEY_PASSWORD
    CSC_LINK: $MACOS_CSC_LINK
    APPLE_ID: $MACOS_NOTARIZE_USERNAME
    APPLE_ID_PASSWORD: $MACOS_NOTARIZE_PASSWORD
    TEAM_SHORT_NAME: $MACOS_ASC_PROVIDER
  script: ./.ci/macos-build.sh
  artifacts:
    paths:
      - dist/

#macOS_notarize:
#  stage: deploy
#  dependencies:
#    - macOS
#  tags:
#    - macOS
#  script: ./.ci/macos-notarize.sh
#  only:
#    - tags

upload_to_minio:
  stage: deploy
  dependencies:
    - macOS
    - windows
    - linux
  tags:
    - linux
  script:
    - aws s3 --endpoint=https://minio.mycard.moe:9000 sync dist/ s3://mycard/downloads
  only:
    - tags
    #- v3
