Skip to content

Commit 7e6b5d7

Browse files
committed
circleci: reorganize scripts for autobuild
Signed-off-by: Ansuel Smith <[email protected]>
1 parent 8b799bf commit 7e6b5d7

5 files changed

+86
-79
lines changed

.circleci/config.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ jobs:
1414
command: |
1515
echo Start autobuild of dev gui...
1616
apt-get update && apt-get install dos2unix git curl -y
17+
- run:
18+
name: Increment version from latest build
19+
command: bash ./scripts/1-increment_autobuild_ver.sh
20+
- run:
21+
name: Clone autobuild repo
22+
command: bash ./scripts/2-clone_autobuild_dir.sh
1723
- run:
1824
name: Inizialize Gui
19-
command: bash ./inizialize_gui.sh dev
25+
command: bash ./inizialize_gui.sh dev
26+
- run:
27+
name: Upload new build, build and latest.version
28+
command: |
29+
source ~/.bashrc
30+
bash ./scripts/3-update_autobuild_ver.sh

inizialize_gui.sh

+3-78
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,3 @@
1-
if [ $CI == "true" ]; then
2-
3-
rootdevice_file="decompressed/base/etc/init.d/rootdevice"
4-
latest_version_link="https://raw.githubusercontent.com/Ansuel/gui-dev-build-auto/master/latest.version"
5-
version=$(curl -s $latest_version_link)
6-
7-
echo "Increment version as this is an autobuild"
8-
9-
major=$(echo $version | grep -Eo "^[0-9]+")
10-
dev_num=$(echo $version | sed -E s/[0-9]+\.[0-9]+\.//)
11-
minor=$(echo $version | sed s#$major\.## | sed s#\\.$dev_num## )
12-
13-
if [ $((dev_num + 1)) -gt 99 ]; then
14-
echo "dev_num greater than 99 increment minor"
15-
dev_num=0
16-
if [ $((minor + 1)) -gt 99 ]; then
17-
echo "minor greater than 99 increment minor"
18-
minor=0
19-
major=$((major + 1))
20-
else
21-
minor=$((minor + 1))
22-
fi
23-
else
24-
dev_num=$((dev_num + 1))
25-
fi
26-
27-
new_version=$major.$minor.$dev_num
28-
29-
echo "Detected version: "$version
30-
echo "New version to apply: "$new_version
31-
32-
sed -i s#version_gui=TO_AUTO_COMPLETE#version_gui=$new_version# $rootdevice_file
33-
34-
git config --global user.name "CircleCI";
35-
git config --global user.email "CircleCI";
36-
37-
ssh -o StrictHostKeyChecking=no [email protected]
38-
39-
echo "Publishing dev build to auto repo...";
40-
git clone --depth=1 [email protected]:Ansuel/gui-dev-build-auto.git $HOME/gui-dev-build-auto/
41-
42-
if [ ! -d $HOME/gui-dev-build-auto/modular ]; then
43-
mkdir $HOME/gui-dev-build-auto/modular
44-
fi
45-
fi
46-
47-
481
echo "Fixing file..."
492

503
nfile=0
@@ -92,6 +45,9 @@ declare -a modular_dir=(
9245
if [ "$1" == "dev" ]; then
9346
echo "Dev build detected"
9447
type="_dev"
48+
if [ $CI == "true" ]; then
49+
touch ~/.dev
50+
fi
9551
fi
9652

9753
mkdir tar_tmp
@@ -144,34 +100,3 @@ done
144100

145101
cd total && BZIP2=-9 tar -cjf ../compressed/GUI$type.tar.bz2 * --owner=0 --group=0
146102
cd ../
147-
148-
if [ $CI == "true" ]; then
149-
150-
md5sum=$(md5sum compressed/GUI$type.tar.bz2 | awk '{print $1}')
151-
version=$(cat total/etc/init.d/rootdevice | grep -m1 version_gui | cut -d'=' -f 2)
152-
if ! grep -w -q "$version" $HOME/gui-dev-build-auto/version ; then
153-
echo "Adding md5sum of new GUI to version file"
154-
echo "Version: "$version" Md5sum: "$md5sum
155-
echo $md5sum $version >> $HOME/gui-dev-build-auto/version
156-
else
157-
echo "Md5sum already present. Overwriting..."
158-
old_version_md5=$(grep -w "$version" $HOME/gui-dev-build-auto/version | awk '{print $1}')
159-
sed -i "/$version/d" $HOME/gui-dev-build-auto/version
160-
echo "Adding md5sum of new GUI to version file"
161-
echo "Version: "$version" Old_Md5sum: "$old_version_md5
162-
echo "Version: "$version" Md5sum: "$md5sum
163-
echo $md5sum $version >> $HOME/gui-dev-build-auto/version
164-
fi
165-
166-
cp compressed/GUI$type.tar.bz2 $HOME/gui-dev-build-auto/ -r;
167-
168-
cd $HOME/gui-dev-build-auto/;
169-
170-
echo $version > latest.version
171-
172-
git add -A;
173-
git commit -a -m "Automatic dev build. Version: $version";
174-
git push origin master;
175-
176-
echo "Done.";
177-
fi

scripts/1-increment_autobuild_ver.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
rootdevice_file="decompressed/base/etc/init.d/rootdevice"
2+
latest_version_link="https://raw.githubusercontent.com/Ansuel/gui-dev-build-auto/master/latest.version"
3+
version=$(curl -s $latest_version_link)
4+
5+
echo "Increment version as this is an autobuild"
6+
7+
major=$(echo $version | grep -Eo "^[0-9]+")
8+
dev_num=$(echo $version | sed -E s/[0-9]+\.[0-9]+\.//)
9+
minor=$(echo $version | sed s#$major\.## | sed s#\\.$dev_num## )
10+
11+
if [ $((dev_num + 1)) -gt 99 ]; then
12+
echo "dev_num greater than 99 increment minor"
13+
dev_num=0
14+
if [ $((minor + 1)) -gt 99 ]; then
15+
echo "minor greater than 99 increment minor"
16+
minor=0
17+
major=$((major + 1))
18+
else
19+
minor=$((minor + 1))
20+
fi
21+
else
22+
dev_num=$((dev_num + 1))
23+
fi
24+
25+
new_version=$major.$minor.$dev_num
26+
27+
echo "Detected version: "$version
28+
echo "New version to apply: "$new_version
29+
30+
sed -i s#version_gui=TO_AUTO_COMPLETE#version_gui=$new_version# $rootdevice_file

scripts/2-clone_autobuild_dir.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
git config --global user.name "CircleCI";
2+
git config --global user.email "CircleCI";
3+
4+
ssh -o StrictHostKeyChecking=no [email protected]
5+
6+
git clone --depth=1 [email protected]:Ansuel/gui-dev-build-auto.git $HOME/gui-dev-build-auto/
7+
8+
if [ ! -d $HOME/gui-dev-build-auto/modular ]; then
9+
mkdir $HOME/gui-dev-build-auto/modular
10+
fi
11+

scripts/3-update_autobuild_ver.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
if [ -f ~/.dev ]; then
2+
type="_dev"
3+
fi
4+
md5sum=$(md5sum compressed/GUI$type.tar.bz2 | awk '{print $1}')
5+
version=$(cat total/etc/init.d/rootdevice | grep -m1 version_gui | cut -d'=' -f 2)
6+
if ! grep -w -q "$version" $HOME/gui-dev-build-auto/version ; then
7+
echo "Adding md5sum of new GUI to version file"
8+
echo "Version: "$version" Md5sum: "$md5sum
9+
echo $md5sum $version >> $HOME/gui-dev-build-auto/version
10+
else
11+
echo "Md5sum already present. Overwriting..."
12+
old_version_md5=$(grep -w "$version" $HOME/gui-dev-build-auto/version | awk '{print $1}')
13+
sed -i "/$version/d" $HOME/gui-dev-build-auto/version
14+
echo "Adding md5sum of new GUI to version file"
15+
echo "Version: "$version" Old_Md5sum: "$old_version_md5
16+
echo "Version: "$version" Md5sum: "$md5sum
17+
echo $md5sum $version >> $HOME/gui-dev-build-auto/version
18+
fi
19+
20+
cp compressed/GUI$type.tar.bz2 $HOME/gui-dev-build-auto/ -r;
21+
22+
cd $HOME/gui-dev-build-auto/;
23+
24+
echo $version > latest.version
25+
26+
git add -A;
27+
git commit -a -m "Automatic dev build. Version: $version";
28+
git push origin master;
29+
30+
echo "Done.";

0 commit comments

Comments
 (0)