Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ci.yml #3804

Merged
merged 4 commits into from
May 5, 2024
Merged
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
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: recursive
# - name: xcode-select
# run: sudo xcode-select -s /Applications/Xcode_14.2.app
- name: brew install
run: brew install xcodegen
- name: package
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ If you would like to contribute financially to the development of Karabiner-Elem

System requirements to build Karabiner-Elements:

- macOS 12+
- Xcode 13.3+
- macOS 13+
- Xcode 15.0.1+
- Command Line Tools for Xcode (`xcode-select --install`)
- xz (`brew install xz`)
- [XcodeGen](https://github.com/yonaskolb/XcodeGen) (`brew install xcodegen`)
Expand Down
62 changes: 48 additions & 14 deletions make-package.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
#!/bin/bash

set -u
set -u # forbid undefined variables
set -e # forbid command failure

#
# Check Xcode version
#

# Note:
# Using `xcrun --show-sdk-version` in GitHub Actions results in the following error.
#
# ```
# xcodebuild: error: SDK "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" cannot be located.
# xcrun: error: unable to lookup item 'SDKVersion' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
# ```
#
# Therefore, we extract the version from the Info.plist of Xcode.app

sdkversion=$(xcrun --show-sdk-version)
if [ ${sdkversion%.*} -lt 12 ]; then
xcodeVersion=$(plutil -extract CFBundleShortVersionString raw "$(xcode-select -p)/../Info.plist")
xcodeMajorVersion=$(echo "$xcodeVersion" | sed 's|\..*$||')
echo "Xcode version: $xcodeVersion"
echo "Xcode major version: $xcodeMajorVersion"
if [[ "$xcodeMajorVersion" -lt 15 ]]; then
echo
echo 'ERROR:'
echo ' Xcode is too old.'
echo ' You have to use Xcode 13.1 or later.'
echo ' You have to use Xcode 15.0.1 or later.'
echo
exit 1
fi

# Package build into a signed .dmg file

version=$(cat version)

#
# Build
#

echo "make build"
ruby scripts/reduce-logs.rb 'make build' || exit 99

# --------------------------------------------------
echo "Copy Files"
#
# Copy files
#

set -e
echo "Copy Files"

rm -rf pkgroot
mkdir -p pkgroot
Expand Down Expand Up @@ -64,18 +83,26 @@ mkdir -p "$basedir"
cp -R "src/apps/EventViewer/build/Release/Karabiner-EventViewer.app" "$basedir"
cp -R "src/apps/SettingsWindow/build/Release/Karabiner-Elements.app" "$basedir"

set +e

#
# Sign with Developer ID
#

bash scripts/codesign.sh "pkgroot"

#
# Update file permissions
#

sh "scripts/setpermissions.sh" pkginfo
sh "scripts/setpermissions.sh" pkgroot

chmod 755 pkginfo/Scripts/postinstall
chmod 755 pkginfo/Scripts/preinstall

# --------------------------------------------------
#
# Create pkg
#

echo "Create pkg"

pkgName="Karabiner-Elements.pkg"
Expand Down Expand Up @@ -113,11 +140,18 @@ productbuild \
rm -f $archiveName/Installer.pkg
rm -f $archiveName/Karabiner-DriverKit-VirtualHIDDevice.pkg

# --------------------------------------------------
#
# Sign
#

echo "Sign with Developer ID"

bash scripts/codesign-pkg.sh $archiveName/$pkgName

# --------------------------------------------------
#
# Create dmg
#

echo "Make Archive"

# Note:
Expand Down
6 changes: 6 additions & 0 deletions scripts/codesign-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ readonly PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH

readonly CODE_SIGN_IDENTITY=$(bash $(dirname $0)/get-installer-codesign-identity.sh)

if [[ -z $CODE_SIGN_IDENTITY ]]; then
echo "Skip codesign"
exit 0
fi

readonly LOGFILE="$(dirname $0)/productsign.log"

err() {
Expand Down
Loading