-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·59 lines (56 loc) · 1.41 KB
/
build.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
#!/bin/bash
set -x
set -e
# Set envs
token=$(echo $TOKEN)
branch=$(git rev-parse --abbrev-ref HEAD)
repo_full_name=$(git config --get remote.origin.url | sed 's/.*:\/\/github.com\///;s/.git$//')
build_dir="./build"
declare -a new_release
declare -a tags
post_data()
{
cat <<EOF
{
"tag_name": "$version",
"target_commitish": "$branch",
"name": "$version",
"body": "$text",
"draft": false,
"prerelease": false
}
EOF
}
find_in_array() {
local word=$1
shift
for e in "$@"; do [[ "$e" == "$word" ]] && return 0; done
}
# fetch all tags
git fetch --all --tags
mkdir ${build_dir}
# searching for new releases
#
for i in */
do
for v in `find $i -name "*.version.json"`
do
tags=$(git tag)
tversion=$(cat $v | jq .version | sed -e 's/\"//g')
version=$(echo ${i%/}-${tversion})
if [[ " ${tags[@]} " =~ " ${version} " ]]
then
echo "exists"
else
[ -d "${i}/cloud-init" ] && genisoimage -output ${i}/cloud-init/seed.img -volid cidata -joliet -rock ${i}/cloud-init/user-data ${i}/cloud-init/meta-data
sudo packer init ${i}${i%/}.json.pkr.hcl
sudo PACKER_LOG=1 packer build -var-file $v ${i}${i%/}.json.pkr.hcl
# sudo gzip ./tmp/${version}.qcow2
sudo mv ./tmp/${version}.qcow2 ${build_dir}/${TAG}-${version}.qcow2
sudo chmod 777 ${build_dir}/*
sudo rm -rf ./tmp/
git fetch --all --tags
fi
done
done
echo "done."