-
Notifications
You must be signed in to change notification settings - Fork 0
272 lines (238 loc) · 8.42 KB
/
app-release.yml
File metadata and controls
272 lines (238 loc) · 8.42 KB
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
name: Build and Release App
on:
pull_request:
paths:
- ColimaStack/**
- ColimaStackTests/**
- ColimaStackUITests/**
- ColimaStack.xcodeproj/**
- .github/workflows/app-release.yml
push:
branches: [main]
tags:
- 'v*'
paths:
- ColimaStack/**
- ColimaStackTests/**
- ColimaStackUITests/**
- ColimaStack.xcodeproj/**
- .github/workflows/app-release.yml
workflow_dispatch:
inputs:
version:
description: Release version, without the leading v.
required: true
default: '0.0.1'
build_number:
description: Optional CFBundleVersion override. Defaults to the workflow run number.
required: false
permissions:
contents: read
concurrency:
group: app-${{ github.ref }}
cancel-in-progress: true
env:
APP_NAME: ColimaStack
PROJECT_PATH: ColimaStack.xcodeproj
SCHEME: ColimaStack
CONFIGURATION: Release
DERIVED_DATA_PATH: build/DerivedData
EXPORT_PATH: build/export
jobs:
app-smoke-tests:
name: App Smoke Tests (${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
needs: build
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
runner: [macos-14, macos-15, macos-26]
steps:
- name: Show runner platform
run: |
sw_vers
- name: Download app artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.build.outputs.artifact_name }}
path: smoke-assets
- name: Expand app artifact
shell: bash
run: |
set -euo pipefail
archive_path="smoke-assets/${{ needs.build.outputs.artifact_name }}.zip"
if [[ ! -f "$archive_path" ]]; then
echo "Expected app archive not found at $archive_path" >&2
exit 1
fi
mkdir -p smoke-app
ditto -x -k "$archive_path" smoke-app
- name: Launch app
shell: bash
run: |
set -euo pipefail
app_path="smoke-app/${APP_NAME}.app"
executable="$app_path/Contents/MacOS/${APP_NAME}"
log_path="$RUNNER_TEMP/${APP_NAME}-${{ matrix.runner }}.log"
if [[ ! -x "$executable" ]]; then
echo "Expected app executable not found at $executable" >&2
exit 1
fi
"$executable" --mock-data >"$log_path" 2>&1 &
app_pid="$!"
cleanup() {
kill "$app_pid" >/dev/null 2>&1 || true
wait "$app_pid" >/dev/null 2>&1 || true
}
trap cleanup EXIT
for _ in {1..15}; do
if ! kill -0 "$app_pid" >/dev/null 2>&1; then
echo "App exited before the smoke test completed." >&2
cat "$log_path" >&2 || true
exit 1
fi
sleep 1
done
echo "App stayed running during the smoke test."
build:
name: Build and Test
runs-on: macos-15
outputs:
version: ${{ steps.metadata.outputs.version }}
build_number: ${{ steps.metadata.outputs.build_number }}
artifact_name: ${{ steps.metadata.outputs.artifact_name }}
release_tag: ${{ steps.metadata.outputs.release_tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Resolve version metadata
id: metadata
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_BUILD_NUMBER: ${{ github.event.inputs.build_number }}
INPUT_VERSION: ${{ github.event.inputs.version }}
REF_NAME: ${{ github.ref_name }}
REF_TYPE: ${{ github.ref_type }}
RUN_NUMBER: ${{ github.run_number }}
run: |
set -euo pipefail
project_version="$(
xcodebuild -showBuildSettings \
-project "$PROJECT_PATH" \
-scheme "$SCHEME" \
-configuration "$CONFIGURATION" \
-destination 'generic/platform=macOS' \
-derivedDataPath "$DERIVED_DATA_PATH" \
| awk -F '= ' '/MARKETING_VERSION/ { print $2; exit }'
)"
if [[ -z "$project_version" ]]; then
echo "Unable to resolve MARKETING_VERSION from Xcode build settings." >&2
exit 1
fi
version="$project_version"
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
version="$INPUT_VERSION"
elif [[ "$REF_TYPE" == "tag" ]]; then
version="${REF_NAME#v}"
fi
build_number="$RUN_NUMBER"
if [[ "$EVENT_NAME" == "workflow_dispatch" && -n "$INPUT_BUILD_NUMBER" ]]; then
build_number="$INPUT_BUILD_NUMBER"
fi
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Version must use x.y.z format, for example 0.0.1." >&2
exit 1
fi
if [[ ! "$build_number" =~ ^[0-9]+$ ]]; then
echo "Build number must be numeric." >&2
exit 1
fi
release_tag="v${version}"
artifact_name="${APP_NAME}-${version}-${build_number}"
{
echo "version=${version}"
echo "build_number=${build_number}"
echo "release_tag=${release_tag}"
echo "artifact_name=${artifact_name}"
} >> "$GITHUB_OUTPUT"
- name: Run tests
run: |
xcodebuild test \
-project "$PROJECT_PATH" \
-scheme "$SCHEME" \
-configuration Debug \
-destination 'platform=macOS' \
-skip-testing:ColimaStackUITests \
-derivedDataPath "$DERIVED_DATA_PATH" \
-parallel-testing-enabled NO \
CODE_SIGNING_ALLOWED=NO
- name: Build app
run: |
xcodebuild build \
-project "$PROJECT_PATH" \
-scheme "$SCHEME" \
-configuration "$CONFIGURATION" \
-destination 'generic/platform=macOS' \
-derivedDataPath "$DERIVED_DATA_PATH" \
MARKETING_VERSION="${{ steps.metadata.outputs.version }}" \
CURRENT_PROJECT_VERSION="${{ steps.metadata.outputs.build_number }}" \
CODE_SIGNING_ALLOWED=NO \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGN_IDENTITY=""
- name: Package app
shell: bash
run: |
set -euo pipefail
app_path="$DERIVED_DATA_PATH/Build/Products/$CONFIGURATION/$APP_NAME.app"
if [[ ! -d "$app_path" ]]; then
echo "Expected app bundle not found at $app_path" >&2
exit 1
fi
mkdir -p "$EXPORT_PATH"
ditto -c -k --keepParent "$app_path" "$EXPORT_PATH/${{ steps.metadata.outputs.artifact_name }}.zip"
shasum -a 256 "$EXPORT_PATH/${{ steps.metadata.outputs.artifact_name }}.zip" \
> "$EXPORT_PATH/${{ steps.metadata.outputs.artifact_name }}.zip.sha256"
- name: Upload workflow artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.metadata.outputs.artifact_name }}
path: |
${{ env.EXPORT_PATH }}/${{ steps.metadata.outputs.artifact_name }}.zip
${{ env.EXPORT_PATH }}/${{ steps.metadata.outputs.artifact_name }}.zip.sha256
if-no-files-found: error
release:
name: Publish GitHub Release
runs-on: ubuntu-latest
needs:
- build
- app-smoke-tests
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Download app artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.build.outputs.artifact_name }}
path: release-assets
- name: Create or update release
env:
GH_TOKEN: ${{ github.token }}
REPOSITORY: ${{ github.repository }}
TAG: ${{ needs.build.outputs.release_tag }}
VERSION: ${{ needs.build.outputs.version }}
BUILD_NUMBER: ${{ needs.build.outputs.build_number }}
ARTIFACT_NAME: ${{ needs.build.outputs.artifact_name }}
run: |
set -euo pipefail
notes="ColimaStack ${VERSION} (${BUILD_NUMBER})"
if gh release view "$TAG" --repo "$REPOSITORY" >/dev/null 2>&1; then
gh release upload "$TAG" release-assets/* --repo "$REPOSITORY" --clobber
else
gh release create "$TAG" release-assets/* \
--repo "$REPOSITORY" \
--title "ColimaStack ${VERSION}" \
--notes "$notes"
fi