From 39d62f9f3af34ed901d2975916f03bb565ec34f4 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Tue, 27 Sep 2022 10:08:56 +0200 Subject: [PATCH] CI AJA: factor out common handling --- .github/scripts/Windows/prepare_msys.sh | 12 +++++------- .github/scripts/aja-common.sh | 13 +++++++++++++ .github/scripts/macOS/prepare.sh | 11 ++++------- 3 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 .github/scripts/aja-common.sh diff --git a/.github/scripts/Windows/prepare_msys.sh b/.github/scripts/Windows/prepare_msys.sh index f44583cc0..7f8a84cd6 100644 --- a/.github/scripts/Windows/prepare_msys.sh +++ b/.github/scripts/Windows/prepare_msys.sh @@ -38,6 +38,8 @@ EOF # shellcheck source=/dev/null . .github/scripts/json-common.sh +github_workspace_cp=$(cygpath "$GITHUB_WORKSPACE") + PACMAN_INSTALL='pacman -Sy --needed --noconfirm --disable-download-timeout' # Install MSYS2 packages MINGW_PACKAGE_PREFIX=mingw-w64-clang-x86_64 @@ -59,13 +61,9 @@ pacman -Scc --noconfirm install_aja() {( git clone --depth 1 https://github.com/aja-video/ntv2 AJA cd AJA - aja_release_json=$(fetch_json https://api.github.com/repos/aja-video/ntv2/releases "$GITHUB_TOKEN" array) - aja_gh_release=$(jq -r '.[0].assets_url' "$aja_release_json") - rm -- "$aja_release_json" - aja_gh_path_json=$(fetch_json "$aja_gh_release" "$GITHUB_TOKEN" array) - aja_gh_path=$(jq -r '[.[] | select(.name | test(".*libs_windows_.*"))] | .[0].browser_download_url' "$aja_gh_path_json") - rm -- "$aja_gh_path_json" - curl -sSL "$aja_gh_path" -o aja_build.zip + # shellcheck source=/dev/null + . "$github_workspace_cp/.github/scripts/aja-common.sh" + download_aja_release_asset libs_windows_ aja_build.zip rm README.md # would be overriden from zip below unzip aja_build.zip mkdir -p lib diff --git a/.github/scripts/aja-common.sh b/.github/scripts/aja-common.sh new file mode 100644 index 000000000..fd4ccf8de --- /dev/null +++ b/.github/scripts/aja-common.sh @@ -0,0 +1,13 @@ +# shellcheck shell=sh +download_aja_release_asset() { + pattern=${1?pattern must be given!} + file=${2?output filename must be given!} + aja_release_json=$(fetch_json https://api.github.com/repos/aja-video/ntv2/releases "$GITHUB_TOKEN" array) + aja_gh_release=$(jq -r '.[0].assets_url' "$aja_release_json") + rm -- "$aja_release_json" + aja_gh_path_json=$(fetch_json "$aja_gh_release" "$GITHUB_TOKEN" array) + aja_gh_path=$(jq -r '[.[] | select(.name | test(".*'"$pattern"'.*"))] | .[0].browser_download_url' "$aja_gh_path_json") + rm -- "$aja_gh_path_json" + curl -sSL "$aja_gh_path" -o "$file" +} + diff --git a/.github/scripts/macOS/prepare.sh b/.github/scripts/macOS/prepare.sh index ae383319d..696e5e319 100755 --- a/.github/scripts/macOS/prepare.sh +++ b/.github/scripts/macOS/prepare.sh @@ -41,17 +41,14 @@ install_ximea() { } install_aja() { + # shellcheck source=/dev/null + . "$GITHUB_WORKSPACE/.github/scripts/aja-common.sh" AJA_DIRECTORY=/private/var/tmp/ntv2sdk git clone --depth 1 https://github.com/aja-video/ntv2 $AJA_DIRECTORY cd $AJA_DIRECTORY echo "AJA_DIRECTORY=$AJA_DIRECTORY" >> "$GITHUB_ENV" - aja_release_json=$(fetch_json https://api.github.com/repos/aja-video/ntv2/releases "$GITHUB_TOKEN" array) - aja_gh_release=$(jq -r '.[0].assets_url' "$aja_release_json") - rm -- "$aja_release_json" - aja_gh_path_json=$(fetch_json "$aja_gh_release" "$GITHUB_TOKEN" array) - aja_gh_path=$(jq -r '[.[] | select(.name | test(".*libs_mac_.*"))] | .[0].browser_download_url' "$aja_gh_path_json") - rm -- "$aja_gh_path_json" - curl -sSL "$aja_gh_path" | tar xzf - + download_aja_release_asset libs_mac_ aja_build.tar.gz + tar xzf aja_build.tar.gz sudo cp Release/x64/* /usr/local/lib cd $TEMP_INST }