This repository was archived by the owner on Jun 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathupload.sh
executable file
·45 lines (38 loc) · 1.59 KB
/
upload.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
#!/bin/bash
IFS=';' read -ra DIRECTORIES <<<"${COMPONENTS_DIRECTORIES:-.}"
NAMESPACE=${COMPONENTS_NAMESPACE:-espressif}
UPLOAD_ARGUMENTS=("--allow-existing" "--namespace=${NAMESPACE}" )
if [ -n "$SKIP_PRE_RELEASE" ]; then
UPLOAD_ARGUMENTS+=("--skip-pre-release")
fi
if [ -n "$COMPONENT_VERSION" ]; then
if [ "$COMPONENT_VERSION" == "git" ]; then
git fetch --force --tags
if ! git describe --exact-match; then
echo "Version is set to 'git', but the current commit is not tagged. Skipping the upload."
exit 0
fi
fi
UPLOAD_ARGUMENTS+=("--version=${COMPONENT_VERSION//v/}")
fi
NUMBER_OF_DIRECTORIES="${#DIRECTORIES[@]}"
echo "Processing $NUMBER_OF_DIRECTORIES components"
for ITEM in "${DIRECTORIES[@]}"; do
FULL_PATH="${GITHUB_WORKSPACE?}/${ITEM}"
if [ "$NUMBER_OF_DIRECTORIES" -eq "1" ] && [ "${ITEM}" == "." ] && [ -z "${COMPONENT_NAME}" ]; then
echo "To upload a single component, either specify the component name or directory, which will be used as the component name"
exit 1
fi
if [ "${ITEM}" == "." ]; then
NAME=${COMPONENT_NAME?"Name is required to upload a component from the root of the repository."}
else
NAME=$(basename "$(realpath "${FULL_PATH}")")
fi
echo "Processing component \"$NAME\" at $ITEM"
python3 -m idf_component_manager upload-component "${UPLOAD_ARGUMENTS[@]}" --path="${FULL_PATH}" --name="${NAME}"
EXIT_CODE=$?
if [ "$EXIT_CODE" -ne "0" ]; then
echo "An error occurred while uploading the new version of ${NAMESPACE}/${NAME}."
exit 1
fi
done