-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_app.sh
More file actions
executable file
·64 lines (50 loc) · 1.6 KB
/
update_app.sh
File metadata and controls
executable file
·64 lines (50 loc) · 1.6 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
set -e
APP_DIR="/home/elixirdss/app-src/elixir-dss"
# If not running as elixirdss user, switch to it
if [ "$USER" != "elixirdss" ]; then
echo "Switching to elixirdss user..."
exec sudo -u elixirdss bash "$0" "$@"
fi
VERSION="${1}"
echo "=== Deploying Elixir DSS ==="
cd "$APP_DIR"
echo "Fetching tags..."
git fetch --tags origin
if [ -n "$VERSION" ]; then
if ! echo "$VERSION" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9._/+-]+)?$'; then
echo "Error: VERSION '$VERSION' has invalid format (expected 'v1.0.0' or 'v0.2.0-dev')"
exit 1
fi
else
echo "No VERSION provided. Using latest stable tag..."
VERSION=$(git tag --list | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1)
if [ -z "$VERSION" ]; then
echo "Error: No version tags found"
exit 1
fi
echo "Selected: $VERSION"
fi
if ! git show-ref --tags --quiet --verify "refs/tags/$VERSION"; then
echo "Error: Tag $VERSION does not exist. Available tags:"
git tag --list | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -5
exit 1
fi
echo "Checking out tag: $VERSION"
if ! git checkout "$VERSION"; then
echo "Error: git checkout $VERSION failed"
exit 1
fi
echo "Updating Python dependencies..."
source project_venv/bin/activate
pip install -e . --upgrade
echo "Applying database migrations..."
flask db upgrade
echo "Building frontend assets..."
cd elixir_dss/static/vendor
npm ci
npm run build:css
echo "Restarting services..."
sudo systemctl restart elixir-dss
sudo systemctl restart nginx
echo "✓ Deployment completed successfully (version: $VERSION)!"