1
0
Fork 1
mirror of https://example.com synced 2024-11-23 08:36:38 +09:00
firefish/neko/update/utils

36 lines
919 B
Text

color() {
if [ -t 1 ]; then
tput setaf "${1:-7}"
fi
}
say() {
color 5 # magenta
printf '( ^-^) < %s\n' "$1"
color
}
run() {
color 3 # yellow
printf '[running] $ %s\n' "$1"
color
/bin/sh -c "$1"
}
br() {
printf '\n'
}
version() {
UPSTREAM_VERSION=$(pnpm pkg get version | sed -e 's/"//g')
COMMIT_DATE=$(git show --no-patch --pretty='%cs' FETCH_HEAD | sed -e 's/-//g' | cut -c 3-)
COMMIT_HASH_INITIAL=$(printf '%s' "$(git rev-parse FETCH_HEAD)" | cut -c 1)
printf '%s+neko:%s.%s' "${UPSTREAM_VERSION}" "${COMMIT_DATE}" "${COMMIT_HASH_INITIAL}"
}
version_ci() {
UPSTREAM_VERSION=$(grep '"version":' package.json | cut -d '"' -f 4)
COMMIT_DATE=$(git show --no-patch --pretty='%cs' HEAD | sed -e 's/-//g' | cut -c 3-)
COMMIT_HASH_INITIAL=$(printf '%s' "$(git rev-parse HEAD)" | cut -c 1)
printf '%s+neko:%s.%s' "${UPSTREAM_VERSION}" "${COMMIT_DATE}" "${COMMIT_HASH_INITIAL}"
}