variables:
  NIXOS_VERSION: "23.11"
  NIXPKGS_ALLOW_UNFREE: "1"
  NIXPKGS_ALLOW_INSECURE: "1"
  GIT_DEPTH: 10

stages:
  - test
  - release
  - deploy 

before_script:
  - git config --global user.email "${GITLAB_USER_EMAIL}"
  - git config --global user.name "${GITLAB_USER_NAME}"
  - git config --global credential.helper '!f() { echo "username=gitlab-ci-token"; echo "password=${CI_JOB_TOKEN}"; }; f'
  - git config --global pull.rebase true
  - git config --global http.sslVerify "false"

after_script:
  - nix develop .#gitlab --command clean-up

#tests:
#  stage: test
#  tags:
#    - nixos-gen3
#  script:
#    -  nix develop .#gitlab --command run-ci-tests
#  cache:
#    untracked: true
#    key:
#      files:
#        - pnpm-lock.yaml
#    paths:
#      - node_modules/
#
#web-tests:
#  stage: test
#  tags:
#    - nixos-gen3
#  script:
#    -  nix develop .#gitlab --command run-ci-web-tests
#  cache:
#    untracked: true
#    key:
#      files:
#        - pnpm-lock.yaml
#    paths:
#      - node_modules/
#  artifacts:
#    paths:
#      - screenshot.png
#  rules:
#    - if: '$CI_COMMIT_TAG == null'

release:
  stage: release
  tags:
    - nixos-gen3
  script:
    - nix develop .#gitlab --command release
  when: on_success
  rules:
    - if: '$CI_COMMIT_TAG == null'

deploy:
  stage: deploy
  tags:
    - nixos-gen3
  script:
    - nix develop .#gitlab --command build-and-publish
  when: on_success
  rules:
    - if: '$CI_COMMIT_TAG != null'