Skip to content

Commit 6ad3a5b

Browse files
committed
Codesign and notarize macOS build
1 parent 9d75e4e commit 6ad3a5b

File tree

4 files changed

+106
-34
lines changed

4 files changed

+106
-34
lines changed

.github/workflows/gearsystem.yml

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
name: Main Workflow
1+
name: Build and Release
22

33
on:
44
workflow_dispatch:
55
push:
66
paths-ignore:
77
- '**.md'
8+
- '.github/**'
9+
- '.vscode/**'
10+
- '.devcontainer/**'
811
pull_request:
912
schedule:
1013
- cron: '0 0 * * 0'
@@ -49,6 +52,28 @@ jobs:
4952
with:
5053
name: ${{ env.NAME_UPPER }}-${{ env.BUILD_NUMBER }}-${{ matrix.os }}
5154
path: artifact/*
55+
linux-clang:
56+
name: Linux (Clang/LLVM)
57+
runs-on: ubuntu-latest
58+
permissions:
59+
contents: read
60+
steps:
61+
- name: Checkout
62+
uses: actions/checkout@v4
63+
with:
64+
fetch-depth: 0
65+
- name: Update OS
66+
run: sudo apt-get update -qq
67+
- name: Install dependencies
68+
run: sudo apt-get install -y libsdl2-dev libglew-dev libgtk-3-dev
69+
- name: Get build number
70+
run: |
71+
echo "BUILD_NUMBER=$(git describe --abbrev=7 --dirty --always --tags)" >> $GITHUB_ENV
72+
- name: make
73+
run: make
74+
working-directory: platforms/linux
75+
env:
76+
USE_CLANG: 1
5277
libretro:
5378
name: Libretro (ubuntu)
5479
runs-on: ubuntu-latest
@@ -98,12 +123,45 @@ jobs:
98123
- name: make
99124
run: make dist
100125
working-directory: platforms/macos
126+
- name: Codesign app bundle
127+
env:
128+
MACOS_CERTIFICATE: ${{ secrets.PROD_MACOS_CERTIFICATE }}
129+
MACOS_CERTIFICATE_PWD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }}
130+
MACOS_CERTIFICATE_NAME: ${{ secrets.PROD_MACOS_CERTIFICATE_NAME }}
131+
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
132+
run: |
133+
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
134+
135+
security create-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
136+
security default-keychain -s build.keychain
137+
security unlock-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
138+
security import certificate.p12 -k build.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign
139+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_CI_KEYCHAIN_PWD" build.keychain
140+
141+
codesign -v -f -o runtime --sign "$MACOS_CERTIFICATE_NAME" ${{ env.NAME_UPPER }}.app/Contents/MacOS/gamecontrollerdb.txt
142+
codesign -v -f -o runtime --entitlements "app.entitlements" --sign "$MACOS_CERTIFICATE_NAME" ${{ env.NAME_UPPER }}.app/Contents/MacOS/${{ env.NAME_LOWER }}
143+
codesign -v -f -o runtime --sign "$MACOS_CERTIFICATE_NAME" ${{ env.NAME_UPPER }}.app
144+
145+
codesign -v -vvv --deep "${{ env.NAME_UPPER }}.app"
146+
working-directory: platforms/macos
147+
- name: Notarize app bundle
148+
env:
149+
PROD_MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
150+
PROD_MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
151+
PROD_MACOS_NOTARIZATION_PWD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
152+
run: |
153+
xcrun notarytool store-credentials "notarytool-profile" --apple-id "$PROD_MACOS_NOTARIZATION_APPLE_ID" --team-id "$PROD_MACOS_NOTARIZATION_TEAM_ID" --password "$PROD_MACOS_NOTARIZATION_PWD"
154+
ditto -c -k --keepParent "${{ env.NAME_UPPER }}.app" "notarization.zip"
155+
xcrun notarytool submit "notarization.zip" --keychain-profile "notarytool-profile" --wait
156+
xcrun stapler staple "${{ env.NAME_UPPER }}.app"
157+
spctl -a -vvv -t install "${{ env.NAME_UPPER }}.app"
158+
ditto -c -k --keepParent "${{ env.NAME_UPPER }}.app" "${{ env.NAME_UPPER }}.app.zip"
159+
working-directory: platforms/macos
101160
- name: Prepare artifact directory
102161
run: |
103162
mkdir -p artifact
104-
cp platforms/README.txt artifact
105-
cp platforms/gamecontrollerdb.txt artifact
106-
cp -R platforms/macos/${{ env.NAME_UPPER }}.app artifact
163+
cp platforms/README.txt artifact/
164+
mv platforms/macos/${{ env.NAME_UPPER }}.app.zip artifact/
107165
- name: Archive binary
108166
uses: actions/upload-artifact@v4
109167
with:
Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
CXX = g++
2-
CC = gcc
3-
#CXX = clang++
4-
#CC = clang
1+
define HEADER
2+
____ _
3+
/ ___| ___ __ _ _ __ ___ _ _ ___| |_ ___ _ __ ___
4+
| | _ / _ \\/ _` | '__/ __| | | / __| __/ _ \\ '_ ` _ \\
5+
| |_| | __/ (_| | | \\__ \\ |_| \\__ \\ || __/ | | | | |
6+
\\____|\\___|\\__,_|_| |___/\\__, |___/\\__\\___|_| |_| |_|
7+
|___/
8+
9+
** Building for $(PLATFORM) platform **
10+
** Git version: $(GIT_VERSION) **
11+
12+
endef
13+
export HEADER
514

615
TARGET_NAME = gearsystem
716
GIT_VERSION := "$(shell git describe --abbrev=7 --dirty --always --tags)"
@@ -10,17 +19,28 @@ PLATFORM = "undefined"
1019

1120
OBJECTS += $(SOURCES_C:.c=.o) $(SOURCES_CXX:.cpp=.o)
1221

22+
USE_CLANG ?= 0
23+
ifeq ($(USE_CLANG), 1)
24+
CXX = clang++
25+
CC = clang
26+
else
27+
CXX = g++
28+
CC = gcc
29+
endif
30+
1331
CPPFLAGS += -I../ -I../../
1432
CPPFLAGS += -Wall -Wextra -Wformat -DEMULATOR_BUILD=\"$(GIT_VERSION)\"
1533
CXXFLAGS += -std=c++11
1634
CFLAGS += -std=c99
1735

1836
DEBUG ?= 0
1937
ifeq ($(DEBUG), 1)
38+
BUILD_CONFIG = Debug
2039
CPPFLAGS +=-DDEBUG -g3
2140
else
22-
CPPFLAGS +=-DNDEBUG -O3 -flto
23-
LDFLAGS += -flto
41+
BUILD_CONFIG = Release
42+
CPPFLAGS +=-DNDEBUG -O3 -flto=auto
43+
LDFLAGS += -O3 -flto=auto
2444
endif
2545

2646
SANITIZE ?= 0
@@ -29,23 +49,17 @@ ifeq ($(SANITIZE), 1)
2949
LDFLAGS += -lasan
3050
endif
3151

32-
ifeq ($(UNAME_S), Linux) #LINUX
52+
ifeq ($(UNAME_S), Linux)
3353
PLATFORM = "Linux"
3454
LDFLAGS += -lGL -lGLEW -ldl `sdl2-config --libs`
3555
CPPFLAGS += `sdl2-config --cflags`
3656
TARGET := $(TARGET_NAME)
37-
else ifeq ($(UNAME_S), Darwin) #APPLE
57+
else ifeq ($(UNAME_S), Darwin)
3858
PLATFORM = "macOS"
39-
LDFLAGS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs`
40-
LDFLAGS += -L/usr/local/lib
59+
LDFLAGS += -framework OpenGL `sdl2-config --static-libs`
4160
CPPFLAGS += `sdl2-config --cflags`
42-
CPPFLAGS += -I/usr/local/include -I/opt/local/include
61+
CPPFLAGS += -I/opt/local/include
4362
TARGET := $(TARGET_NAME)
44-
else ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
45-
PLATFORM = "MinGW"
46-
LDFLAGS += -lgdi32 -lopengl32 -lglew32 -limm32 `pkg-config --static --libs sdl2`
47-
CPPFLAGS += `pkg-config --cflags sdl2`
48-
TARGET := $(TARGET_NAME).exe
4963
else
5064
PLATFORM = "Generic Unix-like/BSD"
5165
LDFLAGS += `sdl2-config --libs` -lSDL2
@@ -56,8 +70,8 @@ else
5670
TARGET := $(TARGET_NAME)
5771
endif
5872

59-
all: $(TARGET)
60-
@echo Build complete for $(PLATFORM)
73+
all: header $(TARGET)
74+
@echo Build complete for $(PLATFORM) \($(BUILD_CONFIG)\)
6175

6276
$(TARGET): $(OBJECTS)
6377
$(CXX) -o $@ $(OBJECTS) $(LDFLAGS)
@@ -72,4 +86,7 @@ $(TARGET): $(OBJECTS)
7286
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
7387

7488
clean:
75-
rm -f $(OBJECTS) $(TARGET)
89+
rm -f $(OBJECTS) $(TARGET)
90+
91+
header:
92+
@echo "$$HEADER"

platforms/macos/Makefile

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,16 @@ LDFLAGS += -framework AppKit -framework UniformTypeIdentifiers
66

77
include ../desktop-shared/Makefile.common
88

9-
# Brew use a different path on Apple Silicon as on Intel
10-
UNAME_P := $(shell uname -m)
11-
ifneq ($(filter arm64%,$(UNAME_P)),)
12-
DYLIB_PATH=/opt/homebrew/lib/
13-
else
14-
DYLIB_PATH=/usr/local/opt/sdl2/lib
15-
endif
16-
17-
SDL_DYLIB=libSDL2-2.0.0.dylib
189
APP_NAME=Gearsystem
1910

2011
bundle:
2112
rm -rf $(APP_NAME).app
2213
mkdir -p $(APP_NAME).app/Contents/{MacOS,Resources,Frameworks}
2314
sed -e "s/@version@/$(GIT_VERSION)/g" Info.plist > $(APP_NAME).app/Contents/Info.plist
24-
cp $(DYLIB_PATH)/$(SDL_DYLIB) $(APP_NAME).app/Contents/Frameworks/
2515
cp iconfile.icns $(APP_NAME).app/Contents/Resources/
2616
cp $(TARGET) $(APP_NAME).app/Contents/MacOS/
2717
cp run.sh $(APP_NAME).app/Contents/MacOS/
2818
cp ../gamecontrollerdb.txt $(APP_NAME).app/Contents/MacOS/
29-
install_name_tool -change $(DYLIB_PATH)/$(SDL_DYLIB) @$(APP_NAME).app/Contents/MacOS/$(SDL_DYLIB) $(APP_NAME).app/Contents/MacOS/$(APP_NAME)
3019

3120
dist: clean all bundle
3221
@echo Success!!

platforms/macos/app.entitlements

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.cs.disable-library-validation</key>
6+
<true/>
7+
</dict>
8+
</plist>

0 commit comments

Comments
 (0)