ci: Many fixes and updates
This commit is contained in:
parent
84141efe37
commit
0df3d4d15b
8 changed files with 104 additions and 47 deletions
3
Makefile
3
Makefile
|
|
@ -9,6 +9,9 @@ endif
|
|||
.PHONY: fmt
|
||||
fmt:
|
||||
prefix "$@" ./ci/sub/fmt/make.sh
|
||||
.PHONY: fmt-release
|
||||
fmt-release_sh:
|
||||
prefix "$@" ./ci/release/gen_sh.sh
|
||||
.PHONY: lint
|
||||
lint:
|
||||
prefix "$@" go vet --composites=false ./...
|
||||
|
|
|
|||
|
|
@ -167,13 +167,14 @@ build_remote_macos() {
|
|||
trap unlockfile_ssh EXIT
|
||||
sh_c ssh "$REMOTE_HOST" mkdir -p src
|
||||
sh_c rsync --archive --human-readable --delete ./ "$REMOTE_HOST:src/d2/"
|
||||
sh_c ssh "$REMOTE_HOST" "DRY_RUN=${DRY_RUN-} \
|
||||
sh_c ssh "$REMOTE_HOST" "COLOR=${COLOR-} \
|
||||
TERM=${TERM-} \
|
||||
DRY_RUN=${DRY_RUN-} \
|
||||
HW_BUILD_DIR=$HW_BUILD_DIR \
|
||||
VERSION=$VERSION \
|
||||
OS=$OS \
|
||||
ARCH=$ARCH \
|
||||
ARCHIVE=$ARCHIVE \
|
||||
TERM=$TERM \
|
||||
PATH=\\\"/usr/local/bin:/usr/local/sbin:/opt/homebrew/bin:/opt/homebrew/sbin\\\${PATH+:\\\$PATH}\\\" \
|
||||
./src/d2/ci/release/_build.sh"
|
||||
sh_c mkdir -p "$HW_BUILD_DIR"
|
||||
|
|
@ -185,13 +186,14 @@ build_remote_linux() {
|
|||
trap unlockfile_ssh EXIT
|
||||
sh_c ssh "$REMOTE_HOST" mkdir -p src
|
||||
sh_c rsync --archive --human-readable --delete ./ "$REMOTE_HOST:src/d2/"
|
||||
sh_c ssh "$REMOTE_HOST" "DRY_RUN=${DRY_RUN-} \
|
||||
sh_c ssh "$REMOTE_HOST" "COLOR=${COLOR-} \
|
||||
TERM=${TERM-} \
|
||||
DRY_RUN=${DRY_RUN-} \
|
||||
HW_BUILD_DIR=$HW_BUILD_DIR \
|
||||
VERSION=$VERSION \
|
||||
OS=$OS \
|
||||
ARCH=$ARCH \
|
||||
ARCHIVE=$ARCHIVE \
|
||||
TERM=$TERM \
|
||||
./src/d2/ci/release/build_docker.sh"
|
||||
sh_c mkdir -p "$HW_BUILD_DIR"
|
||||
sh_c rsync --archive --human-readable "$REMOTE_HOST:src/d2/$ARCHIVE" "$ARCHIVE"
|
||||
|
|
|
|||
|
|
@ -13,5 +13,4 @@ docker_run \
|
|||
-e OS \
|
||||
-e ARCH \
|
||||
-e ARCHIVE \
|
||||
-e TERM \
|
||||
"$tag" ./src/d2/ci/release/_build.sh
|
||||
|
|
|
|||
|
|
@ -37,3 +37,7 @@ sh_c cat \
|
|||
sh_c cat ./ci/release/_install.sh \
|
||||
\| sed -n "'/cd -- \"\$(dirname/,/cd -/!p'" \>\> install.sh
|
||||
sh_c chmod -w install.sh
|
||||
|
||||
if [ -n "${CI-}" ]; then
|
||||
git_assert_clean
|
||||
fi
|
||||
|
|
|
|||
11
ci/release/gen_sh.sh
Executable file
11
ci/release/gen_sh.sh
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
cd -- "$(dirname "$0")/../.."
|
||||
. ./ci/sub/lib.sh
|
||||
|
||||
./ci/release/gen_install.sh
|
||||
./ci/release/gen_template_lib.sh
|
||||
|
||||
if [ -n "${CI-}" ]; then
|
||||
git_assert_clean
|
||||
fi
|
||||
|
|
@ -27,3 +27,7 @@ sh_c cat \
|
|||
./ci/sub/lib/log.sh \
|
||||
\| sed "-e'/^\. /d'" \>\>./ci/release/template/scripts/lib.sh
|
||||
sh_c chmod -w ./ci/release/template/scripts/lib.sh
|
||||
|
||||
if [ -n "${CI-}" ]; then
|
||||
git_assert_clean
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -47,23 +47,32 @@ if [ -n "${DEBUG-}" ]; then
|
|||
set -x
|
||||
fi
|
||||
|
||||
export COLOR
|
||||
if ! [ "${COLOR-}" = 0 -o "${COLOR-}" = false ]; then
|
||||
if [ "${COLOR-}" = 1 -o "${COLOR-}" = true -o -t 1 ]; then
|
||||
export _COLOR=1
|
||||
fi
|
||||
fi
|
||||
|
||||
tput() {
|
||||
if [ "${COLOR-}" = 0 -o "${COLOR-}" = false ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "${COLOR-}" = 1 -o "${COLOR-}" = true -o -t 1 ]; then
|
||||
if should_color; then
|
||||
TERM=${TERM:-xterm-256color} command tput "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
should_color() {
|
||||
if [ -n "${COLOR-}" ]; then
|
||||
if [ "${COLOR-}" = 0 -o "${COLOR-}" = false ]; then
|
||||
_COLOR=0
|
||||
return 1
|
||||
elif [ "${COLOR-}" = 1 -o "${COLOR-}" = true ]; then
|
||||
_COLOR=1
|
||||
return 0
|
||||
else
|
||||
printf '$COLOR must be 0, 1, false or true but got %s' "$COLOR" >&2
|
||||
fi
|
||||
fi
|
||||
if [ -t 1 ]; then
|
||||
_COLOR=1
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
setaf() {
|
||||
tput setaf "$1"
|
||||
shift
|
||||
|
|
@ -100,10 +109,10 @@ printfp() {(
|
|||
if [ -z "${FGCOLOR-}" ]; then
|
||||
FGCOLOR="$(get_rand_color "$prefix")"
|
||||
fi
|
||||
printf '%s' "$(setaf "$FGCOLOR" "$prefix")"
|
||||
setaf "$FGCOLOR" "[$prefix]"
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
printf ': '
|
||||
printf ' '
|
||||
printf "$@"
|
||||
fi
|
||||
)}
|
||||
|
|
@ -112,7 +121,8 @@ catp() {
|
|||
prefix="$1"
|
||||
shift
|
||||
|
||||
sed "s/^/$(printfp "$prefix" '')/"
|
||||
should_color || true
|
||||
sed "s/^/$(COLOR=${_COLOR-} printfp "$prefix" '')/"
|
||||
}
|
||||
|
||||
repeat() {
|
||||
|
|
@ -126,27 +136,30 @@ strlen() {
|
|||
}
|
||||
|
||||
echoerr() {
|
||||
FGCOLOR=1 echop err "$*" | humanpath>&2
|
||||
FGCOLOR=1 logp err "$*" | humanpath>&2
|
||||
}
|
||||
|
||||
caterr() {
|
||||
FGCOLOR=1 catp err "$@" | humanpath >&2
|
||||
FGCOLOR=1 logpcat err "$@" | humanpath >&2
|
||||
}
|
||||
|
||||
printferr() {
|
||||
FGCOLOR=1 printfp err "$@" | humanpath >&2
|
||||
FGCOLOR=1 logfp err "$@" | humanpath >&2
|
||||
}
|
||||
|
||||
logp() {
|
||||
echop "$@" | humanpath >&2
|
||||
should_color >&2 || true
|
||||
COLOR=${_COLOR-} echop "$@" | humanpath >&2
|
||||
}
|
||||
|
||||
logfp() {
|
||||
printfp "$@" | humanpath >&2
|
||||
should_color >&2 || true
|
||||
COLOR=${_COLOR-} printfp "$@" | humanpath >&2
|
||||
}
|
||||
|
||||
logpcat() {
|
||||
catp "$@" | humanpath >&2
|
||||
should_color >&2 || true
|
||||
COLOR=${_COLOR-} catp "$@" | humanpath >&2
|
||||
}
|
||||
|
||||
log() {
|
||||
|
|
@ -169,6 +182,10 @@ warnf() {
|
|||
FGCOLOR=3 logfp warn "$@"
|
||||
}
|
||||
|
||||
warncat() {
|
||||
FGCOLOR=3 logpcat warn "$@"
|
||||
}
|
||||
|
||||
sh_c() {
|
||||
FGCOLOR=3 logp exec "$*"
|
||||
if [ -z "${DRY_RUN-}" ]; then
|
||||
|
|
|
|||
59
install.sh
59
install.sh
|
|
@ -53,23 +53,32 @@ if [ -n "${DEBUG-}" ]; then
|
|||
set -x
|
||||
fi
|
||||
|
||||
export COLOR
|
||||
if ! [ "${COLOR-}" = 0 -o "${COLOR-}" = false ]; then
|
||||
if [ "${COLOR-}" = 1 -o "${COLOR-}" = true -o -t 1 ]; then
|
||||
export _COLOR=1
|
||||
fi
|
||||
fi
|
||||
|
||||
tput() {
|
||||
if [ "${COLOR-}" = 0 -o "${COLOR-}" = false ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "${COLOR-}" = 1 -o "${COLOR-}" = true -o -t 1 ]; then
|
||||
if should_color; then
|
||||
TERM=${TERM:-xterm-256color} command tput "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
should_color() {
|
||||
if [ -n "${COLOR-}" ]; then
|
||||
if [ "${COLOR-}" = 0 -o "${COLOR-}" = false ]; then
|
||||
_COLOR=0
|
||||
return 1
|
||||
elif [ "${COLOR-}" = 1 -o "${COLOR-}" = true ]; then
|
||||
_COLOR=1
|
||||
return 0
|
||||
else
|
||||
printf '$COLOR must be 0, 1, false or true but got %s' "$COLOR" >&2
|
||||
fi
|
||||
fi
|
||||
if [ -t 1 ]; then
|
||||
_COLOR=1
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
setaf() {
|
||||
tput setaf "$1"
|
||||
shift
|
||||
|
|
@ -106,10 +115,10 @@ printfp() {(
|
|||
if [ -z "${FGCOLOR-}" ]; then
|
||||
FGCOLOR="$(get_rand_color "$prefix")"
|
||||
fi
|
||||
printf '%s' "$(setaf "$FGCOLOR" "$prefix")"
|
||||
setaf "$FGCOLOR" "[$prefix]"
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
printf ': '
|
||||
printf ' '
|
||||
printf "$@"
|
||||
fi
|
||||
)}
|
||||
|
|
@ -118,7 +127,8 @@ catp() {
|
|||
prefix="$1"
|
||||
shift
|
||||
|
||||
sed "s/^/$(printfp "$prefix" '')/"
|
||||
should_color || true
|
||||
sed "s/^/$(COLOR=${_COLOR-} printfp "$prefix" '')/"
|
||||
}
|
||||
|
||||
repeat() {
|
||||
|
|
@ -132,27 +142,30 @@ strlen() {
|
|||
}
|
||||
|
||||
echoerr() {
|
||||
FGCOLOR=1 echop err "$*" | humanpath>&2
|
||||
FGCOLOR=1 logp err "$*" | humanpath>&2
|
||||
}
|
||||
|
||||
caterr() {
|
||||
FGCOLOR=1 catp err "$@" | humanpath >&2
|
||||
FGCOLOR=1 logpcat err "$@" | humanpath >&2
|
||||
}
|
||||
|
||||
printferr() {
|
||||
FGCOLOR=1 printfp err "$@" | humanpath >&2
|
||||
FGCOLOR=1 logfp err "$@" | humanpath >&2
|
||||
}
|
||||
|
||||
logp() {
|
||||
echop "$@" | humanpath >&2
|
||||
should_color >&2 || true
|
||||
COLOR=${_COLOR-} echop "$@" | humanpath >&2
|
||||
}
|
||||
|
||||
logfp() {
|
||||
printfp "$@" | humanpath >&2
|
||||
should_color >&2 || true
|
||||
COLOR=${_COLOR-} printfp "$@" | humanpath >&2
|
||||
}
|
||||
|
||||
logpcat() {
|
||||
catp "$@" | humanpath >&2
|
||||
should_color >&2 || true
|
||||
COLOR=${_COLOR-} catp "$@" | humanpath >&2
|
||||
}
|
||||
|
||||
log() {
|
||||
|
|
@ -175,6 +188,10 @@ warnf() {
|
|||
FGCOLOR=3 logfp warn "$@"
|
||||
}
|
||||
|
||||
warncat() {
|
||||
FGCOLOR=3 logpcat warn "$@"
|
||||
}
|
||||
|
||||
sh_c() {
|
||||
FGCOLOR=3 logp exec "$*"
|
||||
if [ -z "${DRY_RUN-}" ]; then
|
||||
|
|
|
|||
Loading…
Reference in a new issue