From fab6045d52f1126d0b32f94877d35c346c30bac5 Mon Sep 17 00:00:00 2001 From: "Billy.Zheng" Date: Wed, 8 May 2024 00:52:43 +0800 Subject: [PATCH] Add /version action. --- src/actions/version/index.cr | 7 +++++++ src/start_server.cr | 4 ++++ 2 files changed, 11 insertions(+) create mode 100644 src/actions/version/index.cr diff --git a/src/actions/version/index.cr b/src/actions/version/index.cr new file mode 100644 index 0000000..31c469d --- /dev/null +++ b/src/actions/version/index.cr @@ -0,0 +1,7 @@ +class Version::Index < BrowserAction + include Auth::AllowGuests + + get "/version" do + plain_text "Deployed version: #{College::VERSION}" + end +end diff --git a/src/start_server.cr b/src/start_server.cr index b5b92e5..fcb282f 100644 --- a/src/start_server.cr +++ b/src/start_server.cr @@ -13,5 +13,9 @@ Signal::INT.trap do app_server.close end +module College + VERSION = {{ `git rev-parse --short HEAD`.chomp.stringify }} +end + STDERR.puts "Listening on #{ENV["HOST"]}:#{ENV["PORT"]}" app_server.listen