Skip to content

Merge pull request #144 from gimlet-io/fix/unified-image-pull-secrets… #92

Merge pull request #144 from gimlet-io/fix/unified-image-pull-secrets…

Merge pull request #144 from gimlet-io/fix/unified-image-pull-secrets… #92

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract tag version
id: versioning
run: |
tag=${GITHUB_REF/refs\/tags\//}
tag=${tag#v}
echo ::set-output name=tag_version::$tag
- name: Extract chart version
id: chart_version
run: |
CHART_VERSION=$(cat charts/onechart/Chart.yaml | grep ^version:)
CHART_VERSION=${CHART_VERSION#version: }
echo $CHART_VERSION
echo ::set-output name=chart_version::$CHART_VERSION
CHART_VERSION=$(cat charts/cron-job/Chart.yaml | grep ^version:)
CHART_VERSION=${CHART_VERSION#version: }
echo $CHART_VERSION
echo ::set-output name=cron_job_chart_version::$CHART_VERSION
CHART_VERSION=$(cat charts/static-site/Chart.yaml | grep ^version:)
CHART_VERSION=${CHART_VERSION#version: }
echo $CHART_VERSION
echo ::set-output name=static_site_chart_version::$CHART_VERSION
- name: Ensure tag and chart version matches
run: |
echo "$TAG_VERSION"
echo "$CHART_VERSION"
echo "$CRON_JOB_CHART_VERSION"
if [ "$TAG_VERSION" != "$CHART_VERSION" ]
then
echo "Tag version does not match chart version"
exit 1
fi
if [ "$TAG_VERSION" != "$CRON_JOB_CHART_VERSION" ]
then
echo "Tag version does not match cron-job chart version"
exit 1
fi
env:
TAG_VERSION: ${{ steps.versioning.outputs.tag_version }}
CHART_VERSION: ${{ steps.chart_version.outputs.chart_version }}
CRON_JOB_CHART_VERSION: ${{ steps.chart_version.outputs.cron_job_chart_version }}
- name: Create a Release
uses: elgohr/Github-Release-Action@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
title: Release ${{ github.ref }}
- name: Publishing to the Helm repository
run: |
git config --global user.email "action@github.com"
git config --global user.name "Github Action"
git checkout master
make package
git add .
git commit -m "Publishing $TAG_VERSION to the Helm repository"
git push origin master
env:
TAG_VERSION: ${{ steps.versioning.outputs.tag_version }}
title: Release ${{ github.ref }}
- name: Publish to to GHCR
run: |
echo ${{ secrets.HELM_TOKEN }} | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin
helm push docs/onechart-${CHART_VERSION}.tgz oci://ghcr.io/gimlet-io
helm push docs/cron-job-${CHART_VERSION}.tgz oci://ghcr.io/gimlet-io
helm push docs/static-site-${STATIC_SITE_CHART_VERSION}.tgz oci://ghcr.io/gimlet-io
env:
CHART_VERSION: ${{ steps.chart_version.outputs.chart_version }}
STATIC_SITE_CHART_VERSION: ${{ steps.chart_version.outputs.static_site_chart_version }}
- name: Preparing the next release version
run: |
git config --global user.email "action@github.com"
git config --global user.name "Github Action"
git checkout master
without_major_version=${CHART_VERSION#*.}
without_patch_version=${without_major_version%.*}
increased_minor_version=$(($without_patch_version + 1))
major_version=${CHART_VERSION%%.*}
increased_version="$major_version.$increased_minor_version.0"
echo "The new version will be $increased_version"
sed -i "s/version: $CHART_VERSION/version: $increased_version/" charts/onechart/Chart.yaml
sed -i "s/version: $CHART_VERSION/version: $increased_version/" charts/cron-job/Chart.yaml
sed -i "s/version: $CHART_VERSION/version: $increased_version/" charts/static-site/Chart.yaml
git status
git add .
git commit -m "The next release version will be $increased_version"
git push origin master
env:
CHART_VERSION: ${{ steps.chart_version.outputs.chart_version }}