summaryrefslogtreecommitdiffstats
path: root/apps/portal/build_and_push.sh
diff options
context:
space:
mode:
Diffstat (limited to 'apps/portal/build_and_push.sh')
-rwxr-xr-xapps/portal/build_and_push.sh98
1 files changed, 98 insertions, 0 deletions
diff --git a/apps/portal/build_and_push.sh b/apps/portal/build_and_push.sh
new file mode 100755
index 0000000..3beff5e
--- /dev/null
+++ b/apps/portal/build_and_push.sh
@@ -0,0 +1,98 @@
+#!/usr/bin/env bash
+
+set -Eueo pipefail
+
+APP_NAME="portal";
+CURRENT_DEV_VERSION=$(cat .version-dev)
+CURRENT_DEV_VERSION_INT=${CURRENT_DEV_VERSION//[!0-9]/}
+CURRENT_VERSION=$(cat .version)
+CURRENT_VERSION_INT=${CURRENT_VERSION//[!0-9]/}
+if [ ${1-prod} == "dev" ]; then
+ NEW_VERSION="v$((CURRENT_DEV_VERSION_INT+1))-$APP_NAME-dev"
+ OLD_VERSION=$CURRENT_DEV_VERSION
+else
+ NEW_VERSION="v$((CURRENT_VERSION_INT+1))-$APP_NAME"
+ OLD_VERSION=$CURRENT_VERSION
+fi
+# Check for uncommited changes and optionally commit them
+if [ "$(git status --untracked-files=no --porcelain)" ]; then
+ echo "Unclean git tree! press CTRL+C to exit or press ENTER to commit and push to the default branch"
+ read -n 1
+
+ read -p "Enter commit message: " COMMIT_MESSAGE
+ git add ../../
+ git commit --quiet -m "$COMMIT_MESSAGE"
+fi
+
+if [ ${1-prod} == "dev" ]; then
+ echo $NEW_VERSION >| .version-dev
+ git add .version-dev
+else
+ echo $NEW_VERSION >| .version
+ git add .version
+fi
+
+echo "Starting build of $APP_NAME@$NEW_VERSION at $(date -u)..."
+echo
+
+git commit --quiet -m "chore(release): Bump version";
+
+read -p "Do you want to tag this build? (y/n) " -n 1 -r
+echo
+if [[ $REPLY =~ ^[Yy]$ ]]
+then
+ read -p "Enter tag message (can be empty): " TAG_MESSAGE
+ commit_msg="chore(release): Update CHANGELOG.md for $NEW_VERSION"
+ git cliff -r ../../ $OLD_VERSION..HEAD --with-commit "$commit_msg" --prepend CHANGELOG.md
+ git add CHANGELOG.md
+ git commit --quiet -m "$commit_msg";
+ git tag -am "$TAG_MESSAGE" $NEW_VERSION
+fi
+
+read -p "Do you want to push the latest commits and tags to origin? (y/n) " -n 1 -r
+echo
+if [[ $REPLY =~ ^[Yy]$ ]]
+then
+ echo "Pushing latest changes to remotes..."
+ echo
+ git push --quiet --follow-tags
+fi
+
+pushd src
+pnpm run build
+
+cd build
+echo "$NEW_VERSION" >version.txt
+
+
+if [ ${1-prod} == "dev" ]; then
+ scp -r * contabo-fast-1:services/public/portal.dev.greatoffice.life/www
+else
+ echo "Pushing to production in 10 sec, press CTRL+C to cancel"
+ sleep 10
+ scp -r * contabo-fast-1:services/public/portal.greatoffice.life/www
+fi
+
+popd
+
+
+
+server {
+ listen 443 ssl;
+ server_name *.example.com;
+ ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
+ ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
+ include /etc/letsencrypt/options-ssl-nginx.conf;
+ ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
+ root /var/www/example.com;
+ index index.html;
+ location / {
+ try_files $uri $uri/ =404;
+ }
+}
+
+- Congratulations! Your certificate and chain have been saved at:
+ /etc/letsencrypt/live/dev.greatoffice.life/fullchain.pem
+ Your key file has been saved at:
+ /etc/letsencrypt/live/dev.greatoffice.life/privkey.pem
+ Your cert will expire on 2022-08-31. To obtain a new or tweaked