-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
46 lines (38 loc) · 1.49 KB
/
deploy.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
#!/usr/bin/env bash
API_BASE_URI="https://app.vagrantup.com/api/v1"
VAGRANT_CLOUD_TOKEN=""
USERNAME="sivalabs"
BOX_NAME="ubuntu_bionic64_java"
BOX_VERSION="0.0.2"
PROVIDER="virtualbox"
# Create a new box
curl \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $VAGRANT_CLOUD_TOKEN" \
$API_BASE_URI/boxes \
--data "{ \"box\": { \"username\": \"$USERNAME\", \"name\": \"$BOX_NAME\" } }"
# Create a new version
curl \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $VAGRANT_CLOUD_TOKEN" \
$API_BASE_URI/box/$USERNAME/$BOX_NAME/versions \
--data "{ \"version\": { \"version\": \"$BOX_VERSION\" } }"
# Create a new provider
curl \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $VAGRANT_CLOUD_TOKEN" \
$API_BASE_URI/box/$USERNAME/$BOX_NAME/version/$BOX_VERSION/providers \
--data "{ \"provider\": { \"name\": \"$PROVIDER\" } }"
# Prepare the provider for upload/get an upload URL
response=$(curl \
--header "Authorization: Bearer $VAGRANT_CLOUD_TOKEN" \
$API_BASE_URI/box/$USERNAME/$BOX_NAME/version/$BOX_VERSION/provider/virtualbox/upload)
# Extract the upload URL from the response (requires the jq command)
upload_path=$(echo "$response" | jq .upload_path)
# Perform the upload
curl $upload_path --request PUT --upload-file package.box
# Release the version
curl \
--header "Authorization: Bearer $VAGRANT_CLOUD_TOKEN" \
$API_BASE_URI/box/$USERNAME/$BOX_NAME/version/$BOX_VERSION/release \
--request PUT