forked from d1ceward-on-dokku/n8n_on_dokku
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate
More file actions
executable file
·50 lines (38 loc) · 1.39 KB
/
Copy pathupdate
File metadata and controls
executable file
·50 lines (38 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
set -eo pipefail
trap "exit" INT
# Pull upstream changes
echo -e "\033[0;32m====>\033[0m Pull origin..."
git pull
echo -e "\033[0;32m====>\033[0m Initial check..."
# Get current release name
CURRENT_RELEASE=$(git tag --sort=version:refname | tail -1)
# Get the highest 1.x.x release name (ignore 2.x.x and above)
RELEASE=$(curl -s https://api.github.com/repos/n8n-io/n8n/releases?per_page=100 \
| jq -r '.[].tag_name' \
| sed 's/n8n@//g; s/\"//g' \
| grep -E '^1\.[0-9]+\.[0-9]+$' \
| sort -V \
| tail -1)
# Prevent upgrade to 2.x.x or higher
if [[ $RELEASE =~ ^2\.|^[3-9]\.|^[1-9][0-9]+\. ]]; then
echo -e "\033[0;31mERROR:\033[0m Upgrade to n8n version $RELEASE is not allowed. Only 1.x.x versions are supported."
exit 1
fi
# Exit script if already up to date
if [ "$RELEASE" = "$CURRENT_RELEASE" ]; then
echo -e "\033[0;32m=>\033[0m Already up to date..."
exit 0
fi
# Replace "from" line in dockerfile with the new release
sed -i "s#ARG N8N_VERSION.*#ARG N8N_VERSION=\"${RELEASE}\"#" Dockerfile
# Replace README link to n8n release
N8N_BADGE="[](https://github.com/n8n-io/n8n/releases/tag/n8n%40${RELEASE})"
sed -i "s#\[\!\[n8n\].*#${N8N_BADGE}#" README.md
# Push changes
git add Dockerfile README.md
git commit -m "Update to n8n version ${RELEASE}"
git push origin master
# Create tag
git tag $RELEASE
git push --tags