Skip to content

Commit

Permalink
ci: version bump on dockerfile change
Browse files Browse the repository at this point in the history
Signed-off-by: Romain Billon <[email protected]>
  • Loading branch information
Rbillon59 committed Oct 29, 2024
1 parent 32b93a1 commit 88d654f
Showing 1 changed file with 7 additions and 29 deletions.
36 changes: 7 additions & 29 deletions .github/workflows/update-to-latest.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
on:
schedule:
- cron: '30 5 * * 2'
push:
branches:
- master
paths:
- 'Dockerfile'
workflow_dispatch:

jobs:
Expand All @@ -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'
Expand Down

0 comments on commit 88d654f

Please sign in to comment.