Skip to content

Release Charts

Release Charts #129

Workflow file for this run

name: Release Charts
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
release_tag:
type: string
description: "release tag that should be used for this release"
required: true
default: "1.0.5-nightly"
overwrite_existing_release_assets_if_applicable:
type: boolean
description: "Should Overwrite Existing Release Assets, if applicable"
required: false
default: false
helm_merge_with_existing_indexes:
type: boolean
description: "Should Merge Helm Index with Existing Indexes from index.yaml, if applicable"
required: false
default: true
prerelease:
type: boolean
description: "should this release be marked as pre-release"
required: false
default: true
permissions:
contents: write
id-token: write
pages: write
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
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v3
- name: Setup Pages
uses: actions/configure-pages@v3
- uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Installing yq (with pip)
run: |+
pip install yq
- name: Add repositories
run: |
for dir in $(ls -d charts/*); do
pushd $dir
helm dependency list 2> /dev/null | tail +2 | head -n -1 | awk '{ print "helm repo add " $1 " " $3 }' | while read cmd; do $cmd; done
helm dependency update
popd
done
- name: Setting up Chart Releaser
run: |+
curl -L0 https://github.com/helm/chart-releaser/releases/download/v1.5.0/chart-releaser_1.5.0_linux_amd64.tar.gz > /tmp/chart-releaser.tar.gz && tar xf /tmp/chart-releaser.tar.gz -C /tmp && mv /tmp/cr /usr/local/bin/cr
- name: Installing Github Cli
run: |+
curl -L0 https://github.com/cli/cli/releases/download/v2.29.0/gh_2.29.0_linux_amd64.tar.gz > /tmp/gh_2.29.0_linux_amd64.tar.gz && tar xf /tmp/gh_2.29.0_linux_amd64.tar.gz -C /tmp && mv /tmp/gh_2.29.0_linux_amd64/bin/gh /usr/local/bin/gh
- name: update version and appVersion in charts' Chart.yaml
run: |+
RELEASE_TAG=${{ github.event.inputs.release_tag }}
for dir in $(ls -d charts/*); do
pushd $dir
sed -i "s/^version:.*/version: $RELEASE_TAG/g" Chart.yaml
sed -i "s/^appVersion:.*/appVersion: $RELEASE_TAG/g" Chart.yaml
popd
done
- name: Releasing Helm Charts
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
RELEASE_TAG: ${{github.event.inputs.release_tag}}
PRE_RELEASE: ${{ github.event.inputs.prerelease }}
OVERWRITE_RELEASE_ASSETS: ${{ github.event.inputs.overwrite_existing_release_assets_if_applicable }}
HELM_MERGE_WITH_EXISTING_RELEASES: ${{ github.event.inputs.helm_merge_with_existing_indexes }}
RELEASE_TITLE: "kloudlite-helm-charts"
GITHUB_REPO_OWNER: ${{github.repository_owner}}
GITHUB_REPO_NAME: ${{github.event.repository.name}}
shell: bash
run: |+
bash scripts/release-script.sh
# - name: Releasing Helm Charts
# env:
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# shell: bash
# run: |+
# set -o allexport
#
# RELEASE_TAG=${{ github.event.inputs.release_tag }}
# PRE_RELEASE=${{ github.event.inputs.prerelease }}
# OVERWRITE_RELEASE_ASSETS=${{ github.event.inputs.overwrite_existing_release_assets_if_applicable }}
#
# HELM_MERGE_WITH_EXISTING_RELEASES=${{ github.event.inputs.helm_merge_with_existing_indexes }}
#
# RELEASE_TITLE="kloudlite-helm-charts"
#
# opts=("-R" "$GITHUB_REPOSITORY")
#
# release=$(gh release list ${opts[@]} | tail -n +1 | (grep -iE "\s+$RELEASE_TAG\s+" || echo -n "") | awk '{print $3}')
# if [[ -z $release ]]; then
# echo "going to create release, as RELEASE ($RELEASE_TAG) does not exist"
# createOpts=${opts[@]}
# if $PRE_RELEASE; then
# createOpts+=("--prerelease")
# fi
# if ! [[ -z $RELEASE_TITLE ]]; then
# createOpts+=("--title" "$RELEASE_TITLE")
# fi
# createOpts+=("--notes" "'$RELEASE_NOTES'")
#
# echo "creating github release with cmd: \`gh release create $RELEASE_TAG ${createOpts[@]}\` "
# eval gh release create $RELEASE_TAG ${createOpts[@]} --generate-notes
# else
# echo "release $release exists, going to build charts, now"
# fi
#
# tar_dir=".chart-releases"
#
# for dir in $(ls -d charts/*); do
# echo cr package $dir --package-path $tar_dir
# cr package $dir --package-path $tar_dir
# done
#
# uploadOpts=${opts[@]}
# if $OVERWRITE_RELEASE_ASSETS; then
# uploadOpts+=("--clobber")
# fi
#
# echo "uploading packaged helm-charts with cmd: \`gh release upload $RELEASE_TAG ${uploadOpts[@]} $tar_dir/*.tgz\`"
# eval gh release upload $RELEASE_TAG ${uploadOpts[@]} $tar_dir/*.tgz
#
# ## updating CRDs
# for file in $(ls crds/*); do
# cat $file >> crds/crds-all.yml
# echo "---" >> crds/crds-all.yml
# done
#
# gh release upload $RELEASE_TAG ${uploadOpts[@]} crds/*.yml
#
# if $HELM_MERGE_WITH_EXISTING_RELEASES; then
# # remove entries related to the current release_tag, for all the charts
# index_file_url="https://${{github.repository_owner}}.github.io/${{github.event.repository.name}}/index.yaml"
# curl -f -L0 $index_file_url | yq -y > $tar_dir/index.yaml
# echo "+++++++ current: index.yaml"
# cat $tar_dir/index.yaml
#
# for dir in $(ls -d charts/*); do
# export CHART_NAME=$(basename $dir)
#
# cat $tar_dir/index.yaml | yq '. | .entries[env.CHART_NAME] = (.entries[env.CHART_NAME] | map_values(select( (. != null) and (.appVersion != env.RELEASE_TAG) )))' -y > /tmp/index2.yaml
#
# mv /tmp/index2.yaml $tar_dir/index.yaml
# done
# fi
#
# echo "++++++ modified index.yaml"
# cat $tar_dir/index.yaml
#
# helm repo index $tar_dir --url https://github.com/$GITHUB_REPOSITORY/releases/download/$RELEASE_TAG --merge $tar_dir/index.yaml
#
# echo "+++++++ new: index.yaml"
# cat $tar_dir/index.yaml
#
# mkdir -p .static-pages
# cp $tar_dir/index.yaml .static-pages/index.yaml
# gh release upload $RELEASE_TAG ${uploadOpts[@]} .static-pages/index.yaml
#
# cat > .static-pages/index.html <<EOF
# <html>
# <head>
# <title>Kloudlite Helm Charts</title>
# </head>
#
# <body>
# <p>Hi, the file you are looking for is located <a href="${index_file_url}">here</a>.</p>
# </body>
# </html>
# EOF
# gh release upload $RELEASE_TAG ${uploadOpts[@]} .static-pages/index.html
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
name: github-pages
path: .static-pages
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: release
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2