Skip to content

Commit 980e5d7

Browse files
committed
fix: add versioning at build time
also adopt dyne/musl-action in CI (thx @matteo-cristino)
1 parent b501f66 commit 980e5d7

File tree

6 files changed

+33
-9
lines changed

6 files changed

+33
-9
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,13 @@ jobs:
5858
uses: actions/checkout@v4
5959
with:
6060
fetch-depth: 0
61-
- name: ccache
62-
uses: hendrikmuhs/ccache-action@v1.2
63-
- name: Install dyne muscle
64-
run: |
65-
curl -L "https://files.dyne.org/?file=musl/dyne-gcc-musl-${OUTPUT}.tar.xz" | sudo tar -C /opt -xJf -
61+
- name: Install dyne musl
62+
uses: dyne/musl-action@main
63+
with:
64+
target_arch: x86_64
6665
- name: Build conspire
6766
run: |
68-
make
67+
make VERSION=${{ needs.semantic-release.outputs.new_release_version }}
6968
- name: Upload release artifact
7069
uses: actions/upload-artifact@v4
7170
with:

GNUmakefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Makefile to download and build it all
22
OUTPUT ?= x86_64
33
TARGET ?= x86_64-linux-musl
4+
VERSION ?= dev
45
R := $(CURDIR)
56
I := $(R)/build/deps
67

@@ -11,7 +12,8 @@ all: build/deps conspire
1112

1213
conspire:
1314
cmake -G Ninja -S server -B build -DARCH=$(TARGET) \
14-
-DCMAKE_TOOLCHAIN_FILE="/opt/dyne/gcc-musl/settings.cmake"
15+
-DCMAKE_TOOLCHAIN_FILE="/opt/dyne/gcc-musl/settings.cmake" \
16+
-DVERSION="$(VERSION)"
1517
ninja -C build
1618
cp build/canchat-exe conspire-$(OUTPUT)
1719
/opt/dyne/gcc-musl/bin/$(TARGET)-strip conspire-$(OUTPUT)

server/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,18 @@ if(EXISTS "${DEPS_PREFIX}")
7272
endif()
7373

7474
#################################################################
75-
## define certificates path
75+
## define version and build paths
76+
77+
# Set version from command line or default
78+
if(NOT DEFINED VERSION)
79+
set(VERSION "unknown")
80+
endif()
7681

7782
add_definitions(
7883
-DCERT_PEM_PATH="cert/privkey.pem"
7984
-DCERT_CRT_PATH="cert/fullchain.pem"
8085
-DFRONT_PATH="front"
86+
-DCONSPIRE_VERSION="${VERSION}"
8187
)
8288

8389
#################################################################

server/src/App.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,16 @@ void setupSignalHandlers() {
124124

125125
void run(const oatpp::base::CommandLineArguments& args) {
126126

127+
// Print version and exit if '--version' is present
128+
if(args.hasArgument("--version")) {
129+
std::cout << "Conspire Chat Server v" << CONSPIRE_VERSION << std::endl;
130+
return;
131+
}
132+
127133
// Print help and exit if '-h' or '--help' is present
128134
if(args.hasArgument("-h") || args.hasArgument("--help")) {
129135
std::cout << R"HELP(
130-
Conspire Chat Server
136+
Conspire Chat Server v)HELP" << CONSPIRE_VERSION << R"HELP(
131137
Usage: conspire [options]
132138
Options:
133139
--host <address> Bind address (default: localhost)
@@ -137,6 +143,7 @@ Usage: conspire [options]
137143
--url-stats <path> Statistics endpoint path (default: admin/stats.json)
138144
--pid <path> Path to PID file to create
139145
--front <path> Path to frontend static files (default: front)
146+
--version Show version information
140147
-h, --help Show this help message
141148
)HELP" << std::endl;
142149
return;
@@ -231,6 +238,8 @@ Usage: conspire [options]
231238
OATPP_LOGi("canchat", "Stats thread exiting cleanly");
232239
});
233240

241+
OATPP_LOGi("canchat", "Conspire Chat Server v{} starting up", appConfig->version)
242+
234243
if(appConfig->useTLS) {
235244
OATPP_LOGi("canchat", "clients are expected to connect at https://{}:{}/", appConfig->host, appConfig->port);
236245
} else {

server/src/AppComponent.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ class AppComponent {
125125
// Parse --front argument for frontend path
126126
config->frontPath = m_cmdArgs.getNamedArgumentValue("--front", "front");
127127

128+
// Set version from build-time definition
129+
config->version = CONSPIRE_VERSION;
130+
128131
return config;
129132

130133
}());

server/src/dto/Config.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ class ConfigDto : public oatpp::DTO {
6565
*/
6666
DTO_FIELD(String, frontPath);
6767

68+
/**
69+
* Software version.
70+
*/
71+
DTO_FIELD(String, version);
72+
6873
/**
6974
* Max size of the received bytes. (the whole MessageDto structure).
7075
* The actual payload is smaller.

0 commit comments

Comments
 (0)