Created
June 16, 2024 20:16
-
-
Save jessitron/ebfd8bd3bc488c0ca367dacd641a5654 to your computer and use it in GitHub Desktop.
updating the version number after the deploy, by editing the deploy script
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/sh | |
# do something with a version number, and then increment the version number in this script. | |
# Is this a good idea? No claims made. | |
set -e # exit on fail | |
set -x # print what you're doing | |
me=$0 # name of this script | |
VERSION_NUMBER=5 | |
## Do stuff with the version number | |
echo "I am $me, with version number $VERSION_NUMBER" | |
## Now change this script to increment the version number, so next time it will be different. | |
function sed_in_place { | |
expr=$1 | |
file=$2 | |
backup=$file.bak | |
sed "$expr" $file > $file.bak | |
chmod `stat -f %A $file` $file.bak # this works on mac, to copy file permissions. | |
mv $file.bak $file | |
} | |
sed_in_place "s/VERSION_NUMBER=$VERSION_NUMBER/VERSION_NUMBER=$(( VERSION_NUMBER + 1 ))/" $me |
wouldn't that be lovely? 😢
The version of sed
on my mac doesn't have it. Same with chmod --reference
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Came here from your blog to ask: Is there a particular reason against using
sed --in-place
? 🤔