diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3efaf4c..b2273a6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -86,6 +86,34 @@ jobs: - name: Get result run: echo "${{steps.set-result.outputs.result}}" + - name: Update versions + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') + run: | + TAG="${{ steps.tags.outputs.result }}" + CURRENT_VERSION=$(grep "appVersion: " helm/easyhaproxy/Chart.yaml | sed 's#appVersion: "\(.*\)"#\1#g') + + if [ "$TAG" = "$CURRENT_VERSION" ]; then + echo "Skipping update version..." + else + sed -i "s#easy-haproxy:[a-zA-Z0-9\.]*#easy-haproxy:$TAG#g" deploy/docker/docker-compose.yml + sed -i "s#version: \"[a-zA-Z0-9\.]*\"#version: \"$TAG\"#g" deploy/kubernetes/easyhaproxy-*.yml + sed -i "s#easy-haproxy:[a-zA-Z0-9\.]*#easy-haproxy:$TAG#g" deploy/kubernetes/easyhaproxy-*.yml + + sed -i "s#easy-haproxy/[a-zA-Z0-9\.]*/#easy-haproxy/$TAG/#g" docs/kubernetes.md + sed -i "s#appVersion: \"[a-zA-Z0-9\.]*\"#appVersion: \"$TAG\"#g" helm/easyhaproxy/Chart.yaml + + VERSION=$(grep "version: " helm/easyhaproxy/Chart.yaml | sed 's#version: ##g') + NEW_VERSION=$(echo $VERSION | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.) + + sed -i "s#version: [a-zA-Z0-9\.]*#version: $NEW_VERSION#g" helm/easyhaproxy/Chart.yaml + sed -i "s#chart: easyhaproxy-[a-zA-Z0-9\.]*#chart: easyhaproxy-$NEW_VERSION#g" deploy/kubernetes/easyhaproxy-*.yml + + git add . + git commit -m "[skip ci] Update from $TAG to $CURRENT_VERSION" + git push + fi + + # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image @@ -94,7 +122,7 @@ jobs: context: . file: build/Dockerfile build-args: | - RELEASE_VERSION_ARG="${{ join(steps.tags.outputs.result, ',') }}" + RELEASE_VERSION_ARG="${{ steps.tags.outputs.result }}" platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' || github.event.inputs.push == 'true' }} tags: ${{ steps.meta.outputs.tags }} @@ -110,7 +138,7 @@ jobs: Helm: runs-on: 'ubuntu-latest' needs: Build - if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') env: DOC_GITHUB_TOKEN: '${{ secrets.DOC_TOKEN }}' steps: @@ -119,7 +147,7 @@ jobs: Documentation: runs-on: 'ubuntu-latest' - needs: Build + needs: Helm if: github.ref == 'refs/heads/master' env: DOC_GITHUB_TOKEN: '${{ secrets.DOC_TOKEN }}'