Skip to content

Commit

Permalink
Create helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
filip-szweda committed Oct 19, 2023
1 parent 63a5d59 commit a92292e
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions .github/workflows/build-test-and-publish-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,39 @@ jobs:

- name: Move third party licenses to artifact directory
run: |
downloadLicense() {
local requirement="${1}"
local requirementPath="${2}"
local licenseUrl="${3}"
printf "[INFO] Downloading %s license file from %s to %s\n" "${requirement}" "${licenseUrl}" "${requirementPath}"
(cd "${requirementPath}" && curl "${licenseUrl}" --output LICENSE)
}
copyLicense() {
local requirement="${1}"
local requirementPath="${2}"
local licensePath="${3}"
printf "[INFO] Copying %s license file %s to %s\n" "${requirement}" "${licensePath}" "${requirementPath}"
cp "${licensePath}" "${requirementPath}"
}
licenseDirPaths="$(sudo find /home/runner/.conan2/p/ -type d -name "licenses" | tr "\n" " ")"
requirements="$(cat conanfile.txt | tr "\n" " " | grep -Po "\[requires\] \K[^\[]+")"
for requirement in $requirements; do
requirementPath=${{ env.ARTIFACT_PATH }}/thirdparty/${requirement}
mkdir -p "${requirementPath}"
licenseUrl="https://raw.githubusercontent.com/protobuf-c/protobuf-c/master/LICENSE"
if printf "%s" "${requirement}" | grep -q "protobuf-c/"; then
printf "[INFO] Downloading %s license file from %s to %s\n" "${requirement}" "${licenseUrl}" "${requirementPath}"
(cd "${requirementPath}" && curl "${licenseUrl}" --output LICENSE)
downloadLicense "${requirement}" "${requirementPath}" "https://raw.githubusercontent.com/protobuf-c/protobuf-c/master/LICENSE"
continue
fi
licenseUrl="https://raw.githubusercontent.com/protocolbuffers/protobuf/main/LICENSE"
if printf "%s" "${requirement}" | grep -q "protobuf/"; then
printf "[INFO] Downloading %s license file from %s to %s\n" "${requirement}" "${licenseUrl}" "${requirementPath}"
(cd "${requirementPath}" && curl "${licenseUrl}" --output LICENSE)
downloadLicense "${requirement}" "${requirementPath}" "https://raw.githubusercontent.com/protocolbuffers/protobuf/main/LICENSE"
continue
fi
Expand All @@ -68,22 +83,19 @@ jobs:
licensePath="${licenseDirPath}/LICENSE"
if [ -e "${licensePath}" ]; then
printf "[INFO] Copying %s license file %s to %s\n" "${requirement}" "${licensePath}" "${requirementPath}"
cp "${licensePath}" "${requirementPath}"
copyLicense "${requirement}" "${requirementPath}" "${licensePath}"
continue
fi
licensePath="${licenseDirPath}/LICENSE_1_0.txt"
if [ -e "${licensePath}" ]; then
printf "[INFO] Copying %s license file %s to %s\n" "${requirement}" "${licensePath}" "${requirementPath}"
cp "${licensePath}" "${requirementPath}"
copyLicense "${requirement}" "${requirementPath}" "${licensePath}"
continue
fi
licensePath="${licenseDirPath}/LICENSE.rst"
if [ -e "${licensePath}" ]; then
printf "[INFO] Copying %s license file %s to %s\n" "${requirement}" "${licensePath}" "${requirementPath}"
cp "${licensePath}" "${requirementPath}"
copyLicense "${requirement}" "${requirementPath}" "${licensePath}"
continue
fi
Expand Down

0 comments on commit a92292e

Please sign in to comment.