forked from aptly-dev/aptly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload-artifacts.sh
executable file
·66 lines (53 loc) · 2.47 KB
/
upload-artifacts.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
#!/bin/sh
set -e
builds=build/
packages=${builds}*.deb
folder=`mktemp -u tmp.XXXXXXXXXXXXXXX`
aptly_user="$APTLY_USER"
aptly_password="$APTLY_PASSWORD"
aptly_api="https://aptly-ops.aptly.info"
version=`make version`
echo "Publishing version '$version' to $1..."
for file in $packages; do
echo "Uploading $file..."
curl -fsS -X POST -F "file=@$file" -u $aptly_user:$aptly_password ${aptly_api}/api/files/$folder
echo
done
if [ "$1" = "nightly" ]; then
if echo "$version" | grep -vq "+"; then
# skip nightly when on release tag
exit 0
fi
aptly_repository=aptly-nightly
aptly_published=s3:repo.aptly.info:./nightly
echo "Adding packages to $aptly_repository..."
curl -fsS -X POST -u $aptly_user:$aptly_password ${aptly_api}/api/repos/$aptly_repository/file/$folder
echo
echo "Updating published repo..."
curl -fsS -X PUT -H 'Content-Type: application/json' --data \
'{"AcquireByHash": true, "Signing": {"Batch": true, "Keyring": "aptly.repo/aptly.pub",
"secretKeyring": "aptly.repo/aptly.sec", "PassphraseFile": "aptly.repo/passphrase"}}' \
-u $aptly_user:$aptly_password ${aptly_api}/api/publish/$aptly_published
echo
fi
if [ "$1" = "release" ]; then
aptly_repository=aptly-release
aptly_snapshot=aptly-$version
aptly_published=s3:repo.aptly.info:./squeeze
echo "Adding packages to $aptly_repository..."
curl -fsS -X POST -u $aptly_user:$aptly_password ${aptly_api}/api/repos/$aptly_repository/file/$folder
echo
echo "Creating snapshot $aptly_snapshot from repo $aptly_repository..."
curl -fsS -X POST -u $aptly_user:$aptly_password -H 'Content-Type: application/json' --data \
"{\"Name\":\"$aptly_snapshot\"}" ${aptly_api}/api/repos/$aptly_repository/snapshots
echo
echo "Switching published repo to use snapshot $aptly_snapshot..."
curl -fsS -X PUT -H 'Content-Type: application/json' --data \
"{\"AcquireByHash\": true, \"Snapshots\": [{\"Component\": \"main\", \"Name\": \"$aptly_snapshot\"}],
\"Signing\": {\"Batch\": true, \"Keyring\": \"aptly.repo/aptly.pub\",
\"secretKeyring\": \"aptly.repo/aptly.sec\", \"PassphraseFile\": \"aptly.repo/passphrase\"}}" \
-u $aptly_user:$aptly_password ${aptly_api}/api/publish/$aptly_published
echo
fi
curl -fsS -X DELETE -u $aptly_user:$aptly_password ${aptly_api}/api/files/$folder
echo