-
-
Notifications
You must be signed in to change notification settings - Fork 696
208 lines (185 loc) · 6.98 KB
/
build.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
name: Build and Upload Provenance
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true
env:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
SWIFT_PACKAGE_ALLOW_WRITING_TO_DIRECTORY: ${{ github.workspace }}
DEVELOPER_DIR: /Applications/Xcode_16.0.app/Contents/Developer
XCODE_VERSION: '16.0'
jobs:
build:
name: Build and upload Provenance
strategy:
fail-fast: false
matrix:
include:
- target: "Provenance-Lite-iOS"
sdk: iphoneos
scheme: "Provenance-Lite (AppStore) (Release)"
APP_NAME: "Provenance Lite"
IPA_NAME: "Provenance-Lite-iOS"
- target: "Provenance-Lite-tvOS"
sdk: appletvos
scheme: "Provenance-Lite (AppStore) (Release)"
APP_NAME: "Provenance Lite"
IPA_NAME: "Provenance-Lite-tvOS"
- target: "Provenance-iOS"
sdk: iphoneos
scheme: "Provenance (AppStore) (Release)"
APP_NAME: "Provenance"
IPA_NAME: "Provenance-iOS"
- target: "Provenance-tvOS"
sdk: appletvos
scheme: "Provenance (AppStore) (Release)"
APP_NAME: "Provenance"
IPA_NAME: "Provenance-tvOS"
runs-on: 'macos-latest'
timeout-minutes: 300
steps:
- name: Cache Git checkout
uses: actions/cache@v3
with:
path: .
key: git-checkout-${{ github.sha }}
restore-keys: |
git-checkout-
- name: Checkout code
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1.6.0
with:
xcode-version: ${{ env.XCODE_VERSION }}
- name: Set Build Number
run: |
BUILD_NUMBER=$(git rev-list --count HEAD)
echo "BUILD_NUMBER=${BUILD_NUMBER}" >> $GITHUB_ENV
echo "MARKETING_VERSION=$(grep 'MARKETING_VERSION' Build.xcconfig | cut -d'=' -f2 | xargs)" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: |
.build
~/Library/Caches/org.swift.swiftpm
~/Library/Developer/Xcode/DerivedData
key: ${{ runner.os }}-spm-xcode-${{ hashFiles('**/Package.resolved') }}-${{ hashFiles('**/*.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-xcode-
- name: Install dependencies
run: |
brew install ldid
brew install xcbeautify
- name: Clean Build Directory
run: |
rm -rf ./build
mkdir -p ./build
- name: Build Provenance
id: build
env:
MARKETING_VERSION: ${{ env.MARKETING_VERSION }}
BUILD_NUMBER: ${{ env.BUILD_NUMBER }}
run: |
start_time=$(date +%s)
xcodebuild -configuration Release \
-workspace Provenance.xcworkspace \
-scheme "${{ matrix.scheme }}" \
-sdk ${{ matrix.sdk }} \
-skipPackagePluginValidation \
-skipMacroValidation \
MARKETING_VERSION="${MARKETING_VERSION}" \
CURRENT_PROJECT_VERSION="${BUILD_NUMBER}" \
archive \
-archivePath ./archive \
CODE_SIGNING_REQUIRED=NO \
AD_HOC_CODE_SIGNING_ALLOWED=YES \
CODE_SIGNING_ALLOWED=NO \
SWIFT_PACKAGE_ALLOW_WRITING_TO_DIRECTORY=${{ env.SWIFT_PACKAGE_ALLOW_WRITING_TO_DIRECTORY }} \
DEVELOPMENT_TEAM=S32Z3HMYVQ \
ORG_IDENTIFIER=org.provenance-emu \
| xcbeautify
end_time=$(date +%s)
echo "duration=$((end_time - start_time))" >> $GITHUB_OUTPUT
- name: Fakesign app
run: |
echo "Checking entitlements file..."
ls -la "Provenance/"
echo "Checking app binary..."
ls -la "archive.xcarchive/Products/Applications/${{ matrix.APP_NAME }}.app/"
ldid -S"Provenance/Provenance-AppStore.entitlements" "archive.xcarchive/Products/Applications/${{ matrix.APP_NAME }}.app/${{ matrix.APP_NAME }}" || echo "::warning::Fakesign failed but continuing build"
- name: Convert to IPA
run: |
mkdir Payload
ls -la "archive.xcarchive/Products/Applications"
cp -pR "archive.xcarchive/Products/Applications/${{ matrix.APP_NAME }}.app" "Payload/${{ matrix.IPA_NAME }}.app"
zip -r "${{ matrix.IPA_NAME }}.ipa" Payload
- name: Upload Artifact
uses: actions/upload-artifact@v3.1.0
with:
name: "${{ matrix.IPA_NAME }}-v${{ env.MARKETING_VERSION }}(${{ env.BUILD_NUMBER }}).ipa"
path: "${{ matrix.IPA_NAME }}.ipa"
if-no-files-found: error
retention-days: 90
- name: Record Build Time
run: |
duration=${{ steps.build.outputs.duration }}
minutes=$((duration / 60))
seconds=$((duration % 60))
echo "Build took ${minutes}m ${seconds}s"
echo "### Build Time ⏱️" >> $GITHUB_STEP_SUMMARY
echo "- Duration: ${minutes}m ${seconds}s" >> $GITHUB_STEP_SUMMARY
- name: Build Summary
run: |
echo "### Build Complete! :rocket:" >> $GITHUB_STEP_SUMMARY
echo "- Version: ${{ env.MARKETING_VERSION }} (${{ env.BUILD_NUMBER }})" >> $GITHUB_STEP_SUMMARY
echo "- Target: ${{ matrix.target }}" >> $GITHUB_STEP_SUMMARY
echo "- Scheme: ${{ matrix.scheme }}" >> $GITHUB_STEP_SUMMARY
- name: Update Build Status
if: always()
run: |
if [ "${{ job.status }}" = "success" ]; then
echo "✅ Build succeeded for ${{ matrix.target }}"
else
echo "❌ Build failed for ${{ matrix.target }}"
exit 1
fi
- name: Notify Discord Build Status
if: always()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
if [ "${{ job.status }}" = "success" ]; then
STATUS_COLOR="65280"
STATUS="✅ Success"
else
STATUS_COLOR="16711680"
STATUS="❌ Failed"
fi
curl -H "Content-Type: application/json" -X POST $DISCORD_WEBHOOK \
-d '{
"embeds": [{
"title": "Build ${{ matrix.target }}",
"description": "Version ${{ env.MARKETING_VERSION }} (Build ${{ env.BUILD_NUMBER }})\nScheme: ${{ matrix.scheme }}\nBuild Duration: ${{ steps.build.outputs.duration }}s",
"color": '"$STATUS_COLOR"',
"footer": {
"text": "'"$STATUS"'"
}
}]
}'
- name: Cleanup
if: always()
run: |
rm -rf .git
rm -rf .build