Skip to content

Commit

Permalink
Merge pull request #3804 from pqrs-org/update-ci
Browse files Browse the repository at this point in the history
Improve ci.yml
  • Loading branch information
tekezo committed May 5, 2024
2 parents 7b2bdd0 + 6bc77eb commit 89052ad
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 18 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
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
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
@@ -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
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

0 comments on commit 89052ad

Please sign in to comment.