Skip to content

Commit d8e7642

Browse files
authored
Merge pull request #12 from NakaokaRei/codex/add-ci-dependabot-maintain-release
Add CI, Dependabot, and modernize release workflow
2 parents 3b756a5 + 231884a commit d8e7642

4 files changed

Lines changed: 104 additions & 54 deletions

File tree

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
3+
updates:
4+
- package-ecosystem: github-actions
5+
directory: /
6+
schedule:
7+
interval: weekly

.github/workflows/release.yml

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,71 @@ name: Release
33
on:
44
push:
55
tags:
6-
- '*'
6+
- "*"
7+
8+
permissions:
9+
contents: write
710

811
jobs:
9-
build:
10-
runs-on: macos-latest
11-
env:
12-
DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer
12+
release:
13+
runs-on: macos-26
14+
timeout-minutes: 30
1315

1416
steps:
15-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v6
18+
19+
- name: Import signing certificate
20+
env:
21+
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
22+
CERTIFICATE_P12: ${{ secrets.CERTIFICATE_P12 }}
23+
run: |
24+
KEYCHAIN_PATH="$RUNNER_TEMP/build.keychain-db"
25+
CERTIFICATE_PATH="$RUNNER_TEMP/certificate.p12"
1626
17-
# See more details at https://docs.github.com/ja/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development
18-
- name: Import Certificate
19-
env:
20-
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
21-
CERTIFICATE_P12: ${{ secrets.CERTIFICATE_P12 }}
22-
run: |
23-
echo $CERTIFICATE_P12 | base64 --decode > certificate.p12
24-
security create-keychain -p runner build.keychain
25-
security default-keychain -s build.keychain
26-
security unlock-keychain -p runner build.keychain
27-
security import certificate.p12 -k build.keychain -P $CERTIFICATE_PASSWORD -T /usr/bin/codesign
27+
printf '%s' "$CERTIFICATE_P12" | base64 --decode > "$CERTIFICATE_PATH"
28+
security create-keychain -p runner "$KEYCHAIN_PATH"
29+
security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
30+
security unlock-keychain -p runner "$KEYCHAIN_PATH"
31+
security import "$CERTIFICATE_PATH" \
32+
-k "$KEYCHAIN_PATH" \
33+
-P "$CERTIFICATE_PASSWORD" \
34+
-T /usr/bin/codesign
35+
security set-key-partition-list \
36+
-S apple-tool:,apple: \
37+
-s \
38+
-k runner \
39+
"$KEYCHAIN_PATH"
40+
security list-keychains -d user -s "$KEYCHAIN_PATH"
2841
29-
- name: Allow keychain access
30-
run: |
31-
security set-key-partition-list -S apple-tool:,apple: -s -k runner build.keychain
42+
- name: Run tests
43+
run: |
44+
xcodebuild test \
45+
-project TrackpadAir.xcodeproj \
46+
-scheme TrackpadAir \
47+
-destination 'platform=macOS'
3248
33-
- name: Build app
34-
run: xcodebuild -scheme TrackpadAir -project TrackpadAir.xcodeproj build
49+
- name: Archive app
50+
run: |
51+
xcodebuild archive \
52+
-project TrackpadAir.xcodeproj \
53+
-scheme TrackpadAir \
54+
-archivePath "$RUNNER_TEMP/TrackpadAir.xcarchive"
3555
36-
- name: Archive app
37-
run: xcodebuild -scheme TrackpadAir -project TrackpadAir.xcodeproj archive -archivePath TrackpadAir.xcarchive
56+
- name: Package app
57+
run: |
58+
ditto -c -k --keepParent \
59+
"$RUNNER_TEMP/TrackpadAir.xcarchive/Products/Applications/TrackpadAir.app" \
60+
TrackpadAir.app.zip
3861
39-
- name: Zip .app file from Archive
40-
run: |
41-
cd TrackpadAir.xcarchive/Products/Applications
42-
zip -r TrackpadAir.app.zip TrackpadAir.app
43-
mv TrackpadAir.app.zip ../../../
62+
- name: Create GitHub release
63+
env:
64+
GH_TOKEN: ${{ github.token }}
65+
run: |
66+
gh release create "$GITHUB_REF_NAME" \
67+
TrackpadAir.app.zip \
68+
--generate-notes \
69+
--verify-tag
4470
45-
- name: Create Release
46-
id: create_release
47-
uses: actions/create-release@v1
48-
env:
49-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50-
with:
51-
tag_name: ${{ github.ref }}
52-
release_name: v${{ github.ref }}
53-
draft: false
54-
prerelease: false
55-
56-
- name: Upload Release Asset
57-
uses: actions/upload-release-asset@v1
58-
env:
59-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60-
with:
61-
upload_url: ${{ steps.create_release.outputs.upload_url }}
62-
asset_path: ./TrackpadAir.app.zip
63-
asset_name: TrackpadAir.app.zip
64-
asset_content_type: application/zip
71+
- name: Clean up keychain
72+
if: always()
73+
run: security delete-keychain "$RUNNER_TEMP/build.keychain-db" || true

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: test-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
test:
18+
runs-on: macos-26
19+
20+
steps:
21+
- uses: actions/checkout@v6
22+
23+
- name: Run tests
24+
run: |
25+
xcodebuild test \
26+
-project TrackpadAir.xcodeproj \
27+
-scheme TrackpadAir \
28+
-destination 'platform=macOS' \
29+
CODE_SIGNING_ALLOWED=NO

TrackpadAir/Manager/VideoCapture.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,24 @@ class VideoCapture: NSObject {
1919

2020
func setup() {
2121
captureSession.beginConfiguration()
22-
let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back)
2322
guard
24-
let deviceInput = try? AVCaptureDeviceInput(device: device!),
23+
let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back),
24+
let deviceInput = try? AVCaptureDeviceInput(device: device),
2525
captureSession.canAddInput(deviceInput)
26-
else { return }
26+
else {
27+
captureSession.commitConfiguration()
28+
return
29+
}
2730
captureSession.addInput(deviceInput)
2831

2932
let videoDataOutput = AVCaptureVideoDataOutput()
3033
videoDataOutput.setSampleBufferDelegate(self, queue: DispatchQueue(label: "mydispatchqueue"))
3134
videoDataOutput.alwaysDiscardsLateVideoFrames = true
3235

33-
guard captureSession.canAddOutput(videoDataOutput) else { return }
36+
guard captureSession.canAddOutput(videoDataOutput) else {
37+
captureSession.commitConfiguration()
38+
return
39+
}
3440
captureSession.addOutput(videoDataOutput)
3541
captureSession.commitConfiguration()
3642
}
@@ -56,4 +62,3 @@ extension VideoCapture: AVCaptureVideoDataOutputSampleBufferDelegate {
5662
}
5763
}
5864
}
59-

0 commit comments

Comments
 (0)