diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05156ac9..f55343fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,6 +87,7 @@ jobs: VER="$(git describe --tags 2>/dev/null)" echo "version=${VER}" >> "$GITHUB_OUTPUT" + echo "branch=${REF}" >> "$GITHUB_OUTPUT" echo 'tags<> "$GITHUB_OUTPUT" if [[ "$REF" == "main" ]]; then @@ -105,6 +106,7 @@ jobs: platforms: linux/amd64 build-args: | VERSION=${{ steps.info.outputs.version }} + BRANCH=${{ steps.info.outputs.branch }} publish-image: name: Publish Image diff --git a/.gitignore b/.gitignore index 21277fbd..b89b11b4 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ vendor/bundle Procfile.local VERSION +BRANCH .rubocop-https* .env* diff --git a/Dockerfile b/Dockerfile index b1f4a2bc..25fd0747 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM ruby:3.2.2-bullseye AS base SHELL ["/bin/bash", "-o", "pipefail", "-c"] RUN apt-get update \ && apt-get install -y --no-install-recommends \ - software-properties-common dirmngr apt-transport-https \ + software-properties-common dirmngr apt-transport-https \ && (curl -sL https://deb.nodesource.com/setup_20.x | bash -) \ && rm -rf /var/lib/apt/lists/* @@ -43,8 +43,10 @@ COPY ./docker/wait-for.sh /docker-entrypoint.sh COPY --chown=postal . . # Export the version -ARG VERSION=unspecified -RUN echo $VERSION > VERSION +ARG VERSION=null +ARG BRANCH=null +RUN echo $VERSION > VERSION \ + && echo $BRANCH > BRANCH # Set paths for when running in a container ENV POSTAL_CONFIG_FILE_PATH=/config/postal.yml diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0e54e0db..c6acf456 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -100,4 +100,11 @@ def endpoint_options_for_select(server, selected_value = nil, options = {}) end.html_safe end + def postal_version_string + string = Postal.version + string += " (#{Postal.branch})" if Postal.branch && + Postal.branch != "main" + string + end + end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 7176ef4c..c7411f9d 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -55,6 +55,8 @@ %footer.siteContent__footer %ul.footer__links %li.footer__name - Powered by #{link_to "Postal", "https://postalserver.io", target: '_blank'} #{Postal.version}. + Powered by + #{link_to "Postal", "https://postalserver.io", target: '_blank'} + #{postal_version_string} %li= link_to "Documentation", "https://docs.postalserver.io", target: '_blank' %li= link_to "Ask for help", "https://discussions.postalserver.io", target: '_blank' diff --git a/lib/postal/config.rb b/lib/postal/config.rb index b2717f6e..dd0eebfa 100644 --- a/lib/postal/config.rb +++ b/lib/postal/config.rb @@ -153,6 +153,18 @@ def change_database_connection_pool_size(new_size) ActiveRecord::Base.establish_connection(config.merge(pool: new_size)) end + # Return the branch name which created this release + # + # @return [String, nil] + def branch + return @branch if instance_variable_defined?("@branch") + + @branch = begin + path = Rails.root.join("BRANCH") + File.read(path).strip if File.exist?(path) + end + end + end Config = initialize_config