Skip to content
Snippets Groups Projects

devTools/BuildAndIPFSify.sh : Misc fixes

Merged Emuis requested to merge (removed):fix_BuildAndIPFSify.sh into pregmod-master
1 file
+ 15
1
Compare changes
  • Side-by-side
  • Inline
@@ -5,6 +5,8 @@
@@ -5,6 +5,8 @@
# */15 * * * * cd ~/FC/fc-pregmod && git pull --ff-only origin pregmod-master > ~/FC/git_pull.log 2>&1
# */15 * * * * cd ~/FC/fc-pregmod && git pull --ff-only origin pregmod-master > ~/FC/git_pull.log 2>&1
# and do "ln -s ~/FC/fc-pregmod/devTools/BuildAndIPFSify.sh .git/hooks/post-merge"
# and do "ln -s ~/FC/fc-pregmod/devTools/BuildAndIPFSify.sh .git/hooks/post-merge"
 
rm bin/*.html
 
# if this script is used as the post-merge hook then
# if this script is used as the post-merge hook then
# a) git pull has pulled something
# a) git pull has pulled something
# b) $PWD is fc-pregmod
# b) $PWD is fc-pregmod
@@ -12,11 +14,22 @@ if [ "$(basename "$0")" != "post-merge" ]; then
@@ -12,11 +14,22 @@ if [ "$(basename "$0")" != "post-merge" ]; then
# cd to fc-pregmod based on where this script is
# cd to fc-pregmod based on where this script is
cd "$(readlink -f "$(dirname "$0")")/.." || exit 1
cd "$(readlink -f "$(dirname "$0")")/.." || exit 1
git pull
git pull
 
# if there are new html files then git probably pulled something and ran this script as a post-merge hook
 
if ls bin/*.html; then
 
exit 0
 
fi
 
fi
 
 
# If we've done this before then unpin the previous hash so IPFS can GC it if it needs to
 
if [ -r ../IPFS_hash.txt ]; then
 
ipfs pin rm --recursive=true "$(cut -d : -f 2 ../IPFS_hash.txt)"
fi
fi
rm bin/*.html
./compile || exit 1
./compile || exit 1
 
# Keep the build time from changing the hash of the file
 
sed -Ei -e '/^ \* Built on .+$/d' bin/*.html
 
# add the date of the last commit to the file, but don't use colons because Windows (still?) doesn't like them
# add the date of the last commit to the file, but don't use colons because Windows (still?) doesn't like them
mv bin/*.html "bin/FC pregmod $(git log -1 --format='%cd' --date='format:%F %H-%M').html"
mv bin/*.html "bin/FC pregmod $(git log -1 --format='%cd' --date='format:%F %H-%M').html"
@@ -27,6 +40,7 @@ if [ -e ../resources ]; then
@@ -27,6 +40,7 @@ if [ -e ../resources ]; then
else
else
ipfs_hash="$(ipfs add -w -Q bin/*.html)"
ipfs_hash="$(ipfs add -w -Q bin/*.html)"
fi
fi
 
echo "IPFS Folder Hash: ${ipfs_hash}" > ../IPFS_hash.txt
ipfs name publish "$ipfs_hash"
ipfs name publish "$ipfs_hash"
# when it's done it will print something like "Published to $your_pubkey: /ipfs/$ipfs_hash"
# when it's done it will print something like "Published to $your_pubkey: /ipfs/$ipfs_hash"
Loading