Skip to content

Commit ae0ac5f

Browse files
fix(ci): fix macOS static linking and dynamic binary path detection
1 parent e544533 commit ae0ac5f

2 files changed

Lines changed: 27 additions & 22 deletions

File tree

.github/workflows/ci-release.yml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@ on:
44
push:
55
branches: [ "main" ]
66
tags:
7-
- 'v*' # Triggers automatic release when pushing tags like v0.1.0
7+
- 'v*'
88
pull_request:
99
branches: [ "main" ]
1010

1111
permissions:
1212
contents: write
1313

1414
jobs:
15-
# ---------------------------------------------------------------------------
16-
# Job 1: Build & Verify across Windows, Linux, and macOS Matrix
17-
# ---------------------------------------------------------------------------
1815
build:
1916
name: Build (${{ matrix.os }})
2017
runs-on: ${{ matrix.os }}
@@ -24,13 +21,10 @@ jobs:
2421
include:
2522
- os: windows-latest
2623
artifact_name: xary-windows-x64.exe
27-
binary_path: build/Release/xary.exe
2824
- os: ubuntu-latest
2925
artifact_name: xary-linux-x64
30-
binary_path: build/xary
3126
- os: macos-latest
3227
artifact_name: xary-macos-x64
33-
binary_path: build/xary
3428

3529
steps:
3630
- name: 📥 Checkout Repository
@@ -42,32 +36,37 @@ jobs:
4236
- name: 🔨 Compile Binary
4337
run: cmake --build build --config Release
4438

45-
- name: 🧪 Test CLI Binary Output
39+
- name: 🧪 Test CLI Binary Output & Prepare Artifact
4640
shell: bash
4741
run: |
48-
if [ "${{ runner.os }}" == "Windows" ]; then
49-
./build/Release/xary.exe --version
50-
./build/Release/xary.exe --help
51-
else
52-
./build/xary --version
53-
./build/xary --help
42+
# Dynamically locate the built executable across OS generators
43+
if [ -f "build/Release/xary.exe" ]; then
44+
BIN="build/Release/xary.exe"
45+
elif [ -f "build/xary.exe" ]; then
46+
BIN="build/xary.exe"
47+
elif [ -f "build/Release/xary" ]; then
48+
BIN="build/Release/xary"
49+
elif [ -f "build/xary" ]; then
50+
BIN="build/xary"
5451
fi
5552
56-
- name: 📦 Prepare Release Artifact
57-
shell: bash
58-
run: |
53+
echo "Found binary at: $BIN"
54+
chmod +x "$BIN" 2>/dev/null || true
55+
56+
# Run CLI smoke tests
57+
"$BIN" --version
58+
"$BIN" --help
59+
60+
# Package for upload
5961
mkdir -p dist
60-
cp ${{ matrix.binary_path }} dist/${{ matrix.artifact_name }}
62+
cp "$BIN" "dist/${{ matrix.artifact_name }}"
6163
6264
- name: 📤 Upload Build Artifact
6365
uses: actions/upload-artifact@v4
6466
with:
6567
name: ${{ matrix.os }}-build
6668
path: dist/*
6769

68-
# ---------------------------------------------------------------------------
69-
# Job 2: Automatically Create GitHub Release (Triggered on Version Tags)
70-
# ---------------------------------------------------------------------------
7170
release:
7271
name: 🚀 Publish GitHub Release
7372
needs: build

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,18 @@ set(SOURCES
1717
src/main.cpp
1818
src/core/Stream.cpp
1919
src/core/StreamWriter.cpp
20+
src/core/BufferView.cpp
2021
src/cli/ArgumentParser.cpp
2122
)
2223

2324
add_executable(xary ${SOURCES})
2425
target_include_directories(xary PUBLIC include)
2526

26-
if(NOT MSVC)
27+
# Apply static linking conditionally based on OS/Compiler
28+
if(WIN32 AND NOT MSVC)
29+
# MinGW / GCC on Windows
2730
target_link_options(xary PRIVATE -static -static-libgcc -static-libstdc++)
31+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
32+
# Linux GCC/Clang
33+
target_link_options(xary PRIVATE -static-libgcc -static-libstdc++)
2834
endif()

0 commit comments

Comments
 (0)