forked from deiger/AirCon
-
Notifications
You must be signed in to change notification settings - Fork 1
/
new_version.sh
executable file
·51 lines (43 loc) · 1.33 KB
/
new_version.sh
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
#!/bin/bash
set -e
echo "Pobieranie najnowszych zmian z repozytorium"
git pull
# Pobieranie ostatniego tagu
OLD_VERSION=$(git tag | tail -n 1)
echo "Stara wersja: $OLD_VERSION"
# Ustawienie nowej wersji
NEW_VERSION=$1
if [ -z "$NEW_VERSION" ]; then
echo "Nowa wersja nie została podana"
exit 1
fi
echo "Nowa wersja: $NEW_VERSION"
# Ustawienie wiadomości tagu
if [ -z "$2" ]; then
NEW_VERSION_MSG="v$1"
else
NEW_VERSION_MSG=$2
fi
echo "Wiadomość nowej wersji: $NEW_VERSION_MSG"
# Tworzenie nowego tagu
git tag -a "$NEW_VERSION" -m "$NEW_VERSION_MSG"
# Zamiana wersji w plikach
for f in ./aircon/__init__.py ./hassio/config.json ./docker-compose.yaml; do
if [[ -f "$f" ]]; then
echo "Zamiana wersji w pliku: $f"
echo "Używając sed z: OLD_VERSION=$OLD_VERSION i NEW_VERSION=$NEW_VERSION"
# Użycie sed z opcją -i dla Linux
sed -i -e "s/$OLD_VERSION/$NEW_VERSION/g" "$f"
else
echo "Plik $f nie istnieje."
fi
done
# Commit zmian i aktualizacja tagu
git commit -a -m "$NEW_VERSION"
git tag -d "$NEW_VERSION"
git tag -a "$NEW_VERSION" -m "$NEW_VERSION_MSG"
docker buildx rm --all-inactive --force
docker buildx create --name multiarch --driver docker-container --use || true
docker buildx build --platform linux/arm/v7,linux/arm64,linux/amd64,linux/386 -t xury77/aircon:$NEW_VERSION --push .
git push
git push --tags