From d436fe16456ba3c3c23e03ee8dc118fa942059ad Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Sat, 17 Apr 2021 13:28:00 +0200 Subject: [PATCH] Automating releases --- .github/workflows/release.yml | 94 +++++++++++++++++++++++++++++++++++ charts/onechart/Chart.yaml | 2 +- 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5441ef9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,94 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + + - name: Checkout main + uses: actions/checkout@v2 + 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 + + - name: Ensure tag and chart version matches + run: | + echo "Run ${{ steps.versioning.outputs.VERSION }}" + echo "${{ steps.chart_version.outputs.CHART_VERSION }}" + echo "$TAG_VERSION" + echo "$CHART_VERSION" + if [ "$TAG_VERSION" != "$CHART_VERSION" ] + then + echo "Tag version does not match chart version" + exit 1 + fi + env: + TAG_VERSION: ${{ steps.versioning.outputs.tag_version }} + CHART_VERSION: ${{ steps.chart_version.outputs.chart_version }} + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + + - name: Publishing to the Helm repository + run: | + git config --global user.email "action@github.com" + git config --global user.name "Github Action" + git checkout release-automation + + make package + + git add . + git commit -m "Publishing $TAG_VERSION to the Helm repository" + git push origin release-automation + env: + TAG_VERSION: ${{ steps.versioning.outputs.tag_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 release-automation + + 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 + + git status + git add . + git commit -m "The next release version will be $increased_version" + git push origin release-automation + env: + CHART_VERSION: ${{ steps.chart_version.outputs.chart_version }} diff --git a/charts/onechart/Chart.yaml b/charts/onechart/Chart.yaml index b1afe81..82153b9 100644 --- a/charts/onechart/Chart.yaml +++ b/charts/onechart/Chart.yaml @@ -15,4 +15,4 @@ 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.18.0 +version: 0.19.0