Skip to content

Commit

Permalink
Merge pull request #58 from kambala-decapitator/ci-macos
Browse files Browse the repository at this point in the history
[CI] add macOS
  • Loading branch information
chewitt authored Feb 23, 2024
2 parents f6819cd + e248a39 commit b57d5b3
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 52 deletions.
44 changes: 26 additions & 18 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,38 @@ jobs:
matrix:
include:
- os: ubuntu-22.04
CC: gcc
CXX: g++
platform: linux
- os: macos-latest
platform: macos
preset: release-macos
artifact: '*.dmg'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
run: |
sudo add-apt-repository universe -y
sudo apt update -y
sudo apt install -y cmake \
gcc \
g++ \
libgl1-mesa-dev \
qt6-base-dev \
qt6-l10n-tools \
qt6-tools-dev \
qt6-tools-dev-tools \
qt6-wayland-dev
- name: Configure
ci/${{ matrix.platform }}/setup.sh
env:
CC: ${{ matrix.CC }}
CXX: ${{ matrix.CXX }}
MACOS_ASC_API_KEY: ${{ secrets.MACOS_ASC_API_KEY }}
MACOS_CODE_SIGN_KEY_BASE64: ${{ secrets.MACOS_CODE_SIGN_KEY_BASE64 }}
MACOS_KEYCHAIN_PASSWORD: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
- name: Configure
run: |
cmake -DCMAKE_BUILD_TYPE=Release -S ${{ github.workspace }} -B build
cmake --preset ${{ matrix.preset || 'release' }}
- name: Build
run: |
cmake --build build --parallel
cmake --build --preset release
- name: Pack
if: ${{ matrix.artifact }}
run: |
cpack --preset release
env:
ASC_API_KEY_ID: ${{ secrets.MACOS_ASC_API_KEY_ID }}
ASC_API_KEY_ISSUER: ${{ secrets.MACOS_ASC_API_KEY_ISSUER }}
ASC_TEAM_ID: ${{ secrets.MACOS_ASC_TEAM_ID }}
- name: Artifact
if: ${{ matrix.artifact }}
uses: actions/upload-artifact@v4
with:
path: build/${{ matrix.artifact }}
name: ${{ matrix.platform }}
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ set(CPACK_PACKAGE_NAME "${projectDisplayName}")
set(CPACK_PACKAGE_VENDOR "LibreELEC")
if(APPLE)
set(CPACK_PACKAGE_FILE_NAME "LibreELEC.USB-SD.Creator.macOS")
set(CPACK_POST_BUILD_SCRIPTS "${CMAKE_SOURCE_DIR}/dmg_osx/notarize.cmake")

set(notarizeScript "${CMAKE_BINARY_DIR}/notarize.cmake")
file(WRITE "${notarizeScript}"
"execute_process(COMMAND sh -c \"${CMAKE_SOURCE_DIR}/dmg_osx/notarize.sh \${CPACK_PACKAGE_FILES}\")"
)
set(CPACK_POST_BUILD_SCRIPTS "${notarizeScript}")

set(CPACK_GENERATOR DragNDrop)
set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/dmg_osx/background.png")
Expand Down
37 changes: 37 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"version": 6,
"configurePresets": [
{
"name": "release",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "release-macos",
"inherits": "release",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_OSX_ARCHITECTURES": "x86_64;arm64",
"CMAKE_OSX_DEPLOYMENT_TARGET": "11.0"
}
}
],
"buildPresets": [
{
"name": "release",
"configurePreset": "release"
}
],
"packagePresets": [
{
"name": "release",
"configurePreset": "release",
"output": {
"verbose": true
}
}
]
}
16 changes: 16 additions & 0 deletions ci/linux/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

sudo add-apt-repository universe -y
sudo apt update -y
sudo apt install -y cmake \
gcc \
g++ \
libgl1-mesa-dev \
qt6-base-dev \
qt6-l10n-tools \
qt6-tools-dev \
qt6-tools-dev-tools \
qt6-wayland-dev \

echo "CC=gcc" >> $GITHUB_ENV
echo "CXX=g++" >> $GITHUB_ENV
30 changes: 30 additions & 0 deletions ci/macos/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

brew install ninja

cd ..
for module in base tools ; do
archive="$module.7z"
curl -L -o "$archive" "https://download.qt.io/online/qtsdkrepository/mac_x64/desktop/qt6_662/qt.qt6.662.clang_64/6.6.2-0-202402121131qt$module-MacOS-MacOS_13-Clang-MacOS-MacOS_13-X86_64-ARM64.7z"
7z x "$archive" '-xr!*.dSYM'
done
echo "CMAKE_PREFIX_PATH=$PWD/$(ls -1 | fgrep 6.)/macos" >> $GITHUB_ENV

if [ "$MACOS_ASC_API_KEY" ]; then
ascApiKey='ascApiKey.p8'
echo "$MACOS_ASC_API_KEY" > "$ascApiKey"
echo "ASC_API_KEY_PATH=$PWD/$ascApiKey" >> $GITHUB_ENV
fi

if [[ "$MACOS_CODE_SIGN_KEY_BASE64" && "$MACOS_KEYCHAIN_PASSWORD" ]]; then
codesignKey='codesign.p12'
echo "$MACOS_CODE_SIGN_KEY_BASE64" | base64 --decode > "$codesignKey"
echo "CODE_SIGN_IDENTITY=Developer ID Application: Kodi Foundation" >> $GITHUB_ENV

keychainPath='build.keychain'
security create-keychain -p "$MACOS_KEYCHAIN_PASSWORD" "$keychainPath"
security unlock-keychain -p "$MACOS_KEYCHAIN_PASSWORD" "$keychainPath"
security default-keychain -s "$keychainPath"
security import "$codesignKey" -f pkcs12 -P "" -T "$(which codesign)" "$keychainPath"
security set-key-partition-list -S apple-tool:,apple: -s -k "$MACOS_KEYCHAIN_PASSWORD" "$keychainPath"
fi
6 changes: 3 additions & 3 deletions dmg_osx/DS_Store_Setup.scpt.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ on run argv
set dmg_topleft_x to 100
set dmg_topleft_y to 100
set dmg_width to 480
set dmg_height to 320
set dmg_height to (320 + 28)
set dmg_bottomright_x to (dmg_topleft_x + dmg_width)
set dmg_bottomright_y to (dmg_topleft_y + dmg_height)

set le_icon_x to 130
set app_icon_x to 360
set both_icon_y to 180
set both_icon_y to 185

open
set viewOptions to the icon view options of container window
set arrangement of viewOptions to not arranged
Expand Down
30 changes: 0 additions & 30 deletions dmg_osx/notarize.cmake

This file was deleted.

26 changes: 26 additions & 0 deletions dmg_osx/notarize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

dmgPath="$1"

if [ -z "$CODE_SIGN_IDENTITY" ] ; then
echo 'skip dmg signing & notarization - no code sign identity provided in CODE_SIGN_IDENTITY'
exit 0
fi
echo 'sign dmg'
codesign --verbose=4 --force --sign "$CODE_SIGN_IDENTITY" "$dmgPath"

if [[ -z "$ASC_API_KEY_PATH" || -z "$ASC_API_KEY_ID" || -z "$ASC_API_KEY_ISSUER" || -z "$ASC_TEAM_ID" ]] ; then
echo 'skip dmg notarization - ASC_API_KEY_PATH / ASC_API_KEY_ID / ASC_API_KEY_ISSUER / ASC_TEAM_ID not provided'
exit 0
fi
echo 'notarize dmg'
xcrun notarytool submit \
--verbose \
--key "$ASC_API_KEY_PATH" \
--key-id "$ASC_API_KEY_ID" \
--issuer "$ASC_API_KEY_ISSUER" \
--team-id "$ASC_TEAM_ID" \
--wait \
--timeout 30m \
"$dmgPath"
xcrun stapler staple "$dmgPath"

0 comments on commit b57d5b3

Please sign in to comment.