summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.version0
-rw-r--r--.version-dev0
-rwxr-xr-xbuild_and_push.sh90
-rw-r--r--src/BlobBin.csproj (renamed from BlobBin/BlobBin.csproj)0
-rw-r--r--src/DB.cs (renamed from BlobBin/DB.cs)0
-rw-r--r--src/Dockerfile (renamed from BlobBin/Dockerfile)0
-rw-r--r--src/Migrations/20230112230354_InitialCreate.Designer.cs (renamed from BlobBin/Migrations/20230112230354_InitialCreate.Designer.cs)0
-rw-r--r--src/Migrations/20230112230354_InitialCreate.cs (renamed from BlobBin/Migrations/20230112230354_InitialCreate.cs)0
-rw-r--r--src/Migrations/DBModelSnapshot.cs (renamed from BlobBin/Migrations/DBModelSnapshot.cs)0
-rw-r--r--src/Program.cs (renamed from BlobBin/Program.cs)2
-rw-r--r--src/Properties/launchSettings.json (renamed from BlobBin/Properties/launchSettings.json)0
-rw-r--r--src/wwwroot/index.html (renamed from BlobBin/wwwroot/index.html)0
12 files changed, 91 insertions, 1 deletions
diff --git a/.version b/.version
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.version
diff --git a/.version-dev b/.version-dev
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.version-dev
diff --git a/build_and_push.sh b/build_and_push.sh
new file mode 100755
index 0000000..3ea7e26
--- /dev/null
+++ b/build_and_push.sh
@@ -0,0 +1,90 @@
+#!/usr/bin/env bash
+
+set -Eueo pipefail
+
+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))-dev"
+ OLD_VERSION=$CURRENT_DEV_VERSION
+else
+ NEW_VERSION="v$((CURRENT_VERSION_INT + 1))"
+ OLD_VERSION=$CURRENT_VERSION
+fi
+IMAGE_NAME="blob-bin/server"
+HUB_NAME="dr.ivar.systems/blob-in/server"
+
+# 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 $HUB_NAME:$NEW_VERSION at $(date -u)..."
+echo
+
+# Put version.txt inside of server
+pushd src/wwwroot
+echo "$NEW_VERSION" >version.txt
+git add version.txt
+popd
+
+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
+ 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
+
+# Build docker image
+echo "Building docker image"
+echo
+pushd src
+docker build -t $IMAGE_NAME:$NEW_VERSION .
+
+docker tag $IMAGE_NAME:$NEW_VERSION $HUB_NAME:$NEW_VERSION
+
+if [ ${1-prod} == "dev" ]; then
+ docker tag $IMAGE_NAME:$NEW_VERSION $HUB_NAME:latest-dev
+fi
+if [ ${1-prod} == "prod" ]; then
+ docker tag $IMAGE_NAME:$NEW_VERSION $HUB_NAME:latest
+fi
+
+# Optionally push images to docker registry
+echo "Press CTRL+C to exit or press ENTER to push docker image to registry"
+read -n 1
+docker push $HUB_NAME:$NEW_VERSION
+
+if [ ${1-prod} == "dev" ]; then
+ docker push $HUB_NAME:latest-dev
+fi
+
+if [ ${1-prod} == "prod" ]; then
+ docker push $HUB_NAME:latest
+fi
+popd
diff --git a/BlobBin/BlobBin.csproj b/src/BlobBin.csproj
index 263a517..263a517 100644
--- a/BlobBin/BlobBin.csproj
+++ b/src/BlobBin.csproj
diff --git a/BlobBin/DB.cs b/src/DB.cs
index a736dc2..a736dc2 100644
--- a/BlobBin/DB.cs
+++ b/src/DB.cs
diff --git a/BlobBin/Dockerfile b/src/Dockerfile
index 9b1f38e..9b1f38e 100644
--- a/BlobBin/Dockerfile
+++ b/src/Dockerfile
diff --git a/BlobBin/Migrations/20230112230354_InitialCreate.Designer.cs b/src/Migrations/20230112230354_InitialCreate.Designer.cs
index b5a06c3..b5a06c3 100644
--- a/BlobBin/Migrations/20230112230354_InitialCreate.Designer.cs
+++ b/src/Migrations/20230112230354_InitialCreate.Designer.cs
diff --git a/BlobBin/Migrations/20230112230354_InitialCreate.cs b/src/Migrations/20230112230354_InitialCreate.cs
index 97f9c36..97f9c36 100644
--- a/BlobBin/Migrations/20230112230354_InitialCreate.cs
+++ b/src/Migrations/20230112230354_InitialCreate.cs
diff --git a/BlobBin/Migrations/DBModelSnapshot.cs b/src/Migrations/DBModelSnapshot.cs
index 8c9fb26..8c9fb26 100644
--- a/BlobBin/Migrations/DBModelSnapshot.cs
+++ b/src/Migrations/DBModelSnapshot.cs
diff --git a/BlobBin/Program.cs b/src/Program.cs
index e66cd02..01ca76b 100644
--- a/BlobBin/Program.cs
+++ b/src/Program.cs
@@ -92,7 +92,7 @@ string GetFilesDirectoryPath() {
}
string GetUnusedBlobId(DB db) {
- string id() => RandomString.Generate(5);
+ string id() => RandomString.Generate(3);
var res = id();
while (db.Files.Any(c => c.PublicId == res)) {
res = id();
diff --git a/BlobBin/Properties/launchSettings.json b/src/Properties/launchSettings.json
index e19510b..e19510b 100644
--- a/BlobBin/Properties/launchSettings.json
+++ b/src/Properties/launchSettings.json
diff --git a/BlobBin/wwwroot/index.html b/src/wwwroot/index.html
index fa25951..fa25951 100644
--- a/BlobBin/wwwroot/index.html
+++ b/src/wwwroot/index.html