-
Notifications
You must be signed in to change notification settings - Fork 1.1k
188 lines (186 loc) · 8.29 KB
/
apple.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: apple
on:
push:
branches:
- master
tags:
- '*'
pull_request: {}
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: true
matrix:
platform: [iPhoneOS, MacOSX]
arch: [arm64, x86_64]
exclude:
- platform: iPhoneOS
arch: x86_64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true
- id: sysroot
uses: ASzc/change-string-case-action@v1
with:
string: ${{ matrix.platform }}
- name: Download cctools
run: |
cd /opt
wget https://github.com/supertuxkart/dependencies/releases/download/cctools/cctools-14.1.tar.xz
tar xf cctools-14.1.tar.xz
rm cctools-14.1.tar.xz
- name: Restore timestamps
run: |
wget https://github.com/MestreLion/git-tools/archive/refs/heads/main.zip
unzip main.zip
python git-tools-main/git-restore-mtime
- name: List build cache restore keys
run: |
# Look for the last 9 build caches (GitHub supports max 10 including current one)
for number in 1 2 3 4 5 6 7 8 9
do
id=$((${{ github.run_number }} - number))
echo "cache_$number=apple-${{ github.ref }}-${{ matrix.arch }}-${{ matrix.platform }}-$id" >> $GITHUB_ENV
done
- name: Handle build cache
uses: actions/cache@v2
with:
path: |
build
key: apple-${{ github.ref }}-${{ matrix.arch }}-${{ matrix.platform }}-${{ github.run_number }}
restore-keys: |
${{ env.cache_1 }}
${{ env.cache_2 }}
${{ env.cache_3 }}
${{ env.cache_4 }}
${{ env.cache_5 }}
${{ env.cache_6 }}
${{ env.cache_7 }}
${{ env.cache_8 }}
${{ env.cache_9 }}
- name: Download dependencies
run: |
wget https://github.com/supertuxkart/dependencies/releases/download/preview/dependencies-${{ steps.sysroot.outputs.lowercase }}.tar.xz
tar xf dependencies-${{ steps.sysroot.outputs.lowercase }}.tar.xz
- name: Configure clang runtime name
run: |
if [ ${{ matrix.platform }} = "MacOSX" ]; then
echo "rt=osx" >> $GITHUB_ENV
elif [ ${{ matrix.platform }} = "iPhoneOS" ]; then
echo "rt=ios" >> $GITHUB_ENV
elif [ ${{ matrix.platform }} = "AppleTVOS" ]; then
echo "rt=tvos" >> $GITHUB_ENV
elif [ ${{ matrix.platform }} = "iPhoneSimulator" ]; then
echo "rt=iossim" >> $GITHUB_ENV
elif [ ${{ matrix.platform }} = "AppleTVSimulator" ]; then
echo "rt=tvossim" >> $GITHUB_ENV
fi
- name: Configure bulid
run: |
mkdir -p build
cd build
cmake .. -DCCTOOLS_PREFIX=/opt/cctools -DCCTOOLS_ARCH=${{ matrix.arch }} -DCCTOOLS_PLATFORM=${{ matrix.platform }} \
-DRT=/opt/cctools/darwin/libclang_rt.${{ env.rt }}.a -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cctools.cmake -DCHECK_ASSETS=OFF
- name: Build
run: |
cd build
make -j4
mv bin ../${{ steps.sysroot.outputs.lowercase }}-${{ matrix.arch }}
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: ${{ steps.sysroot.outputs.lowercase }}-${{ matrix.arch }}
path: ${{ steps.sysroot.outputs.lowercase }}-${{ matrix.arch }}
packaging:
name: Packaging STK
needs: build
runs-on: macos-latest
steps:
- name: Configure packaging name for git master branch
if: ${{ github.ref == 'refs/heads/master' }}
run: |
echo "release_tag=git`date +%Y%m%d`" >> $GITHUB_ENV
echo "release_name=preview" >> $GITHUB_ENV
- name: Configure packaging name for tag
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
echo "release_tag=`basename $GITHUB_REF`" >> $GITHUB_ENV
echo "release_name=`basename $GITHUB_REF`" >> $GITHUB_ENV
- name: Configure packaging name for non-releasing branch
if: ${{ (github.ref != 'refs/heads/master' && !startsWith(github.ref, 'refs/tags/')) || github.repository_owner != 'supertuxkart' }}
run: |
echo "release_tag=" >> $GITHUB_ENV
echo "release_name=" >> $GITHUB_ENV
- name: Check for prerelease
if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'rc') || contains(github.ref, 'beta') }}
run: |
echo "release_pre=true" >> $GITHUB_ENV
- name: Check for non-prerelease
if: ${{ github.ref != 'refs/heads/master' && !contains(github.ref, 'rc') && !contains(github.ref, 'beta') }}
run: |
echo "release_pre=false" >> $GITHUB_ENV
- name: Show packaging name
run : |
echo "${{ env.release_tag }}"
echo "${{ env.release_name }}"
echo "${{ env.release_pre }}"
- name: Download binaries
uses: actions/download-artifact@v4
- name: Mask developer name
run: |
echo "::add-mask::${{ secrets.MAC_DEVELOPER_NAME }}"
- name: Import certificates
if: ${{ env.release_tag != '' }}
uses: apple-actions/import-codesign-certs@v1
with:
p12-file-base64: ${{ secrets.MAC_DEVELOPER_ID_P12_FILE }}
p12-password: ${{ secrets.MAC_DEVELOPER_ID_P12_PASSWORD }}
- name: Run dylibbundler and sign STK
if: ${{ env.release_tag != '' }}
env:
developer_id: "Developer ID Application: ${{ secrets.MAC_DEVELOPER_NAME }} (${{ secrets.MAC_DEVELOPER_TEAM }})"
run: |
wget https://github.com/supertuxkart/dependencies/releases/download/preview/dependencies-macosx.tar.xz
tar xf dependencies-macosx.tar.xz
HOMEBREW_NO_AUTO_UPDATE=1 brew install dylibbundler
lipo -create ./macosx-x86_64/supertuxkart.app/Contents/MacOS/supertuxkart ./macosx-arm64/supertuxkart.app/Contents/MacOS/supertuxkart -output ./macosx-arm64/supertuxkart.app/Contents/MacOS/supertuxkart
chmod 755 ./macosx-arm64/supertuxkart.app/Contents/MacOS/supertuxkart
install_name_tool -change libcurl.4.dylib @rpath/libcurl.4.dylib ./macosx-arm64/supertuxkart.app/Contents/MacOS/supertuxkart
dylibbundler -od -b -x ./macosx-arm64/supertuxkart.app/Contents/MacOS/supertuxkart -d ./macosx-arm64/supertuxkart.app/Contents/libs/ -p @executable_path/../libs/ -s ./dependencies-macosx/lib -ns
# We use SDL_Vulkan_LoadLibrary for 10.9 compatibility, so otool -L supertuxkart has no libMoltenVK.dylib
cp ./dependencies-macosx/lib/libMoltenVK.dylib ./macosx-arm64/supertuxkart.app/Contents/libs/
cd ./macosx-arm64/supertuxkart.app/Contents/Resources/data
wget https://github.com/supertuxkart/stk-assets-mobile/releases/download/git/stk-assets-full.zip
unzip stk-assets-full.zip
rm stk-assets-full.zip
cd ../../../../..
mv ./macosx-arm64/supertuxkart.app SuperTuxKart.app
codesign --force --sign "$developer_id" SuperTuxKart.app/Contents/libs/*.dylib
codesign --force --options=runtime --deep --sign "$developer_id" SuperTuxKart.app
- name: "Notarize release build"
if: ${{ env.release_tag != '' && github.ref != 'refs/heads/master' }}
run: |
ditto -c -k --sequesterRsrc --keepParent SuperTuxKart.app tmp.zip
xcrun notarytool submit tmp.zip --apple-id ${{ secrets.STK_NOTARIZATION_USERNAME }} \
--password ${{ secrets.STK_NOTARIZATION_PASSWORD }} \
--team-id ${{ secrets.MAC_DEVELOPER_TEAM }} --wait
xcrun stapler staple SuperTuxKart.app
- name: Archive
if: ${{ env.release_tag != '' }}
run: |
ditto -c -k --sequesterRsrc --keepParent SuperTuxKart.app SuperTuxKart-${{ env.release_tag }}-mac.zip
- name: Create release
if: ${{ env.release_tag != '' }}
uses: ncipollo/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "SuperTuxKart*.zip"
tag: ${{ env.release_name }}
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
allowUpdates: true
prerelease: ${{ env.release_pre }}