Skip to content

Instantly share code, notes, and snippets.

@janlauber
Created November 24, 2022 13:52
Show Gist options
  • Save janlauber/f8e93894ef35b81d2856c452a6809f80 to your computer and use it in GitHub Desktop.
Save janlauber/f8e93894ef35b81d2856c452a6809f80 to your computer and use it in GitHub Desktop.
Helm Release Script for Gitlab CI
#!/bin/bash
# build the helm charts
helm package ./charts/**
# for each .tgz file in the charts directory, create a release
for f in ./*.tgz
do
# get the chart name
chart_name=$(basename $f)
# upload the chart to the helm repo
curl --request POST \
--user gitlab-ci-token:$CI_JOB_TOKEN \
--form "chart=@${chart_name}" \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/api/stable/charts"
done
@janlauber
Copy link
Author

.gitlab-ci.yaml:

stages:
  - validate
  - release

helm-lint:
  stage: validate
  image: dtzar/helm-kubectl:3.5.3
  script:
    - helm lint charts/*

helm-release:
  stage: release
  image: dtzar/helm-kubectl:3.5.3
  script:
    - chmod +x ./scripts/helm-release.sh; ./scripts/helm-release.sh
  only:
    - tags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment