pipeline:
  dependencies:
    image: gitnet.fr/deblan/devenv
    commands:
      - make dep
    when:
      event: [tag, push, pull_request]
      branch: [master, develop, feature/*]

  build:
    image: gitnet.fr/deblan/devenv
    commands:
      - make build
    when:
      event: [push, pull_request]

  package:
    image: gitnet.fr/deblan/devenv
    volumes:
      - /var/www/html/artifacts:/var/www/html/artifacts
    secrets: [app_certificate]
    commands:
      - mkdir -p "$HOME/.nextcloud/certificates"
      - echo "$APP_CERTIFICATE" > "$HOME/.nextcloud/certificates/side_menu.key"
      - export VERSION=$(grep "<version>" appinfo/info.xml | grep -o "[0-9]*\.[0-9]*\.[0-9]*" --color=never)
      - export RELEASE_DIRECTORY="/var/www/html/artifacts/deblan/side_menu"
      - make release
    when:
      event: [tag]

  release:
    image: plugins/gitea-release
    volumes:
      - /var/www/html/artifacts:/var/www/html/artifacts
    settings:
      api_key:
        from_secret: gitnet_api_key
      base_url: https://gitnet.fr
      note: ${CI_COMMIT_MESSAGE}
      files: /var/www/html/artifacts/deblan/side_menu/${CI_COMMIT_TAG/v//}/*
    when:
      event: [tag]
