stages:
  - lint
  - build
  - upload

helm-lint:
  image: alpine/helm:3.11.2
  stage: lint
  script:
    - helm lint .

build-package:
  image: alpine/helm:3.11.2
  stage: build
  script:
    - helm package .
  artifacts:
    paths:
      - ${CI_PROJECT_NAME}-*.tgz

upload:
  image: curlimages/curl:latest
  stage: upload
  script:
    - PKG_NAME=$(ls ${CI_PROJECT_NAME}-*.tgz)
    - echo "Found ${PKG_NAME}"
    - curl --request POST
      --user gitlab-ci-token:$CI_JOB_TOKEN
      --form "chart=@${PKG_NAME}"
      "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/api/stable/charts"
  dependencies:
    - build-package
