diff --git a/build_and_push.sh b/build_and_push.sh index 8d2cbe7..1d4b4a8 100755 --- a/build_and_push.sh +++ b/build_and_push.sh @@ -131,21 +131,48 @@ increment_version() { export NEW_VERSION } +# Function to update version in header file +update_version_in_header() { + local version="$1" + print_status "Updating version in src/ginxsom.h to $version..." + + # Extract version components (remove 'v' prefix) + local version_no_v=${version#v} + + # Parse major.minor.patch using regex + if [[ $version_no_v =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then + local major=${BASH_REMATCH[1]} + local minor=${BASH_REMATCH[2]} + local patch=${BASH_REMATCH[3]} + + # Update the header file + sed -i "s/#define VERSION_MAJOR [0-9]\+/#define VERSION_MAJOR $major/" src/ginxsom.h + sed -i "s/#define VERSION_MINOR [0-9]\+/#define VERSION_MINOR $minor/" src/ginxsom.h + sed -i "s/#define VERSION_PATCH [0-9]\+/#define VERSION_PATCH $patch/" src/ginxsom.h + sed -i "s/#define VERSION \"v[0-9]\+\.[0-9]\+\.[0-9]\+\"/#define VERSION \"$version\"/" src/ginxsom.h + + print_success "Updated version in header file" + else + print_error "Invalid version format: $version" + exit 1 + fi +} + # Function to compile the Ginxsom project compile_project() { print_status "Compiling Ginxsom FastCGI server..." - + # Clean previous build if make clean > /dev/null 2>&1; then print_success "Cleaned previous build" else print_warning "Clean failed or no Makefile found" fi - + # Compile the project if make > /dev/null 2>&1; then print_success "Ginxsom compiled successfully" - + # Verify the binary was created if [[ -f "build/ginxsom-fcgi" ]]; then print_success "Binary created: build/ginxsom-fcgi" @@ -390,9 +417,12 @@ main() { git tag "$NEW_VERSION" > /dev/null 2>&1 fi + # Update version in header file + update_version_in_header "$NEW_VERSION" + # Compile project compile_project - + # Build release binary build_release_binary @@ -423,9 +453,12 @@ main() { git tag "$NEW_VERSION" > /dev/null 2>&1 fi + # Update version in header file + update_version_in_header "$NEW_VERSION" + # Compile project compile_project - + # Commit and push (but skip tag creation since we already did it) git_commit_and_push_no_tag diff --git a/config/local-nginx.conf b/config/local-nginx.conf index 99753e5..fe082a4 100644 --- a/config/local-nginx.conf +++ b/config/local-nginx.conf @@ -353,7 +353,7 @@ http { # Root redirect - Server info endpoint location = / { - return 200 '{\n "server": "ginxsom",\n "version": "1.0.0",\n "description": "Ginxsom Blossom Server",\n "endpoints": {\n "blob_get": "GET /",\n "blob_head": "HEAD /",\n "upload": "PUT /upload",\n "upload_requirements": "HEAD /upload",\n "list": "GET /list/",\n "delete": "DELETE /",\n "mirror": "PUT /mirror",\n "report": "PUT /report",\n "health": "GET /health"\n },\n "supported_buds": [\n "BUD-01",\n "BUD-02",\n "BUD-04",\n "BUD-06",\n "BUD-08",\n "BUD-09"\n ],\n "limits": {\n "max_upload_size": 104857600,\n "supported_mime_types": [\n "image/jpeg",\n "image/png",\n "image/webp",\n "image/gif",\n "video/mp4",\n "video/webm",\n "audio/mpeg",\n "audio/ogg",\n "text/plain",\n "application/pdf"\n ]\n },\n "authentication": {\n "required_for_upload": false,\n "required_for_delete": true,\n "required_for_list": false,\n "nip42_enabled": true\n }\n}'; + return 200 '{\n "server": "ginxsom",\n "version": "v0.1.4",\n "description": "Ginxsom Blossom Server",\n "endpoints": {\n "blob_get": "GET /",\n "blob_head": "HEAD /",\n "upload": "PUT /upload",\n "upload_requirements": "HEAD /upload",\n "list": "GET /list/",\n "delete": "DELETE /",\n "mirror": "PUT /mirror",\n "report": "PUT /report",\n "health": "GET /health"\n },\n "supported_buds": [\n "BUD-01",\n "BUD-02",\n "BUD-04",\n "BUD-06",\n "BUD-08",\n "BUD-09"\n ],\n "limits": {\n "max_upload_size": 104857600,\n "supported_mime_types": [\n "image/jpeg",\n "image/png",\n "image/webp",\n "image/gif",\n "video/mp4",\n "video/webm",\n "audio/mpeg",\n "audio/ogg",\n "text/plain",\n "application/pdf"\n ]\n },\n "authentication": {\n "required_for_upload": false,\n "required_for_delete": true,\n "required_for_list": false,\n "nip42_enabled": true\n }\n}'; add_header Content-Type application/json; add_header Access-Control-Allow-Origin * always; add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH" always; @@ -685,7 +685,7 @@ http { # Root redirect - Server info endpoint location = / { - return 200 '{\n "server": "ginxsom",\n "version": "1.0.0",\n "description": "Ginxsom Blossom Server (HTTPS)",\n "endpoints": {\n "blob_get": "GET /",\n "blob_head": "HEAD /",\n "upload": "PUT /upload",\n "upload_requirements": "HEAD /upload",\n "list": "GET /list/",\n "delete": "DELETE /",\n "mirror": "PUT /mirror",\n "report": "PUT /report",\n "health": "GET /health"\n },\n "supported_buds": [\n "BUD-01",\n "BUD-02",\n "BUD-04",\n "BUD-06",\n "BUD-08",\n "BUD-09"\n ],\n "limits": {\n "max_upload_size": 104857600,\n "supported_mime_types": [\n "image/jpeg",\n "image/png",\n "image/webp",\n "image/gif",\n "video/mp4",\n "video/webm",\n "audio/mpeg",\n "audio/ogg",\n "text/plain",\n "application/pdf"\n ]\n },\n "authentication": {\n "required_for_upload": false,\n "required_for_delete": true,\n "required_for_list": false,\n "nip42_enabled": true\n }\n}'; + return 200 '{\n "server": "ginxsom",\n "version": "v0.1.4",\n "description": "Ginxsom Blossom Server (HTTPS)",\n "endpoints": {\n "blob_get": "GET /",\n "blob_head": "HEAD /",\n "upload": "PUT /upload",\n "upload_requirements": "HEAD /upload",\n "list": "GET /list/",\n "delete": "DELETE /",\n "mirror": "PUT /mirror",\n "report": "PUT /report",\n "health": "GET /health"\n },\n "supported_buds": [\n "BUD-01",\n "BUD-02",\n "BUD-04",\n "BUD-06",\n "BUD-08",\n "BUD-09"\n ],\n "limits": {\n "max_upload_size": 104857600,\n "supported_mime_types": [\n "image/jpeg",\n "image/png",\n "image/webp",\n "image/gif",\n "video/mp4",\n "video/webm",\n "audio/mpeg",\n "audio/ogg",\n "text/plain",\n "application/pdf"\n ]\n },\n "authentication": {\n "required_for_upload": false,\n "required_for_delete": true,\n "required_for_list": false,\n "nip42_enabled": true\n }\n}'; add_header Content-Type application/json; add_header Access-Control-Allow-Origin * always; add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH" always; diff --git a/remote.nginx.config b/remote.nginx.config index d58d213..f0a0a9e 100644 --- a/remote.nginx.config +++ b/remote.nginx.config @@ -212,7 +212,7 @@ server { # Default location - Server info endpoint location / { - return 200 '{\n "server": "ginxsom",\n "version": "1.0.0",\n "description": "Ginxsom Blossom Server",\n "endpoints": {\n "blob_get": "GET /",\n "blob_head": "HEAD /",\n "upload": "PUT /upload",\n "upload_requirements": "HEAD /upload",\n "list": "GET /list/",\n "delete": "DELETE /",\n "mirror": "PUT /mirror",\n "report": "PUT /report",\n "health": "GET /health"\n },\n "supported_buds": [\n "BUD-01",\n "BUD-02",\n "BUD-04",\n "BUD-06",\n "BUD-08",\n "BUD-09"\n ],\n "limits": {\n "max_upload_size": 104857600,\n "supported_mime_types": [\n "image/jpeg",\n "image/png",\n "image/webp",\n "image/gif",\n "video/mp4",\n "video/webm",\n "audio/mpeg",\n "audio/ogg",\n "text/plain",\n "application/pdf"\n ]\n },\n "authentication": {\n "required_for_upload": false,\n "required_for_delete": true,\n "required_for_list": false,\n "nip42_enabled": true\n }\n}'; + return 200 '{\n "server": "ginxsom",\n "version": "v0.1.4",\n "description": "Ginxsom Blossom Server",\n "endpoints": {\n "blob_get": "GET /",\n "blob_head": "HEAD /",\n "upload": "PUT /upload",\n "upload_requirements": "HEAD /upload",\n "list": "GET /list/",\n "delete": "DELETE /",\n "mirror": "PUT /mirror",\n "report": "PUT /report",\n "health": "GET /health"\n },\n "supported_buds": [\n "BUD-01",\n "BUD-02",\n "BUD-04",\n "BUD-06",\n "BUD-08",\n "BUD-09"\n ],\n "limits": {\n "max_upload_size": 104857600,\n "supported_mime_types": [\n "image/jpeg",\n "image/png",\n "image/webp",\n "image/gif",\n "video/mp4",\n "video/webm",\n "audio/mpeg",\n "audio/ogg",\n "text/plain",\n "application/pdf"\n ]\n },\n "authentication": {\n "required_for_upload": false,\n "required_for_delete": true,\n "required_for_list": false,\n "nip42_enabled": true\n }\n}'; add_header Content-Type application/json; add_header Access-Control-Allow-Origin * always; add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH" always; diff --git a/src/ginxsom.h b/src/ginxsom.h index fa44b21..c8c79f6 100644 --- a/src/ginxsom.h +++ b/src/ginxsom.h @@ -7,6 +7,11 @@ #ifndef GINXSOM_H #define GINXSOM_H +// Version information (auto-updated by build system) +#define VERSION_MAJOR 0 +#define VERSION_MINOR 1 +#define VERSION_PATCH 5 +#define VERSION "v0.1.5" #include #include