Update version with zero padded commit count

This commit is contained in:
LukeZGD 2023-04-02 22:16:32 +08:00
parent 978a59efd5
commit a021f6f0ce
2 changed files with 3 additions and 3 deletions

View File

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

View File

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