diff --git a/.drone.yml b/.drone.yml index 2dfc1af..4f374e7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,21 +10,14 @@ steps: - name: step1 image: alpine commands: - - apk add perl git - - git show --name-only --pretty="format:" | grep '^charts' - - git show --name-only --pretty="format:" | grep '^charts' | perl -pe 's:^([^/]*?/[^/]*?)/.*:$1:' - - git show --name-only --pretty="format:" | grep '^charts' | perl -pe 's:^([^/]*?/[^/]*?)/.*:$1:' | sort | uniq - - var1=$(git show --name-only --pretty="format:") - - echo "$var1" - # - var2=$(git show --name-only --pretty="format:" | grep '^charts') - # - echo "$var2" - - var3=$(git show --name-only --pretty="format:" | grep '^charts' | perl -pe 's:^([^/]*?/[^/]*?)/.*:$1:') - - echo "$var3" - # - var4=$(git show --name-only --pretty="format:" | grep '^charts' | perl -pe 's:^([^/]*?/[^/]*?)/.*:$1:' | sort) - # - echo "$var4" - - changed_charts=$(git show --name-only --pretty="format:" | grep '^charts' | perl -pe 's:^([^/]*?/[^/]*?)/.*:$1:' | sort | uniq) - - echo "$changed_charts" - - echo "This is after" + - ls + - find build-tools + - find charts + - echo $SHELL + - ./build-tools/upload-new-versions.sh + environment: + GITEA_PASSWORD: + from_secret: gitea_password image_pull_secrets: - dockerconfigjson diff --git a/README.md b/README.md index 3876e4d..89bc52c 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,11 @@ $ curl --user : -X POST --upload-file ./.tgz https: ### Installation ```bash -$ helm repo add --username --password https://hostname.of.gitea/api/packages/scubbo/helm +$ helm repo add --username --password https://hostname.of.gitea/api/packages//helm $ helm install / ``` + +## Other links + +* [General documentation on repositories](https://helm.sh/docs/topics/chart_repository/) +* [Gitea's own documentation](https://docs.gitea.com/next/usage/packages/helm) \ No newline at end of file diff --git a/build-tools/upload-new-versions.sh b/build-tools/upload-new-versions.sh new file mode 100755 index 0000000..11bceae --- /dev/null +++ b/build-tools/upload-new-versions.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +set -x + +apk add git curl jq helm; +# Intentionally does not handle renames, which would begin with `R`. +changed_charts=$(git show --name-status --pretty="format:" | grep '^[MA]' | cut -f 2- | grep '^charts' | cut -d '/' -f 1,2 | sort | uniq); +echo "$changed_charts"; +current_versions=$(curl -s --user scubbo:$GITEA_PASSWORD https://gitea.scubbo.org/api/v1/packages/scubbo | jq -r '.[] | select(.type == "helm") | .name + "___" + .version'); +echo "$current_versions"; + +mkdir bundles; +for changed_chart in $changed_charts +do + echo "Operating on $changed_chart"; + # e.g. /Users/scubbo/Code/helm-charts/hello-world-0.1.1.tgz + output_location=$(helm package $changed_chart | rev | cut -d ' ' -f 1 | rev); + # e.g. hello-world-0.1.1 + file_metadata=$(echo $output_location | rev | cut -d '/' -f 1 | cut -c 5- | rev); + chart_name=$(echo $file_metadata | rev | cut -d '-' -f 2- | rev); + chart_version=$(echo $file_metadata | rev | cut -d '-' -f 1 | rev); + if [[ $(echo $current_versions | grep "$chart_name___$chart_version" | wc -l ) -eq 1 ]]; then + # I.e. if the current version in the repo is the same as what we're trying to push + # TODO - should we check that we're pushing a _newer_ version? + # TODO - does the API only show the current version, or all versions? + echo "Version clash ($chart_version) for $chart_name"; + exit 1; + else + # Move to a directory so we can upload later. Do this after checking all packages so there's no partial update + mv $output_location bundles/; + fi +done + +# All packages have been checked, no version conflicts - upload them all! +find bundles -type f -exec curl -s --user "scubbo:$GITEA_PASSWORD" -X POST --upload-file '{}' https://gitea.scubbo.org/api/packages/scubbo/helm/api/charts \; +rm -rf bundles; diff --git a/charts/hello-world/i-am-a-new-file b/charts/hello-world/i-am-a-new-file new file mode 100644 index 0000000..c41b746 --- /dev/null +++ b/charts/hello-world/i-am-a-new-file @@ -0,0 +1 @@ +I have content! diff --git a/charts/hello-world/new-file b/charts/hello-world/new-file deleted file mode 100644 index e69de29..0000000 diff --git a/charts/hello-world/new-new-file b/charts/hello-world/new-new-file deleted file mode 100644 index e69de29..0000000 diff --git a/charts/hello-world/new-new-new-file b/charts/hello-world/new-new-new-file deleted file mode 100644 index e69de29..0000000 diff --git a/charts/hello-world/newest-file b/charts/hello-world/newest-file deleted file mode 100644 index e69de29..0000000 diff --git a/charts/hello-world/sdf b/charts/hello-world/sdf deleted file mode 100644 index e69de29..0000000 diff --git a/charts/hello-world/sdfasfdasdf b/charts/hello-world/sdfasfdasdf deleted file mode 100644 index e69de29..0000000 diff --git a/charts/new-content/a-file-here b/charts/new-content/a-file-here deleted file mode 100644 index e69de29..0000000 diff --git a/charts/new-content/a-file-here-1 b/charts/new-content/a-file-here-1 deleted file mode 100644 index e69de29..0000000 diff --git a/charts/new-content/asddsdsd b/charts/new-content/asddsdsd deleted file mode 100644 index e69de29..0000000