-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·60 lines (49 loc) · 1.49 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
58
59
60
#!/bin/bash
if [ "$#" -ne 3 ]; then
echo "Illegal number of parameters. Usage: <box> <version> <token>"
exit 1
fi
case $1 in
focal-php8)
grep -q $1 Vagrantfile
if [ $? -eq 1 ]; then
echo "Looks like you are in the wrong branch. Your Vagrantfile does not contain $1"
exit
fi
;;
*)
echo $"Usage: $0 {focal-php8}"
exit 1
esac
# cleanup previous builds
vagrant destroy -f
rm package.box
# build the box
vagrant box update
vagrant up
if [ $? -ne 0 ]; then
exit 1
fi
vagrant package --base focal-php8.vb
if [ $? -ne 0 ]; then
exit 1
fi
# create a new version
curl \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $3" \
https://app.vagrantup.com/api/v1/box/peterrehm/"$1"/versions \
--data "{ \"version\": { \"version\": \"$2\" } }"
# add a new provider
curl \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $3" \
https://app.vagrantup.com/api/v1/box/peterrehm/"$1"/version/"$2"/providers \
--data '{ "provider": { "name": "virtualbox" } }'
# 2-step upload process
curl --request PUT --upload-file package.box $(curl -sS --header "Authorization: Bearer $3" https://app.vagrantup.com/api/v1/box/peterrehm/"$1"/version/"$2"/provider/virtualbox/upload | grep -Po '(?<="upload_path":")[^"]*')
# release the version
curl \
--header "Authorization: Bearer $3" \
https://app.vagrantup.com/api/v1/box/peterrehm/"$1"/version/"$2"/release \
--request PUT