Skip to content

Commit

Permalink
build: relies on versioning in the Charts.yaml to make chart-releaser…
Browse files Browse the repository at this point in the history
… happy
  • Loading branch information
NitriKx committed Feb 2, 2023
1 parent 6e558fe commit 05851e2
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Goreleaser
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+-bm"
- "[0-9]+\\.[0-9]+\\.[0-9]+-bm"
env:
GO_VERSION: 1.19.2
jobs:
Expand Down
138 changes: 71 additions & 67 deletions .github/workflows/helm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Helm chart
on:
push:
branches:
- master
tags:
- "chart/**/[0-9]+.[0-9]+.[0-9]+\\+bm"
- "chart/**/[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+\\+bm"
- main-bm
# tags:
# - "chart/**/[0-9]+.[0-9]+.[0-9]+"
# - "chart/**/[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+"
pull_request:

env:
Expand All @@ -29,22 +29,22 @@ jobs:
with:
version: ${{ env.HELM_VERSION }}

- name: Add Helm repositories
run: |
helm repo add incubator https://charts.helm.sh/incubator
helm repo add chartmuseum https://kubernetes-charts.banzaicloud.com
- name: Update Helm repositories
run: |
helm repo update
helm repo list
- name: Update Helm dependencies
run: |
find -H 'charts/' \
-maxdepth 2 \
-name 'Chart.yaml' \
-execdir helm dependency update \;
#- name: Add Helm repositories
# run: |
# helm repo add incubator https://charts.helm.sh/incubator
# helm repo add chartmuseum https://kubernetes-charts.banzaicloud.com
#
#- name: Update Helm repositories
# run: |
# helm repo update
# helm repo list
#
#- name: Update Helm dependencies
# run: |
# find -H 'charts/' \
# -maxdepth 2 \
# -name 'Chart.yaml' \
# -execdir helm dependency update \;

- name: Lint Helm charts
run: |
Expand All @@ -54,35 +54,35 @@ jobs:
-printf '%h\n' \
| xargs helm lint
- name: Set Git refname
id: set-git-refname
run: |
GIT_REFNAME="$(echo "${{ github.ref }}" | sed -r 's@refs/(heads|pull|tags)/@@g')"
echo "GIT_REFNAME=${GIT_REFNAME}"
echo "git_refname=${GIT_REFNAME}" >> $GITHUB_OUTPUT
- name: Set Helm push enabled
id: set-helm-push-enabled
run: |
HELM_PUSH_ENABLED=""
if [ "${{ github.event_name }}" == "push" ] && echo "${{ steps.set-git-refname.outputs.git_refname }}" | grep -E -q "^(chart/)?[^/]+/[0-9]+.[0-9]+.[0-9]+(?:-dev.[0-9]+)?"; then
HELM_PUSH_ENABLED=1
else
printf >&2 "Unstable chart (%s) from %s event, chart will not be pushed" "${{ steps.set-git-refname.outputs.git_refname }}" "${{ github.event_name }}"
fi
echo "HELM_PUSH_ENABLED=${HELM_PUSH_ENABLED}"
echo "helm_push_enabled=${HELM_PUSH_ENABLED}" >> $GITHUB_OUTPUT
- if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }}
name: Set chart name
id: set-chart-name
run: |
CHART_NAME="$(echo "${{ steps.set-git-refname.outputs.git_refname }}}" | awk -F '/' '{print $(NF-1)}')"
echo "CHART_NAME=${CHART_NAME}"
echo "chart_name=${CHART_NAME}" >> $GITHUB_OUTPUT
# - name: Set Git refname
# id: set-git-refname
# run: |
# GIT_REFNAME="$(echo "${{ github.ref }}" | sed -r 's@refs/(heads|pull|tags)/@@g')"
#
# echo "GIT_REFNAME=${GIT_REFNAME}"
# echo "git_refname=${GIT_REFNAME}" >> $GITHUB_OUTPUT
#
# - name: Set Helm push enabled
# id: set-helm-push-enabled
# run: |
# HELM_PUSH_ENABLED=""
# if [ "${{ github.event_name }}" == "push" ] && echo "${{ steps.set-git-refname.outputs.git_refname }}" | grep -E -q "^(chart/)?[^/]+/[0-9]+.[0-9]+.[0-9]+(?:-dev.[0-9]+)?"; then
# HELM_PUSH_ENABLED=1
# else
# printf >&2 "Unstable chart (%s) from %s event, chart will not be pushed" "${{ steps.set-git-refname.outputs.git_refname }}" "${{ github.event_name }}"
# fi
#
# echo "HELM_PUSH_ENABLED=${HELM_PUSH_ENABLED}"
# echo "helm_push_enabled=${HELM_PUSH_ENABLED}" >> $GITHUB_OUTPUT
#
# - if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }}
# name: Set chart name
# id: set-chart-name
# run: |
# CHART_NAME="$(echo "${{ steps.set-git-refname.outputs.git_refname }}}" | awk -F '/' '{print $(NF-1)}')"
#
# echo "CHART_NAME=${CHART_NAME}"
# echo "chart_name=${CHART_NAME}" >> $GITHUB_OUTPUT

#- if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }}
# name: Package Helm chart
Expand All @@ -94,22 +94,22 @@ jobs:
# echo "HELM_PACKAGE_PATH=${HELM_PACKAGE_PATH}"
# echo "helm_package_path=${HELM_PACKAGE_PATH}" >> $GITHUB_OUTPUT

- if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }}
name: Check Helm chart version in repository
run: |
CHART_PATH="${{ github.workspace }}/charts/${{ steps.set-chart-name.outputs.chart_name }}"
EXPECTED_CHART_VERSION="$(echo "${{ steps.set-git-refname.outputs.git_refname }}" | awk -F '/' '{print $NF}')" || exit 1
ACTUAL_CHART_VERSION="$(awk '/version: [0-9]+\.[0-9]+\.[0-9]+/ {print $2}' "${CHART_PATH}/Chart.yaml")" || exit 1
if [ "${EXPECTED_CHART_VERSION}" != "${ACTUAL_CHART_VERSION}" ]; then
printf >&2 "chart version mismatches, name: %s, expected version (from tag): %s, actual version (from chart): %s" "${{ steps.set-chart-name.outputs.chart_name }}" "${EXPECTED_CHART_VERSION}" "${ACTUAL_CHART_VERSION}"
exit 1
fi
if helm search repo "${{ env.HELM_PUSH_REPOSITORY_NAME }}/${{ steps.set-chart-name.outputs.chart_name }}" --version "${ACTUAL_CHART_VERSION}" --output json | jq --exit-status 'length > 0'; then
printf >&2 "chart version already exists in the repository, repository: %s, name: %s, version: %s" "${{ env.HELM_PUSH_REPOSITORY_NAME }}" "${{ steps.set-chart-name.outputs.chart_name }}" "${ACTUAL_CHART_VERSION}"
exit 1
fi
# - if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }}
# name: Check Helm chart version in repository
# run: |
# CHART_PATH="${{ github.workspace }}/charts/${{ steps.set-chart-name.outputs.chart_name }}"
# EXPECTED_CHART_VERSION="$(echo "${{ steps.set-git-refname.outputs.git_refname }}" | awk -F '/' '{print $NF}')" || exit 1
# ACTUAL_CHART_VERSION="$(awk '/version: [0-9]+\.[0-9]+\.[0-9]+/ {print $2}' "${CHART_PATH}/Chart.yaml")" || exit 1
#
# if [ "${EXPECTED_CHART_VERSION}" != "${ACTUAL_CHART_VERSION}" ]; then
# printf >&2 "chart version mismatches, name: %s, expected version (from tag): %s, actual version (from chart): %s" "${{ steps.set-chart-name.outputs.chart_name }}" "${EXPECTED_CHART_VERSION}" "${ACTUAL_CHART_VERSION}"
# exit 1
# fi
#
# if helm search repo "${{ env.HELM_PUSH_REPOSITORY_NAME }}/${{ steps.set-chart-name.outputs.chart_name }}" --version "${ACTUAL_CHART_VERSION}" --output json | jq --exit-status 'length > 0'; then
# printf >&2 "chart version already exists in the repository, repository: %s, name: %s, version: %s" "${{ env.HELM_PUSH_REPOSITORY_NAME }}" "${{ steps.set-chart-name.outputs.chart_name }}" "${ACTUAL_CHART_VERSION}"
# exit 1
# fi

# ORIGINAL CODE
# - if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }}
Expand All @@ -123,8 +123,12 @@ jobs:
# HELM_REPO_USERNAME: ${{ secrets.HELM_REPO_USERNAME }}
# run: helm push "${{ steps.package-chart.outputs.helm_package_path }}" "${{ env.HELM_PUSH_REPOSITORY_NAME }}"

- if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }}
name: Run chart-releaser
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.5.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
2 changes: 1 addition & 1 deletion charts/vault-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
type: application
name: vault-operator
version: 1.18.0+bm
version: 1.18.0-bm
appVersion: 1.18.0
description: A Helm chart for banzaicloud/bank-vaults Vault operator
icon: https://raw.githubusercontent.com/banzaicloud/bank-vaults/main/docs/images/logo/bank-vaults-logo.svg
Expand Down
2 changes: 1 addition & 1 deletion charts/vault-secrets-webhook/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
type: application
name: vault-secrets-webhook
version: 1.18.2+bm
version: 1.18.2-bm
appVersion: 1.18.0
description: A Helm chart that deploys a mutating admission webhook that configures applications to request secrets from Vault
icon: https://raw.githubusercontent.com/banzaicloud/bank-vaults/main/docs/images/logo/bank-vaults-logo.svg
Expand Down
2 changes: 1 addition & 1 deletion charts/vault/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
type: application
name: vault
version: 1.18.0+bm
version: 1.18.0-bm
appVersion: 1.18.0
description: A Helm chart for Vault, a tool for managing secrets
home: https://www.vaultproject.io/
Expand Down

0 comments on commit 05851e2

Please # to comment.