From a021f6f0cee893371c4f5dfbb1d7e67425868aa2 Mon Sep 17 00:00:00 2001 From: LukeZGD <26163116+LukeZGD@users.noreply.github.com> Date: Sun, 2 Apr 2023 22:16:32 +0800 Subject: [PATCH] Update version with zero padded commit count --- .github/workflows/build.yml | 2 +- restore.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 25e63ee..1c33ecb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: run: | sudo timedatectl set-timezone Asia/Singapore echo "DATE=$(date +%y.%m)" >> $GITHUB_ENV - echo "COUNT=$(git rev-list --count HEAD --since=$(date +%Y-%m-01))" >> $GITHUB_ENV + echo "COUNT=$(git rev-list --count HEAD --since=$(date --date="$(date +%Y-%m-01) - 1 second" +%s) | xargs printf "%02d")" >> $GITHUB_ENV echo "SHA_SHORT=$(echo ${{ github.sha }} | cut -c -7)" >> $GITHUB_ENV echo "DATE_OLD=$(date +%Y-%m-%d)" >> $GITHUB_ENV diff --git a/restore.sh b/restore.sh index a564e2c..569dc7d 100755 --- a/restore.sh +++ b/restore.sh @@ -362,9 +362,9 @@ version_check() { if [[ -d .git ]]; then git_hash=$(git rev-parse HEAD | cut -c -7) if [[ $platform == "macos" ]]; then - version_current=v$(date +%y.%m).$(git rev-list --count HEAD --since=$(date -j -f "%Y-%m-%d %H:%M:%S" "$(date -v1d -v-1d +%Y-%m-%d) 23:59:59" +%s)) + version_current=v$(date +%y.%m).$(git rev-list --count HEAD --since=$(date -j -f "%Y-%m-%d %H:%M:%S" "$(date -v1d -v-1d +%Y-%m-%d) 23:59:59" +%s) | xargs printf "%02d") else - version_current=v$(date +%y.%m).$(git rev-list --count HEAD --since=$(date --date="$(date +%Y-%m-01) - 1 second" +%s)) + version_current=v$(date +%y.%m).$(git rev-list --count HEAD --since=$(date --date="$(date +%Y-%m-01) - 1 second" +%s) | xargs printf "%02d") fi elif [[ -e ./resources/git_hash ]]; then version="$(cat ./resources/version)"