1
0
Fork 1
mirror of https://example.com synced 2024-11-24 23:06:38 +09:00

dev: use pnpm pkg set version to write version info

This commit is contained in:
naskya 2023-11-27 18:31:21 +09:00
parent 7dfc52b681
commit 74f7ef6b98
Signed by: naskya
GPG key ID: 164DFF24E2D40139
3 changed files with 4 additions and 6 deletions

View file

@ -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"

View file

@ -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

View file

@ -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}"
}