Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to override dependency versions #636

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/build_rust.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -euxo pipefail

source "${WORKDIR}/lib-versions.env"
source "${WORKDIR}/ci/export_lib_versions.sh"

declare -A targets=(
[amd64]=x86_64-unknown-linux-gnu
Expand Down
2 changes: 1 addition & 1 deletion ci/check_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euxo pipefail

source "${WORKDIR}/ci/archs.sh"
source "${WORKDIR}/lib-versions.env"
source "${WORKDIR}/ci/export_lib_versions.sh"

temp_dir="${WORKDIR}/bin/deps/artifacts"
lib_root="${WORKDIR}/bin/deps/lib"
Expand Down
3 changes: 3 additions & 0 deletions ci/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ if [[ $tags == *"moose"* ]]; then
trap revert_moose_patch EXIT
fi

source "${WORKDIR}"/ci/set_bindings_version.sh libtelio
source "${WORKDIR}"/ci/set_bindings_version.sh libdrop

for program in ${!names_map[*]}; do # looping over keys
pushd "${WORKDIR}/cmd/${program}"
# BUILDMODE can be no value and `go` does not like empty parameter ''
Expand Down
35 changes: 35 additions & 0 deletions ci/set_bindings_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -euxo pipefail

# source "${WORKDIR}/ci/export_lib_versions.sh"

declare -A LIB_NAME_TO_PACKAGE=(
[libtelio]=github.com/NordSecurity/libtelio-go
[libdrop]=github.com/NordSecurity/libdrop-go
)

declare -A LIB_NAME_TO_VERSION
[[ -n "${LIBTELIO_VERSION:-}" ]] && LIB_NAME_TO_VERSION[libtelio]=$LIBTELIO_VERSION
[[ -n "${LIBDROP_VERSION:-}" ]] && LIB_NAME_TO_VERSION[libdrop]=$LIBDROP_VERSION

declare -A LIB_NAME_TO_BINDINGS_VERSION
[[ -n "${LIBTELIO_BINDINGS_VERSION:-}" ]] && LIB_NAME_TO_BINDINGS_VERSION[libtelio]=$LIBTELIO_BINDINGS_VERSION
[[ -n "${LIBTELIO_BINDINGS_VERSION:-}" ]] && LIB_NAME_TO_BINDINGS_VERSION[libdrop]=$LIBTELIO_BINDINGS_VERSION

lib_name=$1
bartoszWojciechO marked this conversation as resolved.
Show resolved Hide resolved
repo_path="${LIB_NAME_TO_PACKAGE[$lib_name]}"
lib_version="${LIB_NAME_TO_VERSION[$lib_name]:-}"
if [[ -z "${lib_version}" ]]; then
return 0
fi

bindings_version="${LIB_NAME_TO_BINDINGS_VERSION[$lib_name]:-}"

major_version=$(echo "${lib_version}" | cut -d'.' -f1)

full_package_path=$repo_path/$major_version@$lib_version
if [[ -n "${bindings_version}" ]]; then
full_package_path=$repo_path/$major_version@$bindings_version
fi

go get "$full_package_path"
Loading