-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdo-release.sh
executable file
·72 lines (57 loc) · 2.64 KB
/
do-release.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
set -euo pipefail
new_version=$1
version_only=${new_version#*v}
minor_version=${new_version%.*}
new_date=$(date +%Y-%m-%d)
cd "$(dirname "$0")"
if [ ! -z "$(git status -s)" ]; then
echo "Uncommitted changes, aborting"
fi
echo -e "\n* Updating Cargo.toml..."
sed -i 's|^version = ".*|version = "'$version_only'"|' Cargo.toml
# Test build and update cargo.lock
export QMAKE="/usr/lib/qt6/bin/qmake"
cargo build --release
# Make sure all QML files are defined in resources
qml_files=$(find src/frontend/qt/qml \( -name '*.qml' -or -name '*.js' \) | sed 's/^src\/frontend\/qt\/qml\///')
for f in $qml_files; do
if ! fgrep -q "\"$f\"" "src/frontend/qt/resources_qml.rs"; then
echo "File $f not found in QML resource file"
exit 1
fi
done
pushd flatpak &>/dev/null
echo -e "\n* Updating flatpak cargo-source and metainfo files..."
python3 ./flatpak-cargo-generator/flatpak-cargo-generator.py ../Cargo.lock -o cargo-sources.json
sed -i '/<releases>$/a \ <release version="'$version_only'" date="'$new_date'">'"\n <description>\n </description>\n </release>" io.github.kalaksi.Lightkeeper.metainfo.xml
read -p "Edit metainfo now by pressing enter" _temp
$EDITOR io.github.kalaksi.Lightkeeper.metainfo.xml
xmllint io.github.kalaksi.Lightkeeper.metainfo.xml >/dev/null
echo -e "\n* Committing changes..."
git commit -a -m "Prepare for version $new_version"
git push
echo -e "\n* Creating a git tag..."
git tag -a "$new_version" -m "Version $new_version"
git push origin "$new_version"
echo -e "\n* Updating io.github.kalaksi.Lightkeeper.yml..."
sed -ri 's|(\s+url: https://github.com/kalaksi/lightkeeper/archive/refs/tags/).*|\1'$new_version'.tar.gz|' io.github.kalaksi.Lightkeeper.yml
new_checksum=$(wget -qO- "https://github.com/kalaksi/lightkeeper/archive/refs/tags/$new_version.tar.gz"|sha256sum|cut -f 1 -d ' ')
sed -ri '/url: https:\/\/github.com\/kalaksi\/lightkeeper\/archive/{n;s/(\s+sha256: ).*/\1'$new_checksum'/}' io.github.kalaksi.Lightkeeper.yml
git commit -a -m "Update flatpak manifest for $new_version"
git push
popd &>/dev/null
if [ -d ../io.github.kalaksi.Lightkeeper ]; then
echo -e "\n* Updating flatpak-repo"
cp -v flatpak/cargo-sources.json ../io.github.kalaksi.Lightkeeper/
cp -v flatpak/io.github.kalaksi.Lightkeeper.yml ../io.github.kalaksi.Lightkeeper/
cd ../io.github.kalaksi.Lightkeeper
current_branch=$(git branch --show-current)
if [ $current_branch != $minor_version ]; then
# Will fail if branch already exists.
git checkout -b $minor_version
fi
# Pushing the changes has to be done manually
git commit -a -m "Update to version $version_only"
cd -
fi