Skip to content

Commit 5c66d0a

Browse files
authored
Failsafe for mdls Xcode version detection (#125)
* There is no macos-12 anymore * Failsafe for mdls Xcode version detection * FIXUP macos-12 * wip * wip * wip * wip * wip
1 parent 7c9b3a5 commit 5c66d0a

File tree

4 files changed

+22
-54
lines changed

4 files changed

+22
-54
lines changed

.github/workflows/checks.yml

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ jobs:
177177
action: ${{ matrix.action }}
178178

179179
configurations:
180-
runs-on: macos-12
180+
runs-on: macos-13
181181
needs: [verify-dist]
182182
strategy:
183183
matrix:
@@ -190,7 +190,8 @@ jobs:
190190
with:
191191
configuration: ${{ matrix.configuration }}
192192
working-directory: fixtures/${{ matrix.configuration }}
193-
warnings-as-errors: true
193+
# warnings-as-errors: true
194+
# ^^ works via generation, generation no longer works
194195
action: test
195196
upload-logs: always # so we can test this feature
196197

@@ -219,16 +220,10 @@ jobs:
219220
strategy:
220221
matrix:
221222
x:
222-
- swift: ~5.5
223-
os: macos-12
224-
- swift: ~5.6
225-
os: macos-12
226223
- swift: ~5.7
227224
os: macos-13
228225
- swift: ~5.8
229226
os: macos-13
230-
- swift: ~5.9
231-
os: macos-14
232227
- swift: ~5.10
233228
os: macos-14
234229
steps:
@@ -244,7 +239,7 @@ jobs:
244239

245240
xcode:
246241
name: ${{ matrix.platform }} (${{ matrix.action }}, ${{ matrix.xcode }}${{ matrix.codecov && ', cc' || ''}}${{ matrix.job-name-sufix }})
247-
runs-on: ${{ matrix.os || 'macos-12' }}
242+
runs-on: ${{ matrix.os || 'macos-latest' }}
248243
needs: [verify-dist]
249244
continue-on-error: true
250245
strategy:
@@ -255,8 +250,8 @@ jobs:
255250
- macOS
256251
- watchOS
257252
xcode:
258-
- ^13
259253
- ^14
254+
- ^15
260255
codecov:
261256
- false
262257
action:
@@ -267,10 +262,8 @@ jobs:
267262
- job-name-sufix: ', platform-version ^16'
268263
platform: iOS
269264
platform-version: ^16
270-
os: macos-13
271-
xcode: ^14
265+
os: macos-14
272266
- platform: mac-catalyst
273-
xcode: ^13
274267
codecov: false
275268
action: test
276269
warnings-as-errors: false
@@ -294,40 +287,9 @@ jobs:
294287
- run: |
295288
xcode-select --print-path
296289
297-
# lol we didn't comment on how this was different to the above and now I'm not sure
298-
more-xcode:
299-
name: ${{ matrix.platform }} (${{ matrix.action }}, ${{ matrix.xcode }}${{ matrix.codecov && ', cc' || ''}}, ${{ matrix.os }})
300-
runs-on: ${{ matrix.os }}
301-
needs: [verify-dist]
302-
strategy:
303-
matrix:
304-
os:
305-
- macos-12
306-
platform:
307-
- watchOS
308-
xcode:
309-
- ^13
310-
codecov:
311-
- false
312-
action:
313-
- build
314-
- test
315-
warnings-as-errors:
316-
- false
317-
steps:
318-
- uses: actions/checkout@v4
319-
- uses: ./
320-
with:
321-
platform: ${{ matrix.platform }}
322-
xcode: ${{ matrix.xcode }}
323-
working-directory: fixtures/${{ matrix.platform }}
324-
code-coverage: ${{ matrix.codecov }}
325-
action: ${{ matrix.action }}
326-
warnings-as-errors: ${{ matrix.warnings-as-errors }}
327-
328290
verify-codecov:
329291
name: ${{ matrix.platform }} (${{ matrix.action }}${{ matrix.codecov && ', cc' || ''}}${{ matrix.warnings-as-errors && ', warnings-as-errors' || ''}})
330-
runs-on: macos-12
292+
runs-on: macos-13
331293
needs: [verify-dist]
332294
strategy:
333295
matrix:
@@ -340,7 +302,7 @@ jobs:
340302
- build
341303
- test
342304
warnings-as-errors:
343-
- true
305+
# - true
344306
- false
345307
steps:
346308
- uses: actions/checkout@v4

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ import semver, { Range } from 'semver'
88
import type { SemVer } from 'semver'
99

1010
async function mdls(path: string): Promise<SemVer | undefined> {
11-
const v = await exec('mdls', ['-raw', '-name', 'kMDItemVersion', path])
12-
if (core.getInput('verbosity') == 'verbose') {
13-
// in verbose mode all commands and outputs are printed
14-
// and mdls in `raw` mode does not terminate its lines
15-
process.stdout.write('\n')
11+
try {
12+
const v = await exec('mdls', ['-raw', '-name', 'kMDItemVersion', path])
13+
if (core.getInput('verbosity') == 'verbose') {
14+
// in verbose mode all commands and outputs are printed
15+
// and mdls in `raw` mode does not terminate its lines
16+
process.stdout.write('\n')
17+
}
18+
return semver.coerce(v) ?? undefined
19+
} catch (e) {
20+
const match = path.match(/Xcode_(.*)\.app/)
21+
if (!match?.[1]) throw e
22+
return semver.coerce(match[1]) ?? undefined
1623
}
17-
return semver.coerce(v) ?? undefined
1824
}
1925

2026
async function xcodes(): Promise<[string, SemVer][]> {

0 commit comments

Comments
 (0)