]> BookStack Code Mirror - devops/commitdiff
Added script to create & store ZIPped vendor directories
authorDan Brown <redacted>
Mon, 10 Mar 2025 15:41:59 +0000 (15:41 +0000)
committerDan Brown <redacted>
Mon, 10 Mar 2025 15:41:59 +0000 (15:41 +0000)
Related to https://github.com/BookStackApp/BookStack/issues/161

meta-scripts/bookstack-release-steps
meta-scripts/bookstack-store-vendor [new file with mode: 0644]

index 745537f74b430ff1160589425eb9e9f20c2a52e2..226663efa2d811c9dd480373f7164b9ca1ac6865 100755 (executable)
@@ -24,6 +24,10 @@ echo "echo \"${version}\" > version"
 echo "git commit -a -m \"Updated version and assets for release ${version}\""
 echo ""
 
+echo -e "\e[1m\e[94m== Build and upload bundles ==\e[0m"
+echo "bookstack-store-vendor"
+echo ""
+
 echo -e "\e[1m\e[94m== Tag release and push it to GitHub ==\e[0m"
 echo "git tag -a ${version} -m \"Release ${version}\" -s"
 echo "git push origin release"
@@ -34,7 +38,6 @@ echo ""
 echo -e "\e[1m\e[94m== Post Deployment Checklist ==\e[0m"
 echo "✔ Create GitHub release - https://github.com/BookStackApp/BookStack/releases/new?tag=${version}&title=BookStack+${version}"
 echo "✔ Deploy site blogpost/changes"
-echo "✔ Post on Twitter - https://twitter.com/share?url=${blogpost_url}"
 echo "✔ Post on Mastodon - https://fosstodon.org/share?url=${blogpost_url}"
 echo "✔ Post on Subreddit - http://www.reddit.com/r/BookStack/submit?url=${blogpost_url}"
 echo "✔ Update demo instance"
diff --git a/meta-scripts/bookstack-store-vendor b/meta-scripts/bookstack-store-vendor
new file mode 100644 (file)
index 0000000..d1d950f
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+TARGET_HOST="bs-site"
+TARGET_DIR="/var/www/files.bookstackapp.com/vendor"
+
+# Ensure the current working dir is a BookStack install
+if [ ! -f "version" ] || [ ! -f "composer.lock" ]; then
+    echo "Error: Are you in a BookStack install directory? Could not find version or compose.lock files"
+    exit 1
+fi
+
+# Get the version from file and trim whitespace
+VERSION=$(cat version | tr -d '[:space:]')
+if [[ $VERSION != v* ]]; then
+    echo "Error: Found version ($VERSION) does not appear to be valid"
+    exit 1
+fi
+
+echo "Rebuilding vendor directory..."
+rm -rf "vendor"
+composer install --no-dev
+
+echo "Creating ${ZIP_FILENAME}..."
+ZIP_FILENAME="${VERSION}.zip"
+zip -r "${ZIP_FILENAME}" vendor/
+if [ ! -f "${ZIP_FILENAME}" ]; then
+    echo "Error: Failed to create ZIP file"
+    exit 1
+fi
+
+echo "Saving SHA-256 has of ZIP to vendor_hash file..."
+ZIP_SHA=$(sha256sum "${ZIP_FILENAME}" | cut -d ' ' -f 1)
+echo -n "$ZIP_SHA" > vendor_hash
+
+echo "Checking if ZIP already exists on server..."
+if ssh "${TARGET_HOST}" "test -e ${TARGET_DIR}/${ZIP_FILENAME}"; then
+    echo "Error: ZIP file already exists at ${TARGET_DIR}/${ZIP_FILENAME}"
+    exit 1
+fi
+
+echo "Uploading ${ZIP_FILENAME} to server..."
+scp "${ZIP_FILENAME}" "${TARGET_HOST}:${TARGET_DIR}/${ZIP_FILENAME}"
+UPLOAD_RESULT="$?"
+if [ $UPLOAD_RESULT -ne 0 ]; then
+    #statements
+    echo "Error: Upload via scp failed with error code ${UPLOAD_RESULT}"
+    exit 1
+fi
+
+echo "Vendor ZIP creation and update complete!"
+echo "File stored at: https://files.bookstackapp.com/vendor/${ZIP_FILENAME}"
+echo "File sha256: ${ZIP_SHA}"
\ No newline at end of file