-
Notifications
You must be signed in to change notification settings - Fork 0
305 lines (254 loc) Β· 10 KB
/
cicd.yml
File metadata and controls
305 lines (254 loc) Β· 10 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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# ClickIt CI/CD Pipeline
# Inspired by macos-auto-clicker-main with adaptations for Swift Package Manager
name: CI/CD Pipeline
on:
push:
branches: [ main, staging ]
tags: [ 'v*', 'beta*' ]
pull_request:
branches: [ main, staging, dev ]
types: [ opened, synchronize, reopened ]
# Prevent overlapping builds
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# Consistent environment across jobs
APP_NAME: ClickIt
BUNDLE_ID: com.jsonify.clickit
# macOS deployment target
MACOSX_DEPLOYMENT_TARGET: "15.0"
# Swift configuration
SWIFT_VERSION: "6.1"
jobs:
# === Code Quality Checks ===
quality_checks:
name: π Code Quality
runs-on: macos-15
timeout-minutes: 15
steps:
- name: π₯ Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for proper linting
- name: π§ Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: π¦ Swift Package Cache
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-swift-${{ hashFiles('Package.resolved', 'Package.swift') }}
restore-keys: |
${{ runner.os }}-swift-
- name: ποΈ Swift Build (Debug)
run: swift build --configuration debug
- name: π§ͺ Run Tests
run: |
swift test --enable-code-coverage
echo "β
All tests passed"
- name: π Test Coverage
run: |
xcrun llvm-cov export -format="lcov" \
.build/debug/ClickItPackageTests.xctest/Contents/MacOS/ClickItPackageTests \
-instr-profile .build/debug/codecov/default.profdata > coverage.lcov
continue-on-error: true
- name: π Upload Coverage
uses: codecov/codecov-action@v4
with:
file: ./coverage.lcov
fail_ci_if_error: false
continue-on-error: true
- name: π SwiftLint
run: |
if ! command -v swiftlint &> /dev/null; then
echo "Installing SwiftLint..."
brew install swiftlint
fi
swiftlint lint --strict --reporter github-actions-logging
echo "β
Linting passed"
# === Build Tests ===
build_tests:
name: π¨ Build Tests
runs-on: macos-15
needs: quality_checks
timeout-minutes: 20
strategy:
matrix:
configuration: [debug, release]
architecture: [x86_64, arm64]
steps:
- name: π₯ Checkout Code
uses: actions/checkout@v4
- name: π§ Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: π¦ Swift Package Cache
uses: actions/cache@v4
with:
path: .build
key: build-${{ runner.os }}-${{ matrix.configuration }}-${{ matrix.architecture }}-${{ hashFiles('Package.resolved', 'Package.swift') }}
restore-keys: |
build-${{ runner.os }}-${{ matrix.configuration }}-${{ matrix.architecture }}-
build-${{ runner.os }}-${{ matrix.configuration }}-
build-${{ runner.os }}-
- name: ποΈ Build for ${{ matrix.architecture }}
run: |
echo "Building for ${{ matrix.architecture }} in ${{ matrix.configuration }} mode..."
swift build --configuration ${{ matrix.configuration }} --arch ${{ matrix.architecture }}
echo "β
Build successful"
- name: π Verify Binary
run: |
BINARY_PATH=$(swift build --configuration ${{ matrix.configuration }} --arch ${{ matrix.architecture }} --show-bin-path)/ClickIt
if [ -f "$BINARY_PATH" ]; then
echo "β
Binary exists: $BINARY_PATH"
file "$BINARY_PATH"
lipo -info "$BINARY_PATH" 2>/dev/null || echo "Single architecture binary"
else
echo "β Binary not found at $BINARY_PATH"
exit 1
fi
# === Beta Release ===
beta_release:
name: π Beta Release
runs-on: macos-15
needs: [quality_checks, build_tests]
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'beta') && github.ref_name != ''
timeout-minutes: 30
steps:
- name: π₯ Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: π§ Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: π Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- name: π§ Install Fastlane Dependencies
run: |
bundle install
bundle exec fastlane install_plugins
- name: ποΈ Build App Bundle
run: |
./build_app.sh release
echo "β
App bundle created"
- name: π¦ Create Release Assets
run: |
# Extract version from tag (e.g., beta-v1.0.0-20250713 -> 1.0.0)
TAG_NAME="${{ github.ref_name }}"
VERSION=$(echo "$TAG_NAME" | sed -n 's/beta-v\?\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/p')
if [ -z "$VERSION" ]; then
VERSION="1.0.0"
fi
BETA_VERSION="${VERSION}-beta-$(git rev-parse --short HEAD)"
echo "BETA_VERSION=$BETA_VERSION" >> $GITHUB_ENV
# Create ZIP
cd dist
zip -r "${APP_NAME}-${BETA_VERSION}.zip" "${APP_NAME}.app"
echo "β
Created ZIP: ${APP_NAME}-${BETA_VERSION}.zip"
- name: π Generate Changelog
id: changelog
run: |
# Get previous tag for changelog
PREVIOUS_TAG=$(git describe --tags --abbrev=0 ${{ github.ref_name }}^ 2>/dev/null || echo "")
if [ -z "$PREVIOUS_TAG" ]; then
CHANGELOG="## What's New\n\nInitial release of ${{ env.APP_NAME }}!"
else
CHANGELOG="## What's New\n\n"
git log ${PREVIOUS_TAG}..${{ github.ref_name }} --oneline --no-merges | while read commit; do
commit_msg=$(echo "$commit" | cut -d' ' -f2-)
CHANGELOG="${CHANGELOG}- ${commit_msg}\n"
done
fi
CHANGELOG="β οΈ **This is a beta release for testing purposes.**\n\n${CHANGELOG}"
CHANGELOG="${CHANGELOG}\n\n---\nπ€ Generated with [Claude Code](https://claude.ai/code)\nπ± Compatible with macOS 15.0 or later"
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo -e "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: π Create GitHub Release
uses: ncipollo/create-release@v1
with:
tag: ${{ github.ref_name }}
name: "${{ env.APP_NAME }} ${{ env.BETA_VERSION }}"
body: ${{ steps.changelog.outputs.changelog }}
prerelease: true
artifacts: "dist/${{ env.APP_NAME }}-${{ env.BETA_VERSION }}.zip"
token: ${{ secrets.GITHUB_TOKEN }}
# === Production Release ===
production_release:
name: π Production Release
runs-on: macos-15
needs: [quality_checks, build_tests]
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v') && github.ref_name != ''
timeout-minutes: 30
steps:
- name: π₯ Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: π§ Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: π Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- name: π§ Install Fastlane Dependencies
run: |
bundle install
bundle exec fastlane install_plugins
- name: ποΈ Build App Bundle
run: |
./build_app.sh release
echo "β
App bundle created"
- name: π¦ Create Release Assets
run: |
# Extract version from tag (e.g., v1.0.0 -> 1.0.0)
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
cd dist
# Create ZIP
zip -r "${APP_NAME}-${VERSION}.zip" "${APP_NAME}.app"
echo "β
Created ZIP: ${APP_NAME}-${VERSION}.zip"
# Create DMG
hdiutil create -volname "${{ env.APP_NAME }}" -srcfolder "${APP_NAME}.app" -ov -format UDZO "${APP_NAME}-${VERSION}.dmg"
echo "β
Created DMG: ${APP_NAME}-${VERSION}.dmg"
- name: π Generate Changelog
id: changelog
run: |
# Get previous tag for changelog
PREVIOUS_TAG=$(git describe --tags --abbrev=0 ${{ github.ref_name }}^ 2>/dev/null || echo "")
if [ -z "$PREVIOUS_TAG" ]; then
CHANGELOG="## What's New\n\nInitial release of ${{ env.APP_NAME }}!"
else
CHANGELOG="## What's New\n\n"
git log ${PREVIOUS_TAG}..${{ github.ref_name }} --oneline --no-merges | while read commit; do
commit_msg=$(echo "$commit" | cut -d' ' -f2-)
CHANGELOG="${CHANGELOG}- ${commit_msg}\n"
done
fi
CHANGELOG="${CHANGELOG}\n\n---\nπ€ Generated with [Claude Code](https://claude.ai/code)\nπ± Compatible with macOS 15.0 or later"
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo -e "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: π Create GitHub Release
uses: ncipollo/create-release@v1
with:
tag: ${{ github.ref_name }}
name: "${{ env.APP_NAME }} v${{ env.VERSION }}"
body: ${{ steps.changelog.outputs.changelog }}
prerelease: false
artifacts: |
dist/${{ env.APP_NAME }}-${{ env.VERSION }}.zip
dist/${{ env.APP_NAME }}-${{ env.VERSION }}.dmg
token: ${{ secrets.GITHUB_TOKEN }}