Skip to content

Commit

Permalink
publish helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
smatting committed Jan 22, 2024
1 parent 8f74324 commit c888211
Show file tree
Hide file tree
Showing 3 changed files with 561 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/test_build_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,40 @@ jobs:
echo "image_tag=$(cat ./tag.txt)" >> $GITHUB_OUTPUT
echo "Pushed also unique docker tag $image_tag"
- uses: azure/setup-helm@v3
with:
version: '3.12.2'
id: install

- name: Publish Helm chart
shell: bash
id: publish_helm_chart
env:
AWS_ACCESS_KEY_ID: ${{ secrets.CHARTS_WEBAPP_AUTOMATION_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CHARTS_WEBAPP_AUTOMATION_AWS_SECRET_ACCESS_KEY }}
run: |
set -eo pipefail
image_tag="${{steps.push_docker_image.outputs.image_tag}}"
helm plugin install https://github.com/hypnoglow/helm-s3.git --version 0.15.1
helm repo add charts-webapp s3://public.wire.com/charts-webapp
if [ "$TAG" != "" ]; then
chart_version="$(./bin/chart-next-version.sh release)"
else
chart_version="$(./bin/chart-next-version.sh prerelease)"
fi
echo "chart_version=$chart_version" >> $GITHUB_OUTPUT
chart_patched="$(yq -Mr ".version = \"$chart_version\" | .appVersion = \"$image_tag\"" ./charts/account-pages/Chart.yaml)"
echo "$chart_patched" > ./charts/account-pages/Chart.yaml
helm package ./charts/account-pages
helm s3 push account-pages-*.tgz charts-webapp
- name: Create GitHub release
id: create_release
if: env.TAG != '' && matrix.DISTRIBUTION == 'DISTRIBUTION_0'
Expand Down
79 changes: 79 additions & 0 deletions bin/chart-next-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env bash
# Wire
# Copyright (C) 2020 Wire Swiss GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.


#
# This scripts determines the latest published release or prelease version
# of the sftd helm chart returns a semver bump of it on stdout.
#
# If the version in the helm chart source in ./charts/sftd/Chart.yaml
# is greater than the published version it is used in place of the latest
# published version.
#
# Usage: ./bin/chart-next-version.sh <prerelease|release>

set -eo pipefail

readonly bump_type=${1:?"Please specify bump type \"prerelease\" or \"release\""}

# search latest version in helm repo
if [ "$bump_type" = "prerelease" ]; then
search_args="--devel"
else
if [ "$bump_type" = "release" ]; then
search_args=""
else
echo 1>&2 "Unknown bump_type $bump_type provided"
exit 1
fi
fi
res=$(helm search repo charts-webapp/account-pages $search_args)
if [ "$res" == "No results found" ]; then
echo 1>&2 "Unexpected: no charts found"
exit 1
else
version_latest=$(sed -nE '2{s/[^ \t]+[ \t]+([^ \t]+).*/\1/p}' <<< "$res")
if [ "$(./bin/semver validate "$version_latest")" != "valid" ]; then
echo 1>&2 "Could not determine version"
exit 1
fi
fi

# is hardcoded bigger? if yes then use it instead
version_src=$(yq -Mr '.version' ./charts/account-pages/Chart.yaml)
if [ "$(./bin/semver compare "$version_src" "$version_latest")" = "1" ]; then
echo 1>&2 "Harcoded version $version_src is newer than $version_latest, so using $version_src"
version_latest="$version_src"
fi

echo 1>&2 "version_latest: $version_latest"

if [ "$bump_type" = "prerelease" ]; then
if [ "$(./bin/semver get prerelease "$version_latest")" = "" ]; then
# this is a first prelease
# so let's create a new release (bump minor)
# and create a first prerelease for it
version_next=$(./bin/semver bump minor "$version_latest")
version_new=$(./bin/semver bump prerelease pre.1 "$version_next")
else
version_new=$(./bin/semver bump prerelease "$version_latest")
fi
else
version_new=$(./bin/semver bump minor "$version_latest")
fi

echo "$version_new"
Loading

0 comments on commit c888211

Please sign in to comment.