Skip to content

Commit

Permalink
Merge pull request #67 from ccremer/helm-chart-integrate
Browse files Browse the repository at this point in the history
Migrate Helm chart to this Git repository
  • Loading branch information
ccremer authored Jul 23, 2022
2 parents 6bb1c3a + 8e22781 commit 5850483
Show file tree
Hide file tree
Showing 44 changed files with 2,098 additions and 45 deletions.
40 changes: 40 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Summary

* Short summary of what's included in the PR
* Give special note to breaking changes: List the exact changes or provide links to documentation.

## Checklist

<!--
Do *not* mix code changes with chart changes, it will break the release process.
Delete the checklist section that doesn't apply to the change.
-->

### For Code changes

- [ ] Categorize the PR by setting a good title and adding one of the labels:
`kind:bug`, `kind:enhancement`, `kind:documentation`, `kind:change`, `kind:breaking`, `kind:dependency`
as they show up in the changelog
- [ ] PR contains the label `area:provisioner`
- [ ] Link this PR to related issues
- [ ] I have not made _any_ changes in the `charts/` directory.

### For Helm Chart changes

- [ ] Categorize the PR by setting a good title and adding one of the labels:
`kind:bug`, `kind:enhancement`, `kind:documentation`, `kind:change`, `kind:breaking`, `kind:dependency`
as they show up in the changelog
- [ ] PR contains the label `area:chart`
- [ ] PR contains the chart label, e.g. `chart:kubernetes-zfs-provisioner`
- [ ] Variables are documented in the values.yaml using the format required by [Helm-Docs](https://github.com/norwoodj/helm-docs#valuesyaml-metadata).
- [ ] Chart Version bumped if immediate release after merging is planned
- [ ] I have run `make chart-docs`
- [ ] Link this PR to related code release or other issues.

<!--
Remove the section and checklist items that do not apply.
For completed items, change [ ] to [x].
NOTE: these things are not required to open a PR and can be done afterwards,
while the PR is open.
-->
54 changes: 54 additions & 0 deletions .github/changelog-charts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"pr_template": "- ${{TITLE}} (#${{NUMBER}})",
"categories": [
{
"title": "## 🚀 Features",
"labels": [
"kind:enhancement",
"area:chart"
],
"exhaustive": true
},
{
"title": "## 🛠️ Minor Changes",
"labels": [
"kind:change",
"area:chart"
],
"exhaustive": true
},
{
"title": "## 🔎 Breaking Changes",
"labels": [
"kind:breaking",
"area:chart"
],
"exhaustive": true
},
{
"title": "## 🐛 Fixes",
"labels": [
"kind:bug",
"area:chart"
],
"exhaustive": true
},
{
"title": "## 📄 Documentation",
"labels": [
"kind:documentation",
"area:chart"
],
"exhaustive": true
},
{
"title": "## 🔗 Dependency Updates",
"labels": [
"kind:dependency",
"area:chart"
],
"exhaustive": true
}
],
"template": "This release contains _only_ Helm chart changes\n\n${{CATEGORIZED_COUNT}} changes since ${{FROM_TAG}}\n\n${{CHANGELOG}}"
}
13 changes: 13 additions & 0 deletions .github/changelog-charts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -eo pipefail

chart="${1}"

tagPattern="${chart}-(.+)"
chartLabel="chart:${chart}"

echo ::group::Configuring changelog generator
jq '.tag_resolver.filter.pattern="'$tagPattern'" | .tag_resolver.transformer.pattern="'$tagPattern'" | .categories[].labels += ["'$chartLabel'"]' \
.github/changelog-charts.json | tee .github/configuration.json
echo ::endgroup::
24 changes: 18 additions & 6 deletions .github/changelog-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,39 @@
"categories": [
{
"title": "## 🚀 Features",
"labels": ["enhancement", "feature"]
"labels": [
"kind:enhancement"
]
},
{
"title": "## 🛠️ Minor Changes",
"labels": ["change"]
"labels": [
"kind:change"
]
},
{
"title": "## 🔎 Breaking Changes",
"labels": ["breaking"]
"labels": [
"kind:breaking"
]
},
{
"title": "## 🐛 Fixes",
"labels": ["bug", "fix"]
"labels": [
"kind:bug"
]
},
{
"title": "## 📄 Documentation",
"labels": ["documentation"]
"labels": [
"kind:documentation"
]
},
{
"title": "## 🔗 Dependency Updates",
"labels": ["dependency"]
"labels": [
"kind:dependency"
]
}
],
"template": "${{CATEGORIZED_COUNT}} changes since ${{FROM_TAG}}\n\n${{CHANGELOG}}"
Expand Down
4 changes: 4 additions & 0 deletions .github/helm-docs-footer.gotmpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

{{ template "chart.sourcesSection" . }}

{{ template "chart.requirementsSection" . }}
15 changes: 15 additions & 0 deletions .github/helm-docs-header.gotmpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{ template "chart.header" . }}
{{ template "chart.deprecationWarning" . }}

{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}

{{ template "chart.description" . }}

{{ template "chart.homepageLine" . }}

## Installation

```bash
helm repo add zfs-provisioner https://ccremer.github.io/kubernetes-zfs-provisioner
helm install {{ template "chart.name" . }} zfs-provisioner/{{ template "chart.name" . }}
```
3 changes: 0 additions & 3 deletions .github/release-footer.md

This file was deleted.

10 changes: 10 additions & 0 deletions .github/render-charts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -eo pipefail

chartYaml="${1}"
chartName=$(dirname "${chartYaml}")

echo "::group::Render chart ${chartName}"
helm template "${chartName}"
echo "::endgroup::"
19 changes: 7 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,24 @@ on:
- master

jobs:
dist:
docker:
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- uses: actions/checkout@v3

- name: Determine Go version from go.mod
run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
run: echo "GO_VERSION=$(go mod edit -json | jq -r .Go)" >> $GITHUB_ENV

- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- uses: goreleaser/goreleaser-action@v3
with:
args: release --snapshot
- name: Build
run: make build:docker
34 changes: 34 additions & 0 deletions .github/workflows/chart-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: ChartLint

on:
pull_request:
# only run when there are chart changes
paths:
- 'charts/**'
- '!charts/charts.mk'
- '!charts/go*'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3

- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Verify charts are upt-do-date
run: make chart-lint

template:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Render Helm charts
run: find charts -type f -name Chart.yaml -exec .github/render-charts.sh {} \;
81 changes: 81 additions & 0 deletions .github/workflows/chart-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: ChartRelease

on:
push:
tags:
- "[a-z0-9]+-*" # match tags following the 'chart-name-x.y.z'

jobs:
# Currently this job with changelog generator only works for the k8up chart...
# More charts (e.g. forks) may need additional engineering to get the changelog right.
gh-pages:
runs-on: ubuntu-latest
steps:
- name: Download cr
uses: giantswarm/[email protected]
with:
binary: cr
version: "1.4.0"
download_url: https://github.com/helm/chart-releaser/releases/download/v${version}/chart-releaser_${version}_linux_amd64.tar.gz
tarball_binary_path: "${binary}"
smoke_test: "${binary} version"

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: '0'

- uses: actions/setup-go@v3

- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Get chart name
run: echo "CHART_NAME=$(echo ${GITHUB_REF##*/} | grep --perl-regexp --only-matching '^([a-zA-Z0-9-]+)(?![0-9.]+)')" >> $GITHUB_ENV

- name: Get chart versions
run: |
echo "CHART_VERSION=$(yq e '.version' charts/${CHART_NAME}/Chart.yaml)" >> $GITHUB_ENV
echo "PREVIOUS_CHART_VERSION=$(git tag --sort=taggerdate --list "k8up-*" | tail -n 2 | head -n 1 | rev | cut -d - -f 1 | rev)" >> $GITHUB_ENV
- name: Prepare changelog config
run: .github/changelog-charts.sh ${CHART_NAME}

- name: Generate additional artifacts
run: make chart-prepare

- name: Package Helm chart
run: |
mkdir -p .cr-index
cr package charts/${CHART_NAME}
cr upload
cr index --push
env:
CR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CR_OWNER: ${{ github.repository_owner }}
CR_GIT_REPO: ${{ github.event.repository.name }}

- name: Build changelog from PRs with labels
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v3
with:
configuration: ".github/configuration.json"
ignorePreReleases: true
outputFile: .github/release-notes.md
fromTag: ${{ env.CHART_NAME }}-${{ env.PREVIOUS_CHART_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# there doesn't seem to be any maintained GitHub actions that allow uploading assets after release has been made.
- name: Update release
run: |
gh release upload ${CHART_NAME}-${CHART_VERSION} k8up-crd.yaml
gh release edit ${CHART_NAME}-${CHART_VERSION} --notes-file .github/release-notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/chart-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: ChartTest

on:
pull_request:
# only run when there are chart changes
paths:
- 'charts/**'

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3

- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run chart tests
run: make chart-test
6 changes: 5 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Determine Go version from go.mod
run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
run: echo "GO_VERSION=$(go mod edit -json | jq -r .Go)" >> $GITHUB_ENV

- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run linters
run: make lint
Loading

0 comments on commit 5850483

Please sign in to comment.