kawipiko/scripts/deploy.z-run

266 lines
8.1 KiB
Text
Raw Normal View History

#!/dev/null
::// deploy / ...
--:: deploy / rsync / * / linux / x86_64 :: exec -- "${ZRUN[@]}" ':: deploy / rsync / *' linux--x86_64 "${@}"
--:: deploy / rsync / * / linux / x86_64 / seccomp :: exec -- "${ZRUN[@]}" ':: deploy / rsync / *' linux--x86_64--seccomp "${@}"
--:: deploy / rsync / * / darwin / x86_64 :: exec -- "${ZRUN[@]}" ':: deploy / rsync / *' darwin--x86_64 "${@}"
--:: deploy / rsync / * / darwin / aarch64 :: exec -- "${ZRUN[@]}" ':: deploy / rsync / *' darwin--aarch64 "${@}"
--:: deploy / rsync / * / freebsd / x86_64 :: exec -- "${ZRUN[@]}" ':: deploy / rsync / *' freebsd--x86_64 "${@}"
--:: deploy / rsync / * / openbsd / x86_64 :: exec -- "${ZRUN[@]}" ':: deploy / rsync / *' openbsd--x86_64 "${@}"
--:: deploy / rsync / * / android / aarch64 :: exec -- "${ZRUN[@]}" ':: deploy / rsync / *' android--aarch64 "${@}"
--<< deploy / rsync / *
test "${#}" -eq 3 ; _os="${1}" ; _main="${2}" ; _target="${3}" ; shift -- 3
"${ZRUN[@]}" ':: deploy / release' "${_os}" "${_main}"
_source="./.outputs/binaries/publish/${_main}--${_os}"
printf -- '[ii] deploying `%s` for `%s` to `%s`...\n' "${_main}" "${_os}" "${_target}" >&2
exec -- rsync -i -t -p --chmod=0555 -- "${_source}" "${_target}"
!!
<< deploy / publish / no-github
export -- __DEPLOY_NOGITHUB=true
exec -- "${ZRUN[@]}" ':: deploy / publish' "${@}"
!!
<< deploy / publish
if test "${#}" -eq 0 ; then
_main_0=all
else
_main_0="${1}"
shift -- 1
fi
test "${#}" -eq 0
test -d ./.publish/
"${ZRUN[@]}" ':: documentation / all / render / forced'
"${ZRUN[@]}" ':: sources / embedded / bundle'
if test "${__DEPLOY_NOGITHUB:-}" == true ; then
_github_publish=false
else
_github_publish=true
fi
_build_version="$( exec -- cat -- ./sources/embedded/build/version.txt )"
case "${_build_version}" in
( 0.0.0 | *.0 )
_build_release=false
_build_suffix='--preview'
;;
( * )
_build_release=true
_build_suffix=''
;;
esac
if test "${_build_release}" == true ; then
for _main in kawipiko-wrapper kawipiko-archiver kawipiko-server kawipiko-server-dummy ; do
if test "${_main_0}" != all -a "${_main_0}" != "${_main}" ; then
continue
fi
for _os in linux--x86_64 linux--x86_64--seccomp darwin--x86_64 darwin--aarch64 freebsd--x86_64 openbsd--x86_64 android--aarch64 ; do
case "${_main}::${_os}" in
( kawipiko-server::linux--x86_64--seccomp ) ;;
( *::linux--x86_64--seccomp ) continue ;;
esac
if test -e "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}" ; then
printf -- '[ee] release already exists for `%s` for `%s`!\n' "${_main}" "${_os}" >&2
exit -- 1
fi
done
done
fi
if test "${_github_publish}" == true ; then
if ! git diff --quiet ; then
printf -- '[ee] dirty repository (before build); aborting!\n' >&2
exit -- 1
fi
if ! git diff --cached --quiet ; then
printf -- '[ee] dirty repository (before build); aborting!\n' >&2
exit -- 1
fi
fi
printf -- '[ii] releasing all for `%s`...\n' "${_build_version}${_build_suffix}" >&2
"${ZRUN[@]}" ':: deploy / release' all "${_main_0}"
if test "${_github_publish}" == true ; then
if ! git diff --quiet ; then
printf -- '[ee] dirty repository (after build); aborting!\n' >&2
exit -- 1
fi
if ! git diff --cached --quiet ; then
printf -- '[ee] dirty repository (after build); aborting!\n' >&2
exit -- 1
fi
printf -- '[ii] tagging and pushing for `%s`...\n' "${_build_version}${_build_suffix}" >&2
printf -- '[--]\n' >&2
if test "${_build_release}" == true ; then
git tag --sign -m "[release] Release \`v${_build_version}\`." -- "v${_build_version}" HEAD
else
git tag --sign -m "[preview] Preview \`v${_build_version}\`." --force -- preview HEAD
fi
"${ZRUN[@]}" ':: github / push'
printf -- '[--]\n' >&2
fi
printf -- '[ii] publishing all for `%s`...\n' "${_build_version}${_build_suffix}" >&2
for _os in linux--x86_64 linux--x86_64--seccomp darwin--x86_64 darwin--aarch64 freebsd--x86_64 openbsd--x86_64 android--aarch64 ; do
for _main in kawipiko-wrapper kawipiko-archiver kawipiko-server kawipiko-server-dummy ; do
if test "${_main_0}" != all -a "${_main_0}" != "${_main}" ; then
continue
fi
case "${_main}::${_os}" in
( kawipiko-server::linux--x86_64--seccomp ) ;;
( *::linux--x86_64--seccomp ) continue ;;
esac
printf -- '[ii] publishing `%s` for `%s` for `%s`...\n' "${_main}" "${_os}" "${_build_version}${_build_suffix}" >&2
printf -- '[--]\n' >&2
rsync -i -t -p --chmod=0555 -- \
"./.outputs/binaries/publish/${_main}--${_os}" \
"./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}" \
#
if test -e "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}.asc" ; then
if ! gpg2 --verify -- \
"./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}.asc" \
< /dev/null > /dev/null 2> /dev/null \
; then
rm -- "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}.asc"
fi
fi
if test ! -e "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}.asc" ; then
for _retry in 1 2 3 4 ; do
if gpg2 --sign --detach-sign --armor \
--default-key 58FC2194FCC2478399CB220C5A974037A6FD8839 \
--output "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}.asc" \
-- "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}" \
; then break ; fi
done
fi
gpg2 --verify \
-- "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}.asc" \
#
if test "${_build_release}" == true ; then
ln -s -T -f -- "./${_main}--${_os}--v${_build_version}${_build_suffix}" "./.publish/${_os}/${_main}${_build_suffix}"
ln -s -T -f -- "./${_main}--${_os}--v${_build_version}${_build_suffix}.asc" "./.publish/${_os}/${_main}${_build_suffix}.asc"
fi
printf -- '[--]\n' >&2
done
done
if test "${_github_publish}" == true ; then
printf -- '[ii] publishing all for `%s` (on GitHub)...\n' "${_build_version}${_build_suffix}" >&2
for _os in linux--x86_64 linux--x86_64--seccomp darwin--x86_64 darwin--aarch64 freebsd--x86_64 openbsd--x86_64 android--aarch64 ; do
for _main in kawipiko-wrapper kawipiko-archiver kawipiko-server kawipiko-server-dummy ; do
if test "${_main_0}" != all -a "${_main_0}" != "${_main}" ; then
continue
fi
case "${_main}::${_os}" in
( kawipiko-server::linux--x86_64--seccomp ) ;;
( *::linux--x86_64--seccomp ) continue ;;
esac
printf -- '[ii] publishing `%s` for `%s` for `%s` (on GitHub)...\n' "${_main}" "${_os}" "${_build_version}${_build_suffix}" >&2
if test "${_build_release}" == true ; then
gh release upload --clobber -- "v${_build_version}" \
"./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}" \
"./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}.asc" \
#
else
gh release upload --clobber -- preview \
"./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}" \
"./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}.asc" \
#
fi
done
done
fi
!!
<< deploy / release
if test "${#}" -ge 1 ; then
_os_0="${1}"
shift -- 1
else
_os_0='all'
fi
if test "${#}" -ge 1 ; then
_main_0="${1}"
shift -- 1
else
_main_0=all
fi
test "${#}" -eq 0
if test "${__DEPLOY_NORELEASE:-}" == true ; then
exit -- 0
fi
for _main in kawipiko-wrapper kawipiko-archiver kawipiko-server kawipiko-server-dummy ; do
if test "${_main_0}" != all -a "${_main_0}" != "${_main}" ; then
continue
fi
for _os in linux--x86_64 linux--x86_64--seccomp darwin--x86_64 darwin--aarch64 freebsd--x86_64 openbsd--x86_64 android--aarch64 ; do
if test "${_os_0}" != all -a "${_os_0}" != "${_os}" ; then
continue
fi
case "${_main}::${_os}" in
( kawipiko-server::linux--x86_64--seccomp ) ;;
( *::linux--x86_64--seccomp ) continue ;;
esac
"${ZRUN[@]}" ':: go / build / all / publish' "${_os}" "${_main#kawipiko-}"
done
done
!!