Last active
November 14, 2024 08:44
-
-
Save fishyer/08ea07cc17d8ae811404902bf9831d0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "✅pre-commit hook start at $(date)" | |
start_time=$(date +%s) | |
# 添加环境变量 | |
source .env | |
echo "👁️build_version: $build_version" | |
echo "👁️build_time: $build_time" | |
# 将环境变量的第三位加1 | |
build_version=$(echo $build_version | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g') | |
echo "📝new build_version: $build_version" | |
gsed -i "s/^build_version=.*/build_version=$build_version/" .env | |
build_time=$(date +"%Y-%m-%d %H:%M:%S") | |
echo "📝new build_time: $build_time" | |
gsed -i 's/^build_time=.*/build_time="'"$build_time"'"/' .env | |
echo "🎉pre-commit hook end at $(date) elapsed $(($(date +%s) - $start_time)) seconds" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment