-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt release pipeline for single chart releases and publish on GitHub (
#10)
- Loading branch information
Showing
6 changed files
with
120 additions
and
156 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,123 +1,39 @@ | ||
name: Helm chart | ||
|
||
name: Helm Continuous Integration | ||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- "**/[0-9]+.[0-9]+.[0-9]+" | ||
- "**/[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+" | ||
branches: "main" | ||
pull_request: | ||
|
||
env: | ||
HELM_PLUGIN_CHARTMUSEUM_PUSH_VERSION: 0.9.0 | ||
HELM_PUSH_REPOSITORY_NAME: chartmuseum | ||
HELM_VERSION: 3.1.1 | ||
HELM_VERSION: 3.12.1 | ||
PYTHON_VERSION: 3.11 | ||
|
||
jobs: | ||
helm: | ||
name: Helm | ||
runs-on: ubuntu-latest | ||
|
||
name: Chart Linting | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Check out code | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- uses: azure/setup-helm@v1 | ||
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 | ||
helm repo add banzaicloud-stable http://kubernetes-charts.banzaicloud.com/branch/master | ||
helm repo add rimusz https://charts.rimusz.net | ||
- name: Update Helm repositories | ||
run: | | ||
helm repo update | ||
helm repo list | ||
- name: Update Helm dependencies | ||
run: | | ||
find -H '.' \ | ||
-maxdepth 2 \ | ||
-name 'Chart.yaml' \ | ||
-execdir helm dependency update \; | ||
- name: Lint Helm charts | ||
run: | | ||
find -H '.' \ | ||
-maxdepth 2 \ | ||
-name 'Chart.yaml' \ | ||
-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]+"; 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 | ||
fetch-depth: 0 | ||
|
||
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 | ||
id: package-chart | ||
run: | | ||
HELM_PACKAGE_OUTPUT=$(helm package "${{ github.workspace }}/${{ steps.set-chart-name.outputs.chart_name }}") || exit 1 | ||
HELM_PACKAGE_PATH="${HELM_PACKAGE_OUTPUT##"Successfully packaged chart and saved it to: "}" | ||
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 }}/${{ 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 | ||
- name: Set up Helm | ||
uses: azure/[email protected] | ||
with: | ||
version: ${{ env.HELM_VERSION }} | ||
|
||
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 | ||
# Python is required because `ct lint` runs Yamale (https://github.com/23andMe/Yamale) and | ||
# yamllint (https://github.com/adrienverge/yamllint) which require Python | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }} | ||
name: Install Helm ChartMuseum push plugin | ||
run: helm plugin install "https://github.com/chartmuseum/helm-push.git" --version "${{ env.HELM_PLUGIN_CHARTMUSEUM_PUSH_VERSION }}" | ||
- name: Set up chart-testing | ||
uses: helm/[email protected] | ||
with: | ||
version: v3.9.0 | ||
|
||
- if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }} | ||
name: Push Helm chart | ||
env: | ||
HELM_REPO_PASSWORD: ${{ secrets.HELM_REPO_PASSWORD }} | ||
HELM_REPO_USERNAME: ${{ secrets.HELM_REPO_USERNAME }} | ||
run: helm push "${{ steps.package-chart.outputs.helm_package_path }}" "${{ env.HELM_PUSH_REPOSITORY_NAME }}" | ||
- name: Lint chart | ||
run: ct lint --all --config ct.yaml |
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,63 @@ | ||
name: Helm Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "**/[0-9]+.[0-9]+.[0-9]+" | ||
- "**/[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+" | ||
|
||
|
||
env: | ||
HELM_VERSION: 3.1.1 | ||
|
||
jobs: | ||
helm: | ||
name: Publish to Github Pages | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- uses: azure/setup-helm@v1 | ||
with: | ||
version: ${{ env.HELM_VERSION }} | ||
|
||
- name: Configure Git | ||
run: | | ||
git config user.name "$GITHUB_ACTOR" | ||
git config user.email "[email protected]" | ||
- 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 ::set-output name=git_refname::${GIT_REFNAME} | ||
- name: Check Git Tag consistency with Chart version | ||
run: | | ||
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}' "./charts/cadence/Chart.yaml")" || exit 1 | ||
if [ "${EXPECTED_CHART_VERSION}" != "${ACTUAL_CHART_VERSION}" ]; then | ||
printf >&2 "chart version mismatches, expected version (from tag): %s, actual version (from chart): %s" "${EXPECTED_CHART_VERSION}" "${ACTUAL_CHART_VERSION}" | ||
exit 1 | ||
fi | ||
- name: Checkout forked chart-releaser | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: edmondop/chart-releaser-action | ||
path: chart-releaser-action | ||
ref: ef58c21b3f93daff872ba384abd9cdb16e715334 | ||
|
||
- name: Run chart-releaser | ||
uses: ./chart-releaser-action | ||
env: | ||
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
|
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
Oops, something went wrong.