Skip to content

Commit

Permalink
scripts: imp fmt, sign releases
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Nov 6, 2024
1 parent 80ec01d commit 4e33ec1
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 149 deletions.
58 changes: 26 additions & 32 deletions scripts/make/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

verbose="${VERBOSE:-0}"

if [ "$verbose" -gt '0' ]
then
if [ "$verbose" -gt '0' ]; then
set -x
debug_flags='--debug=1'
else
Expand All @@ -20,9 +19,8 @@ commit="${COMMIT:?please set COMMIT}"
dist_dir="${DIST_DIR:?please set DIST_DIR}"
readonly channel commit dist_dir

if [ "${VERSION:-}" = 'v0.0.0' ] || [ "${VERSION:-}" = '' ]
then
version="$( sh ./scripts/make/version.sh )"
if [ "${VERSION:-}" = 'v0.0.0' ] || [ "${VERSION:-}" = '' ]; then
version="$(sh ./scripts/make/version.sh)"
else
version="$VERSION"
fi
Expand All @@ -41,7 +39,7 @@ linux/arm64,\
linux/ppc64le"
readonly docker_platforms

build_date="$( date -u +'%Y-%m-%dT%H:%M:%SZ' )"
build_date="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
readonly build_date

# Set DOCKER_IMAGE_NAME to 'adguard/adguard-home' if you want (and are allowed)
Expand All @@ -59,27 +57,26 @@ readonly docker_image_name
docker_output="${DOCKER_OUTPUT:-type=image,name=${docker_image_name},push=false}"
readonly docker_output

case "$channel"
in
('release')
case "$channel" in
'release')
docker_version_tag="--tag=${docker_image_name}:${version}"
docker_channel_tag="--tag=${docker_image_name}:latest"
;;
('beta')
'beta')
docker_version_tag="--tag=${docker_image_name}:${version}"
docker_channel_tag="--tag=${docker_image_name}:beta"
;;
('edge')
'edge')
# Set the version tag to an empty string when pushing to the edge channel.
docker_version_tag=''
docker_channel_tag="--tag=${docker_image_name}:edge"
;;
('development')
'development')
# Set both tags to an empty string for development builds.
docker_version_tag=''
docker_channel_tag=''
;;
(*)
*)
echo "invalid channel '$channel', supported values are\
'development', 'edge', 'beta', and 'release'" 1>&2
exit 1
Expand All @@ -94,34 +91,31 @@ dist_docker="${dist_dir}/docker"
readonly dist_docker

mkdir -p "$dist_docker"
cp "${dist_dir}/AdGuardHome_linux_386/AdGuardHome/AdGuardHome"\
cp "${dist_dir}/AdGuardHome_linux_386/AdGuardHome/AdGuardHome" \
"${dist_docker}/AdGuardHome_linux_386_"
cp "${dist_dir}/AdGuardHome_linux_amd64/AdGuardHome/AdGuardHome"\
cp "${dist_dir}/AdGuardHome_linux_amd64/AdGuardHome/AdGuardHome" \
"${dist_docker}/AdGuardHome_linux_amd64_"
cp "${dist_dir}/AdGuardHome_linux_arm64/AdGuardHome/AdGuardHome"\
cp "${dist_dir}/AdGuardHome_linux_arm64/AdGuardHome/AdGuardHome" \
"${dist_docker}/AdGuardHome_linux_arm64_"
cp "${dist_dir}/AdGuardHome_linux_arm_6/AdGuardHome/AdGuardHome"\
cp "${dist_dir}/AdGuardHome_linux_arm_6/AdGuardHome/AdGuardHome" \
"${dist_docker}/AdGuardHome_linux_arm_v6"
cp "${dist_dir}/AdGuardHome_linux_arm_7/AdGuardHome/AdGuardHome"\
cp "${dist_dir}/AdGuardHome_linux_arm_7/AdGuardHome/AdGuardHome" \
"${dist_docker}/AdGuardHome_linux_arm_v7"
cp "${dist_dir}/AdGuardHome_linux_ppc64le/AdGuardHome/AdGuardHome"\
cp "${dist_dir}/AdGuardHome_linux_ppc64le/AdGuardHome/AdGuardHome" \
"${dist_docker}/AdGuardHome_linux_ppc64le_"

# Don't use quotes with $docker_version_tag and $docker_channel_tag, because we
# want word splitting and or an empty space if tags are empty.
#
# TODO(a.garipov): Once flag --tag of docker buildx build supports commas, use
# them instead.
$sudo_cmd docker\
"$debug_flags"\
buildx build\
--build-arg BUILD_DATE="$build_date"\
--build-arg DIST_DIR="$dist_dir"\
--build-arg VCS_REF="$commit"\
--build-arg VERSION="$version"\
--output "$docker_output"\
--platform "$docker_platforms"\
$docker_version_tag\
$docker_channel_tag\
-f ./docker/Dockerfile\
.
#
# shellcheck disable=SC2086
$sudo_cmd docker "$debug_flags" \
buildx build --build-arg BUILD_DATE="$build_date" \
--build-arg DIST_DIR="$dist_dir" \
--build-arg VCS_REF="$commit" \
--build-arg VERSION="$version" \
--output "$docker_output" \
--platform "$docker_platforms" \
$docker_version_tag $docker_channel_tag -f ./docker/Dockerfile .
Loading

0 comments on commit 4e33ec1

Please sign in to comment.