-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trying a manual helm chart building approach instead
- Loading branch information
Showing
4 changed files
with
108 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,17 +40,19 @@ jobs: | |
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Install Helm | ||
uses: azure/setup-helm@v3 | ||
- name: Create Helm Chart | ||
run: make create-helmchart-release | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
version: latest | ||
args: release --release-notes=docs/release_notes/${{ steps.prep.outputs.VERSION }}.md --skip-validate | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Install Helm | ||
uses: azure/setup-helm@v3 | ||
- name: Run chart-releaser | ||
uses: helm/[email protected] | ||
env: | ||
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
CR_RELEASE_NAME_TEMPLATE: "helm-chart-{{ .Version }}" | ||
- name: Build and release the helm charts | ||
run: | | ||
helm registry login ghcr.io -u skarlso -p ${{ secrets.GITHUB_TOKEN }} | ||
helm package --version ${{ steps.prep.outputs.VERSION }} --app-version ${{ steps.prep.outputs.VERSION }} ./output/crd-bootstrap | ||
helm push ${{ github.event.repository.name }}-${{ steps.prep.outputs.VERSION }}.tgz oci://ghcr.io/skarlso/helm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/bin/bash | ||
|
||
CONTROLLER="${2}" | ||
|
||
check_dependency() { | ||
if ! command -v helm &> /dev/null | ||
then | ||
echo "Helm could not be found. Please install Helm to proceed." | ||
exit | ||
fi | ||
if ! command -v kustomize &> /dev/null | ||
then | ||
echo "kustomize could not be found. Please install kustomize to proceed." | ||
exit | ||
fi | ||
} | ||
|
||
create_helm_chart() { | ||
helm create "${1}/${CONTROLLER}" | ||
cd "${1}/${CONTROLLER}" || exit | ||
rm -r templates | ||
mkdir templates | ||
mkdir crds | ||
rm -r charts | ||
rm values.yaml | ||
cd ../helm_temp || exit | ||
|
||
case "${1}" in | ||
"helm" ) | ||
#mac | ||
split -p "^---$" "install.yaml" "helm_"; | ||
;; | ||
"output" ) | ||
#ubuntu | ||
csplit "install.yaml" "/^---$/" {*} --prefix "helm_" -q; | ||
;; | ||
* ) | ||
exit | ||
;; | ||
esac | ||
|
||
rm install.yaml | ||
# Move into crds & templates folders after renaming | ||
HELM_FILES=($(ls )) | ||
for input in "${HELM_FILES[@]}"; do | ||
FILENAME=$(cat "${input}" | grep '^ name: ' | head -1 | sed 's/name: //g' | sed 's/\./_/g' | sed 's/ //g') | ||
TYPE=$(cat "${input}" | grep '^kind: ' | head -1 | sed 's/kind: //g' | sed 's/\./_/g' | tr '[:upper:]' '[:lower:]' | sed 's/ //g') | ||
if grep -q "kind: CustomResourceDefinition" "${input}" ; then | ||
mv ${input} ../${CONTROLLER}/crds/${FILENAME}.yaml | ||
else | ||
mv ${input} ../${CONTROLLER}/templates/${TYPE}_${FILENAME}.yaml | ||
fi | ||
done | ||
cd .. | ||
rm -rf helm_temp | ||
} | ||
|
||
create_from_local_resource_manifests() { | ||
echo "Creating from local manifests in the repository" | ||
rm -rf helm | ||
mkdir -p helm | ||
mkdir -p "helm/helm_temp" | ||
kustomize build ./config/default > ./helm/helm_temp/install.yaml | ||
|
||
create_helm_chart "helm" | ||
} | ||
|
||
create_from_github_release() { | ||
echo "Creating from the release" | ||
mkdir -p "output/helm_temp" | ||
cp ./output/install.yaml ./output/helm_temp/install.yaml | ||
create_helm_chart "output" | ||
tar -czf helm_chart.tar.gz ${CONTROLLER} | ||
} | ||
|
||
check_dependency | ||
case "${1}" in | ||
"local" ) | ||
create_from_local_resource_manifests | ||
;; | ||
"release" ) | ||
create_from_github_release | ||
;; | ||
* ) | ||
echo -n "unknown" | ||
exit | ||
;; | ||
esac |