include: "https://git.autistici.org/ai3/build-deb/raw/master/ci-nextstable.yml"

stages:
  - test
  - build_pkgsrc
  - build_pkg
  - upload_pkg

build_pkgsrc:bullseye:
  only:
    - master

build_pkg:bullseye:amd64:
  only:
    - master

test:
  stage: test
  image: registry.git.autistici.org/ai3/docker/test/golang:master
  script:
    - run-go-test ./...
  artifacts:
    when: always
    reports:
      cobertura: cover.xml
      junit: report.xml

release:
  stage: upload_pkg
  image: golang:1.15
  variables:
    VERSION: $CI_COMMIT_TAG
  script:
    - mkdir liber-${VERSION}
    - go build -o liber-${VERSION}/liber ./cmd/liber
    - tar czf liber-${VERSION}.tar.gz liber-${VERSION}
    - "curl --header 'JOB-TOKEN: $CI_JOB_TOKEN' --upload-file liber-${VERSION}.tar.gz ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/liber/${VERSION}/liber-${VERSION}.tar.gz"
  only:
    - tags

