This repository has been archived by the owner on Jun 26, 2021. It is now read-only.
forked from bpicode/github-action-upload-bintray
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·89 lines (76 loc) · 3.37 KB
/
entrypoint.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env sh
set -euf -o pipefail
FILENAME=$(echo "${INPUT_FILE}" | xargs -n 1 basename)
HEADER_GPG_PASSPHRASE=""
if [ "${INPUT_GPG_PASSPHRASE}" != "" ]
then
HEADER_GPG_PASSPHRASE="X-GPG-PASSPHRASE: ${INPUT_GPG_PASSPHRASE}"
fi
HEADER_DEBIAN_DISTRIBUTION=""
if [ "${INPUT_DEB_DISTRIBUTION}" != "" ]
then
HEADER_DEBIAN_DISTRIBUTION="X-Bintray-Debian-Distribution: ${INPUT_DEB_DISTRIBUTION}"
fi
HEADER_DEBIAN_COMPONENT=""
if [ "${INPUT_DEB_COMPONENT}" != "" ]
then
HEADER_DEBIAN_COMPONENT="X-Bintray-Debian-Component: ${INPUT_DEB_COMPONENT}"
fi
HEADER_DEBIAN_ARCHITECTURE=""
if [ "${INPUT_DEB_ARCHITECTURE}" != "" ]
then
HEADER_DEBIAN_ARCHITECTURE="X-Bintray-Debian-Architecture: ${INPUT_DEB_ARCHITECTURE}"
fi
if [ "${INPUT_DELETE_FILE}" = "true" ]; then
echo "Deleting file"
curl --silent --location \
--user "${INPUT_API_USER}:${INPUT_API_KEY}" \
--request DELETE \
"${INPUT_API_URL}/content/${INPUT_REPOSITORY_USER}/${INPUT_REPOSITORY}/${FILENAME}" || /bin/true
echo " -> Done."
fi
if [ "${INPUT_DELETE_PACKAGE}" = "true" ]; then
echo "Delete package"
curl --silent --location \
--user "${INPUT_API_USER}:${INPUT_API_KEY}" \
--request DELETE \
"${INPUT_API_URL}/packages/${INPUT_REPOSITORY_USER}/${INPUT_REPOSITORY}/${INPUT_PACKAGE}" || /bin/true
echo " -> Done."
fi
if [ "${INPUT_CREATE_PACKAGE}" = "true" ]; then
echo "Create package"
curl --silent --location \
--user "${INPUT_API_USER}:${INPUT_API_KEY}" \
--request POST \
-H "Content-Type: application/json" \
--data "{\"name\": \"${INPUT_PACKAGE}\", \"licenses\": [${INPUT_LICENSES}], \"vcs_url\": \"https://github.com/${GITHUB_REPOSITORY}\"}" \
"${INPUT_API_URL}/packages/${INPUT_REPOSITORY_USER}/${INPUT_REPOSITORY}"
echo " -> Done."
fi
if [ "${INPUT_DELETE_VERSION}" = "true" ]; then
echo "Deleting version"
curl --silent --location \
--user "${INPUT_API_USER}:${INPUT_API_KEY}" \
--request DELETE \
"${INPUT_API_URL}/packages/${INPUT_REPOSITORY_USER}/${INPUT_REPOSITORY}/${INPUT_PACKAGE}/versions/${INPUT_VERSION}" || /bin/true
echo " -> Done."
fi
if [ "${INPUT_CREATE_VERSION}" = "true" ]; then
echo "Create version"
curl --silent --location \
--user "${INPUT_API_USER}:${INPUT_API_KEY}" \
--request POST \
-H "Content-Type: application/json" \
--data "{\"name\": \"${INPUT_VERSION}\"}" \
"${INPUT_API_URL}/packages/${INPUT_REPOSITORY_USER}/${INPUT_REPOSITORY}/${INPUT_PACKAGE}/versions" || /bin/true
echo " -> Done."
fi
echo "Uploading file"
curl --silent --show-error --fail --location --request PUT --upload-file "${1}" --user "${INPUT_API_USER}:${INPUT_API_KEY}" -H "${HEADER_GPG_PASSPHRASE}" -H "${HEADER_DEBIAN_DISTRIBUTION}" -H "${HEADER_DEBIAN_COMPONENT}" -H "${HEADER_DEBIAN_ARCHITECTURE}" "${INPUT_API_URL}/content/${INPUT_REPOSITORY_USER}/${INPUT_REPOSITORY}/${INPUT_PACKAGE}/${INPUT_VERSION}/${INPUT_UPLOAD_PATH}/${FILENAME};publish=${INPUT_PUBLISH}"
echo " -> Done."
if [ "${INPUT_CALCULATE_METADATA}" = "true" ]
then
echo "Requesting metadata (re)-calculation"
curl --silent --show-error --fail --location --request POST --user "${INPUT_API_USER}:${INPUT_API_KEY}" -H "${HEADER_GPG_PASSPHRASE}" "${INPUT_API_URL}/calc_metadata/${INPUT_REPOSITORY_USER}/${INPUT_REPOSITORY}"
echo " -> Done."
fi