diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6afc6c102..c1a269833 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -26,13 +26,16 @@ jobs: IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME # Change all uppercase to lowercase IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - # Strip git ref prefix from version - VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + IMAGE_TAG="${{ github.ref_name }}" # Strip "v" prefix from tag name - [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + [[ "${{ github.ref_type }}" == "tag" ]] && IMAGE_TAG=$(echo $IMAGE_TAG | sed -e 's/^v//') # Use Docker `latest` tag convention - [ "$VERSION" == "main" ] && VERSION=latest + [ "$IMAGE_TAG" == "main" ] && IMAGE_TAG=latest + VERSION="${{ github.sha }}" + [[ "${{ github.ref_type }}" == "tag" ]] && VERSION="${{ github.ref_name }}" + [[ "${{ github.ref_type }}" == "branch" ]] && VERSION="${{ github.ref_name }}-${{ github.sha }}" echo IMAGE_ID=$IMAGE_ID >> $GITHUB_OUTPUT + echo IMAGE_TAG=$IMAGE_TAG >> $GITHUB_OUTPUT echo VERSION=$VERSION >> $GITHUB_OUTPUT - name: Set up Docker Buildx @@ -50,8 +53,10 @@ jobs: with: context: . push: true - tags: ${{ steps.vars.outputs.IMAGE_ID }}:${{ steps.vars.outputs.VERSION }} + tags: ${{ steps.vars.outputs.IMAGE_ID }}:${{ steps.vars.outputs.IMAGE_TAG }} labels: runnumber=${{ github.run_id }} cache-from: type=gha cache-to: type=gha,mode=max platforms: linux/amd64,linux/arm64 + build-args: | + VERSION=${{ steps.vars.outputs.VERSION }} diff --git a/Dockerfile b/Dockerfile index 74c6a8646..72aeade39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ ARG ELIXIR_VERSION=1.14.3 # https://github.com/hexpm/bob#docker-images FROM docker.io/hexpm/elixir:${ELIXIR_VERSION}-erlang-${ERLANG_OTP_VERSION}-alpine-${ALPINE_VERSION} as builder +ARG VERSION ARG MIX_ENV=prod ENV ERL_FLAGS="+JPperf true" # Avoid "error 137" (out of memory) while building images diff --git a/config/config.exs b/config/config.exs index e2efa929f..8a633e850 100644 --- a/config/config.exs +++ b/config/config.exs @@ -7,6 +7,8 @@ # General application configuration import Config +config :asciinema, version: System.get_env("VERSION") + config :asciinema, :session_opts, store: :cookie, key: "_asciinema_key", diff --git a/lib/asciinema_web/controllers/page_controller.ex b/lib/asciinema_web/controllers/page_controller.ex index dce41244c..4546585e0 100644 --- a/lib/asciinema_web/controllers/page_controller.ex +++ b/lib/asciinema_web/controllers/page_controller.ex @@ -8,7 +8,9 @@ defmodule AsciinemaWeb.PageController do conn, "about.html", page_title: "About", - contact_email_address: Application.get_env(:asciinema, :contact_email_address) + contact_email_address: Application.get_env(:asciinema, :contact_email_address), + server_name: AsciinemaWeb.Endpoint.host(), + server_version: Application.get_env(:asciinema, :version) ) end diff --git a/lib/asciinema_web/controllers/page_html/about.html.heex b/lib/asciinema_web/controllers/page_html/about.html.heex index 3797b057d..20e2ab22f 100644 --- a/lib/asciinema_web/controllers/page_html/about.html.heex +++ b/lib/asciinema_web/controllers/page_html/about.html.heex @@ -1,8 +1,15 @@ -
- <%= @conn.host %> is a platform for hosting and sharing - terminal session recordings, powered by asciinema server. + <%= @server_name %> + is a platform for hosting and sharing + terminal session recordings, powered by + <%= if @server_version do %> + asciinema server + (<%= @server_version %>). + <% else %> + asciinema server. + <% end %>
<%= if @contact_email_address do %> @@ -22,7 +29,7 @@
diff --git a/lib/asciinema_web/controllers/username_html/new.html.heex b/lib/asciinema_web/controllers/username_html/new.html.heex
index c2b939d02..fe3a38028 100644
--- a/lib/asciinema_web/controllers/username_html/new.html.heex
+++ b/lib/asciinema_web/controllers/username_html/new.html.heex
@@ -5,7 +5,7 @@
- Every asciinema user gets a profile page at <%= url(~p"/") %>/~username. + Every asciinema user gets a profile page at <%= url(~p"/") %>~username.
<.form :let={f} for={@changeset} action={~p"/username"} class="username-form" method="post">