Skip to content

Commit 1f76e3a

Browse files
authored
Provide musl packages through GitHub Actions (#612)
See: #606 Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 5fbd838 commit 1f76e3a

4 files changed

Lines changed: 57 additions & 4 deletions

File tree

.github/workflows/package.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,47 @@ jobs:
1818
matrix:
1919
platform:
2020
- os: ubuntu-22.04
21+
type: native
22+
artifact: ubuntu-x64
2123
cc: gcc
2224
cxx: g++
2325
shell: sh
2426
- os: ubuntu-22.04-arm
27+
type: native
28+
artifact: ubuntu-arm
29+
cc: gcc
30+
cxx: g++
31+
shell: sh
32+
- os: ubuntu-latest
33+
type: container
34+
artifact: alpine-x64
35+
container: alpine:3.21
2536
cc: gcc
2637
cxx: g++
2738
shell: sh
2839
- os: macos-15-intel
40+
type: native
41+
artifact: macos-x64
2942
cc: clang
3043
cxx: clang++
3144
shell: sh
3245
- os: macos-15
46+
type: native
47+
artifact: macos-arm
3348
cc: clang
3449
cxx: clang++
3550
shell: sh
3651
- os: windows-latest
52+
type: native
53+
artifact: windows-x64
3754
shell: pwsh
3855

3956
defaults:
4057
run:
4158
shell: ${{ matrix.platform.shell }}
4259

4360
runs-on: ${{ matrix.platform.os }}
61+
container: ${{ matrix.platform.container }}
4462

4563
# Building the ARM64 Docker image on QEMU takes forever
4664
timeout-minutes: 60
@@ -49,18 +67,24 @@ jobs:
4967
CC: ${{ matrix.platform.cc }}
5068
CXX: ${{ matrix.platform.cxx }}
5169
steps:
70+
- name: Install dependencies (Alpine)
71+
if: matrix.platform.type == 'container'
72+
run: apk add --no-cache cmake make g++ zsh bash jq pipx git
73+
5274
- name: Install pre-commit
5375
run: pipx install pre-commit
5476

5577
- uses: actions/checkout@v4
78+
- run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
79+
if: matrix.platform.type == 'container'
5680
- name: Install dependencies (macOS)
5781
if: runner.os == 'macos'
5882
run: brew bundle
5983
env:
6084
HOMEBREW_NO_ANALYTICS: 1
6185
HOMEBREW_NO_AUTO_UPDATE: 1
6286
- name: Install dependencies (Linux)
63-
if: runner.os == 'linux'
87+
if: runner.os == 'linux' && matrix.platform.type == 'native'
6488
run: sudo apt-get update --yes && sudo apt-get install --yes zsh
6589

6690
- run: cmake --version
@@ -103,7 +127,7 @@ jobs:
103127

104128
- uses: actions/upload-artifact@v4
105129
with:
106-
name: artifacts-${{ matrix.platform.os }}
130+
name: ${{ matrix.platform.artifact }}
107131
path: build/out/*.zip
108132
retention-days: 1
109133

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ jobs:
7979
if: runner.os == 'windows' && matrix.platform.type == 'wsl-2'
8080

8181
- uses: actions/checkout@v4
82+
- run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
83+
if: matrix.platform.type == 'container'
84+
8285
- name: Install dependencies (macOS)
8386
if: runner.os == 'macos'
8487
run: brew bundle

CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ if(PROJECT_IS_TOP_LEVEL)
5555
find_program(GIT_BIN NAMES git)
5656
if(GIT_BIN AND JSONSCHEMA_CONTINUOUS)
5757
execute_process(COMMAND "${GIT_BIN}" rev-parse --git-dir
58+
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
5859
ERROR_QUIET
5960
OUTPUT_STRIP_TRAILING_WHITESPACE
6061
OUTPUT_VARIABLE GIT_DIR)
@@ -67,6 +68,12 @@ if(PROJECT_IS_TOP_LEVEL)
6768
OUTPUT_STRIP_TRAILING_WHITESPACE
6869
COMMAND_ERROR_IS_FATAL ANY)
6970
else()
71+
if(NOT GIT_BIN)
72+
message(STATUS "Could not determine current Git SHA: Git not available")
73+
elseif(NOT EXISTS "${GIT_DIR}")
74+
message(STATUS "Could not determine current Git SHA: Git directory does not exist (${GIT_DIR})")
75+
endif()
76+
7077
set(PROJECT_GIT_SHA "unknown")
7178
endif()
7279

@@ -80,6 +87,17 @@ if(PROJECT_IS_TOP_LEVEL)
8087
set(LOWER_SYSTEM_PROCESSOR "arm64")
8188
endif()
8289
set(PLATFORM_SUFFIX "${LOWER_SYSTEM_NAME}-${LOWER_SYSTEM_PROCESSOR}")
90+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT CMAKE_CROSSCOMPILING)
91+
find_program(LDD_BIN NAMES ldd)
92+
if(LDD_BIN)
93+
execute_process(COMMAND "${LDD_BIN}" --version
94+
OUTPUT_VARIABLE LDD_OUTPUT
95+
ERROR_VARIABLE LDD_OUTPUT)
96+
if(LDD_OUTPUT MATCHES "musl")
97+
set(PLATFORM_SUFFIX "${PLATFORM_SUFFIX}-musl")
98+
endif()
99+
endif()
100+
endif()
83101
if(JSONSCHEMA_CONTINUOUS)
84102
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-${PROJECT_GIT_SHA}-${PLATFORM_SUFFIX}")
85103
else()

install

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,23 @@ then
2323

2424
PACKAGE_BASE_URL="https://github.com/$OWNER/$REPOSITORY/releases/download/v$VERSION"
2525
PACKAGE_PLATFORM_NAME="$(echo "$UNAME" | tr '[:upper:]' '[:lower:]')"
26-
PACKAGE_URL="$PACKAGE_BASE_URL/jsonschema-$VERSION-$PACKAGE_PLATFORM_NAME-$ARCH.zip"
26+
27+
if [ "$UNAME" = "Linux" ] && [ -f /etc/os-release ] && grep -qi alpine /etc/os-release
28+
then
29+
PACKAGE_NAME="jsonschema-$VERSION-$PACKAGE_PLATFORM_NAME-$ARCH-musl"
30+
else
31+
PACKAGE_NAME="jsonschema-$VERSION-$PACKAGE_PLATFORM_NAME-$ARCH"
32+
fi
33+
34+
PACKAGE_URL="$PACKAGE_BASE_URL/$PACKAGE_NAME.zip"
2735
echo "---- Fetching version v$VERSION from $PACKAGE_URL" 1>&2
2836
TMP="$(mktemp -d)"
2937
clean() { rm -rf "$TMP"; }
3038
trap clean EXIT
3139
curl --retry 5 --location --output "$TMP/artifact.zip" "$PACKAGE_URL"
3240
unzip "$TMP/artifact.zip" -d "$TMP/out"
3341
install -d -m 0755 "$OUTPUT/bin"
34-
install -v -m 0755 "$TMP/out/jsonschema-$VERSION-$PACKAGE_PLATFORM_NAME-$ARCH/bin/jsonschema" "$OUTPUT/bin"
42+
install -v -m 0755 "$TMP/out/$PACKAGE_NAME/bin/jsonschema" "$OUTPUT/bin"
3543
else
3644
echo "ERROR: I don't know how to install the JSON Schema CLI in $UNAME!" 1>&2
3745
echo "Open an issue here: https://github.com/sourcemeta/jsonschema/issues" 1>&2

0 commit comments

Comments
 (0)