Skip to content

Commit

Permalink
add script to increment helm charts version (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
plaharanne authored Sep 22, 2022
1 parent 59baaa2 commit f83450d
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 7 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/publish-helm-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release Helm Charts

on:
push:
branches:
- master

jobs:
release:
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.8.2

- name: Add Helm repos
run: |
helm repo add crate-operator https://crate.github.io/crate-operator
- name: Run chart-releaser
uses: helm/[email protected]
with:
charts_dir: deploy/charts
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_GIT_REPO: crate-operator
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Unreleased

* Change AWS Loadbalancer to type NLB instead of CLASSIC.

* Added Helm Chart and ``Helm Chart Releaser`` GitHub action.

2.14.0 (2022-09-13)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion deploy/charts/crate-operator-crds/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
version: 2.14.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
10 changes: 9 additions & 1 deletion deploy/charts/crate-operator-crds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@ Once Helm is properly set up, install the chart.

### Install from local folder

```shell
```
helm install crate-operator-crds crate-operator-crds
```

### Install from repo

```
helm repo add crate-operator https://crate.github.io/crate-operator
helm search repo crate-operator
helm install crate-operator-crds crate-operator/crate-operator-crds
```

### Upgrading the Operator

```
Expand Down
4 changes: 2 additions & 2 deletions deploy/charts/crate-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
version: 2.14.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand All @@ -16,7 +16,7 @@ appVersion: "2.14.0"

dependencies:
- name: crate-operator-crds
version: "0.1.0"
version: 2.14.0
repository: "file://../crate-operator-crds"
condition: crate-operator-crds.enabled

Expand Down
10 changes: 9 additions & 1 deletion deploy/charts/crate-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,18 @@ Once Helm is properly set up, install the chart.

### Install from local folder

```shell
```
helm install crate-operator crate-operator
```

### Install from repo

```
helm repo add crate-operator https://crate.github.io/crate-operator
helm search repo crate-operator
helm install crate-operator crate-operator/crate-operator
```

#### Namespace

The operator is installed in the namespace `crate-operator`.
Expand Down
46 changes: 46 additions & 0 deletions devtools/bumpversion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Script to increment Helm chart version
#
# Usage:
# $ bumpversion.sh VERSION
#
# Example:
# $ bumpversion.sh 2.14.0

function print_error() {
echo -e "\033[31mERROR:\033[0m $1"
}

function print_info() {
echo -e "\033[32mINFO:\033[0m $1"
}

VERSION="$1"

git fetch origin > /dev/null
# get current branch
BRANCH=$(git branch | grep "^\*" | cut -d " " -f 2)
print_info "Current branch is '$BRANCH'."

if [ "$BRANCH" != "release/$VERSION" ]; then
print_error "You should be on a release branch."
print_error "Please start a new branch ``release/$VERSION``."
exit 1
fi

print_info "Incrementing crate-operator Helm Chart to version '$VERSION'"
# Chart version
sed -i "s/^version:.*$/version: $VERSION/" deploy/charts/crate-operator/Chart.yaml
# App version
sed -i "s/^appVersion:.*$/appVersion: \"$VERSION\"/" deploy/charts/crate-operator/Chart.yaml
# Dependency version
sed -i "s/^ version:.*$/ version: $VERSION/" deploy/charts/crate-operator/Chart.yaml


print_info "Incrementing crate-operator-crds Helm Chart to version '$VERSION'"
# Chart version
sed -i "s/^version:.*$/version: $VERSION/" deploy/charts/crate-operator-crds/Chart.yaml
# App version
sed -i "s/^appVersion:.*$/appVersion: \"$VERSION\"/" deploy/charts/crate-operator-crds/Chart.yaml


print_info "Done. ✨"
30 changes: 28 additions & 2 deletions docs/source/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,24 @@ For the following steps we assume the next version is going to be ``$VERSION``.
#. Next, go ahead and ensure the changelog ``CHANGES.rst`` is up to date.

#. Commit the changes to the ``CHANGES.rst``, push them to GitHub, and open a
#. Run ``./devtools/bumpversion.sh $VERSION`` to update version:

$ ./devtools/bumpversion.sh 2.14.1
INFO: Current branch is 'release/2.14.1'.
INFO: Incrementing crate-operator Helm Chart to version '2.14.1'
INFO: Incrementing crate-operator-crds Helm Chart to version '2.14.1'
INFO: Done. ✨

If you want to inspect the changes made, run ``git diff``.

#. Commit the changes to the ``CHANGES.rst``,
``deploy/charts/crate-operator/Chart.yaml`` and
``deploy/charts/crate-operator-crds/Chart.yaml``, push them to GitHub, and open a
pull request against the ``master`` branch:

.. code-block:: console
$ git add CHANGES.rst
$ git add CHANGES.rst deploy/charts/crate-operator/Chart.yaml deploy/charts/crate-operator-crds/Chart.yaml
$ git commit -m "Prepare release $VERSION"
$ git push --set-upstream origin "release/$VERSION"
Expand All @@ -237,6 +249,20 @@ For the following steps we assume the next version is going to be ``$VERSION``.
$ ./devtools/create_tag.sh "$VERSION"
Automatic Helm chart release
----------------------------

This GitHub repo uses the ``chart-releaser`` action that detects any
modification in the repo's charts during every push to ``master``.
The action creates the artifacts and the corresponding GitHub release, then
it updates the index.yaml in ``gh-pages`` branch, which is hosted on GitHub Pages.

For more details, see `Helm Chart Releaser`_.


.. _Helm Chart Releaser: https://github.com/marketplace/actions/helm-chart-releaser


General Tips
------------

Expand Down

0 comments on commit f83450d

Please sign in to comment.