fix parser version check

This commit is contained in:
Graham McIntire 2025-07-07 13:50:04 -05:00
parent c91f80e23f
commit da9d89a3a0
No known key found for this signature in database
3 changed files with 18 additions and 2 deletions

View file

@ -23,6 +23,10 @@ RUN mix local.hex --force && mix local.rebar --force
# Set build environment
ENV MIX_ENV="prod"
# Capture APRS parser git hash from GitHub API
RUN curl -s https://api.github.com/repos/aprsme/aprs/commits/main | grep -o '"sha":"[^"]*"' | head -1 | cut -d'"' -f4 | cut -c1-7 > /tmp/parser_hash.txt
ENV PARSER_GIT_HASH=$(cat /tmp/parser_hash.txt)
# Install dependencies
COPY mix.exs mix.lock ./
RUN mix deps.get --only $MIX_ENV

View file

@ -10,7 +10,11 @@ defmodule Aprsme.DependencyInfo do
"""
def get_aprs_library_sha do
if Application.get_env(:aprsme, :env, :dev) == :prod do
fetch_aprs_sha_from_github()
# In production, use environment variable set during build if available
case System.get_env("PARSER_GIT_HASH") do
nil -> fetch_aprs_sha_from_github()
hash -> hash
end
else
get_aprs_sha_from_vendor()
end

10
mix.exs
View file

@ -4,7 +4,7 @@ defmodule Aprsme.MixProject do
def project do
[
app: :aprsme,
version: "0.1.0",
version: get_version(),
elixir: "~> 1.17",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
@ -125,4 +125,12 @@ defmodule Aprsme.MixProject do
{:aprs, github: "aprsme/aprs", branch: "main"}
end
end
# Get version from PARSER_GIT_HASH environment variable or fall back to default
defp get_version do
case System.get_env("PARSER_GIT_HASH") do
nil -> "0.1.0"
hash -> hash
end
end
end