From 88d654fa6e929a87e3e398e90f59174e1b6385ca Mon Sep 17 00:00:00 2001 From: Romain Billon Date: Tue, 29 Oct 2024 16:45:13 +0100 Subject: [PATCH] ci: version bump on dockerfile change Signed-off-by: Romain Billon --- .github/workflows/update-to-latest.yaml | 36 +++++-------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/.github/workflows/update-to-latest.yaml b/.github/workflows/update-to-latest.yaml index 5e69650..a112459 100644 --- a/.github/workflows/update-to-latest.yaml +++ b/.github/workflows/update-to-latest.yaml @@ -1,6 +1,9 @@ on: - schedule: - - cron: '30 5 * * 2' + push: + branches: + - master + paths: + - 'Dockerfile' workflow_dispatch: jobs: @@ -9,41 +12,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - - name: Get latest n8n version - id: n8n_latest_version - run: | - latest_release=$(curl -s https://docs.n8n.io/release-notes/ | grep -oE "latest.*[0-9]+\.[0-9]+\.[0-9]+" | awk -F '[: ]' '{print $3}') - echo "::set-output name=latest_release::$latest_release" - - - name: Check actual version - id: check_version - run: echo "::set-output name=actual_version::$(grep -oP '(?<=ARG N8N_VERSION=)[0-9]+\.[0-9]+\.[0-9]+' Dockerfile)" - - - name: Check if update is needed - id: check_update - run: echo "::set-output name=update_needed::$(test ${{ steps.check_version.outputs.actual_version }} != ${{ steps.n8n_latest_version.outputs.latest_release }} && echo true || echo false)" - - - name: update n8n version in Dockerfile - if: steps.check_update.outputs.update_needed == 'true' - run: | - sed -i "s/N8N_VERSION=.*/N8N_VERSION=${{ steps.n8n_latest_version.outputs.latest_release }}/g" Dockerfile - name: update addon configuration in config.json - if: steps.check_update.outputs.update_needed == 'true' run: | actual_config=$(cat config.json | jq -r ".version" | awk -F"." '{print $3}') new_config=$((actual_config+1)) actual_version=$(cat config.json | jq -r ".version" | awk -F"." '{print $1"."$2}') new_version="${actual_version}.${new_config}" jq ".version = \"${new_version}\"" config.json > config.json.tmp && mv config.json.tmp config.json - sed -i "s/## \[Unreleased\]/## \[Unreleased\]\n\n## [ ${new_version} ] - $(date +%Y-%m-%d) \n\n Bump n8n to ${{ steps.n8n_latest_version.outputs.latest_release }}/g" CHANGELOG.md - - - - name: update CHANGELOG.md - if: steps.check_update.outputs.update_needed == 'true' - run: | - + n8n_version=$(cat Dockerfile | grep "FROM" | awk -F":" '{print $2}') + sed -i "s/## \[Unreleased\]/## \[Unreleased\]\n\n## [ ${new_version} ] - $(date +%Y-%m-%d) \n\n Bump n8n to ${n8n_version} /g" CHANGELOG.md - name: create pull request if: steps.check_update.outputs.update_needed == 'true'