Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 84 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
.github/workflows/ci.yml)
runtime=true
;;
CMakeLists.txt|Makefile|Dockerfile|action.yml)
CMakeLists.txt|Makefile|Dockerfile|action.yml|VERSION)
runtime=true
;;
get-coastline.sh|get-landcover.sh|get-monaco.sh)
Expand Down Expand Up @@ -128,6 +128,17 @@ jobs:
print(path)
PY

- name: Validate version metadata
run: |
python3 <<'PY'
import pathlib
import re

version = pathlib.Path("VERSION").read_text(encoding="utf-8").strip()
if not re.fullmatch(r"\d+\.\d+\.\d+", version):
raise SystemExit(f"VERSION must use X.Y.Z format, got {version!r}")
PY

- name: Validate Lua profiles
run: |
git ls-files -z -- 'resources/*.lua' |
Expand Down Expand Up @@ -669,6 +680,39 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Read tilemaker version
id: version
run: |
version="$(sed -n '1p' VERSION)"
build_version="v${version}+nogit"

if git rev-parse --git-dir >/dev/null 2>&1; then
sha="$(git rev-parse --short=12 HEAD 2>/dev/null || true)"
if [ -n "${sha}" ]; then
tag="$(git describe --exact-match --tags HEAD 2>/dev/null || true)"
dirty=
if git diff-index --quiet HEAD -- 2>/dev/null; then
dirty_result=0
else
dirty_result="$?"
fi
if [ "${dirty_result}" -eq 1 ]; then
dirty=.dirty
fi

if [ "${tag}" = "v${version}" ] && [ -z "${dirty}" ]; then
build_version="v${version}"
else
build_version="v${version}+g${sha}${dirty}"
fi
fi
fi

{
echo "version=${version}"
echo "build_version=${build_version}"
} >> "$GITHUB_OUTPUT"

- name: Build Docker image
uses: docker/build-push-action@v7
with:
Expand All @@ -677,6 +721,9 @@ jobs:
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TILEMAKER_VERSION=${{ steps.version.outputs.version }}
TILEMAKER_BUILD_VERSION=${{ steps.version.outputs.build_version }}
cache-from: type=gha
cache-to: type=gha,mode=max

Expand Down Expand Up @@ -715,6 +762,39 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Read tilemaker version
id: version
run: |
version="$(sed -n '1p' VERSION)"
build_version="v${version}+nogit"

if git rev-parse --git-dir >/dev/null 2>&1; then
sha="$(git rev-parse --short=12 HEAD 2>/dev/null || true)"
if [ -n "${sha}" ]; then
tag="$(git describe --exact-match --tags HEAD 2>/dev/null || true)"
dirty=
if git diff-index --quiet HEAD -- 2>/dev/null; then
dirty_result=0
else
dirty_result="$?"
fi
if [ "${dirty_result}" -eq 1 ]; then
dirty=.dirty
fi

if [ "${tag}" = "v${version}" ] && [ -z "${dirty}" ]; then
build_version="v${version}"
else
build_version="v${version}+g${sha}${dirty}"
fi
fi
fi

{
echo "version=${version}"
echo "build_version=${build_version}"
} >> "$GITHUB_OUTPUT"

- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
Expand All @@ -723,5 +803,8 @@ jobs:
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TILEMAKER_VERSION=${{ steps.version.outputs.version }}
TILEMAKER_BUILD_VERSION=${{ steps.version.outputs.build_version }}
cache-from: type=gha
cache-to: type=gha,mode=max
47 changes: 40 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()

project(tilemaker)
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" tilemaker_version LIMIT_COUNT 1)
string(STRIP "${tilemaker_version}" tilemaker_version)

project(tilemaker VERSION ${tilemaker_version})

OPTION(TILEMAKER_BUILD_STATIC "Attempt to link dependencies static" OFF)

Expand Down Expand Up @@ -68,13 +71,43 @@ endif()

set(CMAKE_CXX_STANDARD 17)

if(!TM_VERSION)
execute_process(
COMMAND git describe --tags --abbrev=0
OUTPUT_VARIABLE tm_version
OUTPUT_STRIP_TRAILING_WHITESPACE)
add_compile_definitions(TM_VERSION=${tm_version})
if(NOT TM_VERSION)
set(TM_VERSION v${PROJECT_VERSION})
find_package(Git QUIET)
if(NOT GIT_FOUND OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
set(TM_VERSION ${TM_VERSION}+nogit)
else()
execute_process(
COMMAND "${GIT_EXECUTABLE}" -C "${CMAKE_CURRENT_SOURCE_DIR}" rev-parse --short=12 HEAD
OUTPUT_VARIABLE tm_git_sha
RESULT_VARIABLE tm_git_sha_result
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND "${GIT_EXECUTABLE}" -C "${CMAKE_CURRENT_SOURCE_DIR}" describe --exact-match --tags HEAD
OUTPUT_VARIABLE tm_git_tag
RESULT_VARIABLE tm_git_tag_result
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(tm_git_sha_result EQUAL 0 AND NOT tm_git_sha STREQUAL "")
set(tm_git_dirty_suffix)
execute_process(
COMMAND "${GIT_EXECUTABLE}" -C "${CMAKE_CURRENT_SOURCE_DIR}" diff-index --quiet HEAD --
RESULT_VARIABLE tm_git_dirty_result
ERROR_QUIET
OUTPUT_QUIET)
if(tm_git_dirty_result EQUAL 1)
set(tm_git_dirty_suffix .dirty)
endif()
if(NOT (tm_git_tag_result EQUAL 0 AND tm_git_tag STREQUAL TM_VERSION AND tm_git_dirty_suffix STREQUAL ""))
set(TM_VERSION ${TM_VERSION}+g${tm_git_sha}${tm_git_dirty_suffix})
endif()
else()
set(TM_VERSION ${TM_VERSION}+nogit)
endif()
endif()
endif()
add_compile_definitions(TM_VERSION=${TM_VERSION})

if(MSVC)
find_package(unofficial-sqlite3 CONFIG REQUIRED)
Expand Down
16 changes: 13 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM debian:bookworm-slim AS src
LABEL Description="Tilemaker" Version="1.4.0"
ARG TILEMAKER_VERSION=unknown
ARG TILEMAKER_BUILD_VERSION=
LABEL Description="Tilemaker" Version="${TILEMAKER_VERSION}"

ARG BUILD_DEBUG=

Expand All @@ -20,17 +22,22 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins
WORKDIR /usr/src/app

COPY CMakeLists.txt ./
COPY VERSION ./
COPY cmake ./cmake
COPY src ./src
COPY include ./include
COPY server ./server

RUN mkdir build && \
cd build && \
tm_version_arg= && \
if [ -n "$TILEMAKER_BUILD_VERSION" ]; then \
tm_version_arg="-DTM_VERSION=$TILEMAKER_BUILD_VERSION"; \
fi && \
if [ -z "$BUILD_DEBUG" ]; then \
cmake -DCMAKE_BUILD_TYPE=Release -DBoost_USE_DEBUG_RUNTIME=OFF ..; \
cmake -DCMAKE_BUILD_TYPE=Release -DBoost_USE_DEBUG_RUNTIME=OFF $tm_version_arg ..; \
else \
cmake -DCMAKE_BUILD_TYPE=Debug ..; \
cmake -DCMAKE_BUILD_TYPE=Debug $tm_version_arg ..; \
fi; \
cmake --build . --parallel $(nproc) && \
if [ -z "$BUILD_DEBUG" ]; then \
Expand All @@ -43,6 +50,8 @@ ENV PATH="/usr/src/app/build:$PATH"
FROM debian:bookworm-slim

ARG BUILD_DEBUG=
ARG TILEMAKER_VERSION=unknown
LABEL Description="Tilemaker" Version="${TILEMAKER_VERSION}"

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
liblua5.1-0 \
Expand All @@ -62,6 +71,7 @@ COPY --from=src /usr/src/app/build/tilemaker-server .
COPY --from=src /usr/local/lib/lua/5.1/flock.so /usr/local/lib/lua/5.1/flock.so
COPY server/static ./static
COPY resources ./resources
COPY VERSION ./
COPY process.lua ./
COPY config.json ./

Expand Down
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,17 @@ $(info - library path is ${LUA_LIBS})
prefix = /usr/local

MANPREFIX := /usr/share/man
TM_VERSION ?= $(shell git describe --tags --abbrev=0)
TM_BASE_VERSION := v$(shell sed -n '1p' VERSION)
TM_GIT_SHA := $(shell git rev-parse --short=12 HEAD 2>/dev/null)
TM_GIT_TAG := $(shell git describe --exact-match --tags HEAD 2>/dev/null)
TM_GIT_DIRTY := $(shell if git diff-index --quiet HEAD -- 2>/dev/null; then :; elif test $$? -eq 1; then printf '.dirty'; fi)
ifeq ($(TM_GIT_SHA),)
TM_VERSION ?= $(TM_BASE_VERSION)+nogit
else ifeq ($(TM_GIT_TAG)$(TM_GIT_DIRTY),$(TM_BASE_VERSION))
TM_VERSION ?= $(TM_BASE_VERSION)
else
TM_VERSION ?= $(TM_BASE_VERSION)+g$(TM_GIT_SHA)$(TM_GIT_DIRTY)
endif
CXXFLAGS ?= -O3 -Wall -Wno-unknown-pragmas -Wno-sign-compare -std=c++14 -pthread -fPIE -DTM_VERSION=$(TM_VERSION) $(CONFIG)
CFLAGS ?= -O3 -Wall -Wno-unknown-pragmas -Wno-sign-compare -std=c99 -fPIE -DTM_VERSION=$(TM_VERSION) $(CONFIG)
BOOST_SYSTEM_LIB := $(shell printf 'int main(){return 0;}\n' | $(CXX) -x c++ - -o /tmp/tilemaker-boost-system-check -lboost_system >/dev/null 2>&1 && echo -lboost_system; rm -f /tmp/tilemaker-boost-system-check)
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.1.0
Loading