From 74f7ef6b9829b743ab14bfd9b50e84ffa323d0d5 Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 27 Nov 2023 18:31:21 +0900 Subject: [PATCH] dev: use `pnpm pkg set version` to write version info --- Dockerfile | 2 +- neko/update/native.sh | 5 +---- neko/update/utils | 3 ++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index dae340675..c64f1b05b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,7 @@ COPY . ./ # Write version info ARG VERSION ENV VERSION=${VERSION} -RUN sed -i -r "s/\"version\": \"([^+]+).*\",$/\"version\": \"\\1+neko:${VERSION}\",/" package.json +RUN pnpm pkg set version="${VERSION}" # Compile RUN env NODE_ENV=production sh -c "pnpm run --filter '!native-utils' build && pnpm run gulp" diff --git a/neko/update/native.sh b/neko/update/native.sh index 80cfe4fde..78dcf127a 100755 --- a/neko/update/native.sh +++ b/neko/update/native.sh @@ -24,10 +24,7 @@ fi # write version info say 'Writing version info to package.json...' -run "$(cat - << EOC -sed "s/\"version\": \"\([^+][^+]*\).*\",$/\"version\": \"\\1+neko:$(version)\",/" package.json > package.json.new && mv -- package.json.new package.json -EOC -)" +run "pnpm pkg set version=$(version)" say 'Done!' br diff --git a/neko/update/utils b/neko/update/utils index ad36922ef..0c17a88ad 100644 --- a/neko/update/utils +++ b/neko/update/utils @@ -22,7 +22,8 @@ br() { } 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.%s' "${COMMIT_DATE}" "${COMMIT_HASH_INITIAL}" + printf '%s+neko:%s.%s' "${UPSTREAM_VERSION}" "${COMMIT_DATE}" "${COMMIT_HASH_INITIAL}" }