chore(helm): bump up chart and app version #175
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
name: Release Helm Charts | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- charts/**/Chart.yaml | |
jobs: | |
release-helm-charts: | |
runs-on: ubuntu-latest | |
env: | |
HELM_CHART_REPO: instill-ai/helm-charts | |
HELM_CHART_REPO_BRANCH: main | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.botGitHubToken }} | |
- name: Install yq - portable yaml processor | |
uses: mikefarah/yq@v4 | |
- name: Collect charts | |
id: charts | |
run: | | |
set -e | |
find -L charts -mindepth 2 -maxdepth 2 -type f \( -name 'Chart.yaml' -o -name 'Chart.yml' \) -exec dirname "{}" \; \ | |
| sort -u \ | |
| sed -E 's/^/- /' \ | |
| yq --no-colors --indent 0 --output-format json '.' \ | |
| sed -E 's/^/charts=/' >> $GITHUB_OUTPUT | |
- name: Install chart releaser | |
run: | | |
set -e | |
arch="$(dpkg --print-architecture)" | |
curl -s https://api.github.com/repos/helm/chart-releaser/releases/latest \ | |
| yq --indent 0 --no-colors --input-format json --unwrapScalar \ | |
".assets[] | select(.name | test("\""^chart-releaser_.+_linux_${arch}\.tar\.gz$"\"")) | .browser_download_url" \ | |
| xargs curl -SsL \ | |
| tar zxf - -C /usr/local/bin | |
- name: Install Helm | |
uses: azure/setup-helm@v3 | |
with: | |
token: ${{ secrets.botGitHubToken }} | |
- name: Helm Dependencies | |
run: | | |
set -ex | |
echo '${{ steps.charts.outputs.charts }}' \ | |
| yq --indent 0 --no-colors --input-format json --unwrapScalar '.[]' \ | |
| while read -r dir; do | |
helm dependency update $dir; | |
if [ -f "$dir/Chart.lock" ]; then | |
yq --indent 0 \ | |
'.dependencies | map(["helm", "repo", "add", .name, .repository] | join(" ")) | .[]' \ | |
"$dir/Chart.lock" \ | |
| sh --; | |
fi | |
done | |
- name: Package charts | |
id: package | |
run: | | |
set -ex | |
PACKAGES=.cr-release-packages | |
echo '${{ steps.charts.outputs.charts }}' \ | |
| yq --indent 0 --no-colors --input-format json --unwrapScalar '.[]' \ | |
| xargs -d$'\n' cr package --package-path "$PACKAGES" | |
echo "dir=${PACKAGES}" >> $GITHUB_OUTPUT | |
- name: Checkout Helm chart repo | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ env.HELM_CHART_REPO }} | |
path: .helm-chart-repo | |
token: ${{ secrets.botGitHubToken }} | |
- name: Upload packages | |
working-directory: .helm-chart-repo | |
env: | |
GH_TOKEN: ${{ secrets.botGitHubToken }} | |
run: | | |
set -ex | |
repo=core | |
tag=$repo-$(yq -r '.version' ../charts/$repo/Chart.yaml) | |
gh release delete $tag --cleanup-tag --yes || true | |
sleep 1 | |
owner=$(cut -d '/' -f 1 <<< '${{ env.HELM_CHART_REPO }}') | |
repo=$(cut -d '/' -f 2 <<< '${{ env.HELM_CHART_REPO }}') | |
cr upload --git-repo "$repo" --owner "$owner" --token '${{ secrets.botGitHubToken }}' --package-path '../${{ steps.package.outputs.dir }}' --make-release-latest false | |
- name: Import GPG Key | |
uses: crazy-max/ghaction-import-gpg@v5 | |
with: | |
gpg_private_key: ${{ secrets.botGPGPrivateKey }} | |
passphrase: ${{ secrets.botGPGPassphrase }} | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
git_tag_gpgsign: true | |
workdir: .helm-chart-repo | |
- name: Update charts index | |
working-directory: .helm-chart-repo | |
run: | | |
set -ex | |
git config --local user.email "[email protected]" | |
git config --local user.name "droplet-bot" | |
owner=$(cut -d '/' -f 1 <<< '${{ env.HELM_CHART_REPO }}') | |
repo=$(cut -d '/' -f 2 <<< '${{ env.HELM_CHART_REPO }}') | |
cr index --git-repo "$repo" --owner "$owner" \ | |
--pages-branch '${{ env.HELM_CHART_REPO_BRANCH }}' \ | |
--package-path '../${{ steps.package.outputs.dir }}' \ | |
--index-path index.yaml --push | |
- name: Re-upload packages (re-tag) | |
working-directory: .helm-chart-repo | |
env: | |
GH_TOKEN: ${{ secrets.botGitHubToken }} | |
run: | | |
set -ex | |
repo=core | |
tag=$repo-$(yq -r '.version' ../charts/$repo/Chart.yaml) | |
gh release delete $tag --cleanup-tag --yes || true | |
sleep 1 | |
owner=$(cut -d '/' -f 1 <<< '${{ env.HELM_CHART_REPO }}') | |
repo=$(cut -d '/' -f 2 <<< '${{ env.HELM_CHART_REPO }}') | |
cr upload --git-repo "$repo" --owner "$owner" --token '${{ secrets.botGitHubToken }}' --package-path '../${{ steps.package.outputs.dir }}' --make-release-latest false |