File bin/modules/archive.sh

Last commit: Mon Dec 9 22:31:34 2024 +0100	Jan Dankert	More Output
1 #!/bin/bash 2 3 if [ ! -d $archive_dir ]; then 4 echo "$archive_dir does not exist" 5 return 4 6 fi 7 8 if [ ! -d $archive_dir/$REPO_NAME ]; then 9 mkdir $archive_dir/$REPO_NAME 10 if [ $? -ne 0 ]; then 11 echo "mkdir of $archive_dir/$REPO_NAME FAILED" 12 return 4 13 fi 14 fi 15 16 if [ $(git rev-list --count --all) == "0" ]; then 17 echo "There are no commits in this repository. Nothing to do." 18 return 0 19 fi 20 21 echo "archiving latest..." 22 23 if [ $? -ne 0 ]; then 24 echo "archive FAILED" 25 return 4 26 fi 27 28 tags=() 29 tags+=("latest") 30 outfile="$archive_dir/$REPO_NAME/$REPO_NAME-latest.tar.gz" 31 git archive --format tar.gz --output=$outfile HEAD 32 33 34 if [ $? -ne 0 ]; then 35 echo "archive FAILED" 36 return 4 37 fi 38 39 echo "Searching for git tags..." 40 for tag in `git tag`; do 41 echo "... found tag $tag" 42 archive_file=$archive_dir/$REPO_NAME/$REPO_NAME-$tag.tar.gz 43 tags+=($tag) 44 if [ ! -f $archive_file ]; then 45 echo "Creating archive file for '$tag'" 46 git archive --format tar.gz --output=$archive_file $tag 47 if [ $? -ne 0 ]; then 48 echo "Archive FAILED" 49 return 4 50 fi 51 52 fi 53 done 54 55 ( 56 echo "<!DOCTYPE html><html><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=2\" /><title>Download - $repo_project_name</title></head><body>"; 57 echo "<h1>$repo_project_name</h1>" 58 echo "<p>$repo_project_description</p>" 59 echo "<pre>" 60 for t in "${tags[@]}"; do 61 echo "<a href=\"./${REPO_NAME}-$t.tar.gz\">$t</a>"; 62 done 63 echo "</pre></body></html>" 64 ) > $archive_dir/$REPO_NAME/index.html 65 66 ( 67 echo "<!DOCTYPE html><html><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=2\" /></head><body><pre>"; 68 ( cd $archive_dir; find . -type d -printf '<a href="./%P">%P</a>\n'); 69 echo "</pre></body></html>" 70 ) > $archive_dir/index.html 71 72 if [ -n "$archive_ssh_host" ]; then 73 echo "Syncing to $archive_ssh_host ..." 74 rsync -av -e ssh $archive_dir/ $archive_ssh_user@$archive_ssh_host:$archive_ssh_path 75 fi
Download bin/modules/archive.sh
History Mon, 9 Dec 2024 22:31:34 +0100 Jan Dankert More Output Sun, 8 Dec 2024 22:33:23 +0100 Jan Dankert Modules can be disabled by project configuration Wed, 27 Nov 2024 01:03:39 +0100 Jan Dankert Fix: Output all Tags in Downloads. Tue, 26 Nov 2024 23:26:36 +0100 Jan Dankert New: Creating a project website Sun, 12 May 2024 19:53:02 +0200 Jan Dankert first edition of DIT, the delivery expert.