Skip to content

Commit d014e0c

Browse files
chore: Reorganize repo (#15)
* Reorganize repo to make better use of Xcode features * Update web service property names * Example app cleanup * Differentiate dev/release Package.swift files * Update README to reflect new project structure and build steps * Update signing server base URL config * Update xcode version * Fix Swift concurrency build errors * Fix xcframework location * More makefile updates * Fix build output lookup * Update Package.swift for release v0.0.3 * Update gitignore * Update Package.swift * Update ios-framework task * Remove release build step * Update Package.swift for release v0.0.4 * Update C2PAC binary target URL to version 0.0.4 * Update plist and release path * Update Package.swift for release v0.0.5 * Release process fixes * Fix C2PAC plist values * Allow custom headers on WebServiceSigner --------- Co-authored-by: GitHub Actions <[email protected]>
1 parent dd33b8c commit d014e0c

File tree

98 files changed

+11499
-5184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+11499
-5184
lines changed

.github/workflows/release.yml

Lines changed: 21 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,83 +4,53 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: 'Version for the release (e.g. v1.0.0)'
7+
description: "Version for the release (e.g. v1.0.0)"
88
required: true
99
type: string
1010

1111
jobs:
1212
build-and-release:
13-
runs-on: macos-latest
14-
13+
runs-on: macos-15
14+
1515
steps:
1616
- name: Checkout repository
1717
uses: actions/checkout@v4
18-
18+
1919
- name: Validate version format
20-
run: |
21-
if [[ ! "${{ github.event.inputs.version }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
22-
echo "::error::Version must be in format vX.Y.Z (e.g., v1.0.0)"
23-
exit 1
24-
fi
25-
20+
run: make validate-version VERSION="${{ github.event.inputs.version }}"
21+
2622
- name: Display release information
2723
run: |
2824
echo "Starting release process for version ${{ github.event.inputs.version }}"
2925
echo "This workflow will:"
30-
echo "1. Download pre-built binaries from GitHub releases"
31-
echo "2. Build iOS XCFramework"
32-
echo "3. Create and publish Swift Package"
33-
echo "4. Create GitHub release with artifacts"
26+
echo "1. Build iOS XCFramework"
27+
echo "2. Create and publish Swift Package"
28+
echo "3. Create GitHub release with artifacts"
29+
30+
- name: Set up Xcode 16.4
31+
uses: maxim-lobanov/setup-xcode@v1
32+
with:
33+
xcode-version: 16.4
34+
35+
- name: Verify Xcode version
36+
run: xcodebuild -version
3437

35-
- name: Select Xcode version
36-
run: |
37-
sudo xcode-select -s /Applications/Xcode_15.4.app
38-
xcodebuild -version
39-
40-
- name: Run tests before release
41-
run: |
42-
cd example
43-
xcodebuild test \
44-
-scheme C2PAExample \
45-
-destination 'platform=iOS Simulator,name=iPhone 16 Pro,OS=18.4' \
46-
| xcpretty --test --color
47-
4838
- name: Build iOS Framework
4939
run: make ios-framework
5040

51-
- name: Zip XCFramework for distribution
52-
run: |
53-
cd output
54-
zip -r C2PAC.xcframework.zip C2PAC.xcframework
55-
5641
- name: Compute checksum for XCFramework
5742
id: compute-checksum
5843
run: |
59-
cd output
60-
CHECKSUM=$(swift package compute-checksum C2PAC.xcframework.zip)
44+
CHECKSUM=$(make compute-checksum | tail -1)
6145
echo "CHECKSUM=$CHECKSUM" >> $GITHUB_ENV
6246
echo "Checksum: $CHECKSUM"
6347
6448
- name: Archive Swift Package
65-
run: |
66-
cd output
67-
zip -r C2PA-Swift-Package.zip C2PA-iOS/
68-
69-
- name: Copy Package.swift from template to root
70-
run: |
71-
cp template/Package.swift ./Package.swift
49+
run: make package-swift
7250

7351
- name: Update Package.swift with release URL and checksum
7452
run: |
75-
VERSION="${{ github.event.inputs.version }}"
76-
CHECKSUM="${{ env.CHECKSUM }}"
77-
78-
# Replace the path with URL and checksum (using # as delimiter)
79-
sed -i '' 's# path: "Frameworks/C2PAC.xcframework"# url: "https://github.com/${{ github.repository }}/releases/download/'${VERSION}'/C2PAC.xcframework.zip",\n checksum: "'${CHECKSUM}'"#g' ./Package.swift
80-
81-
# Replace the path to the Swift file
82-
sed -i '' 's# path: "Sources/C2PA"# path: "src"#g' ./Package.swift
83-
53+
make update-package-swift VERSION="${{ github.event.inputs.version }}" CHECKSUM="${{ env.CHECKSUM }}" GITHUB_REPOSITORY="${{ github.repository }}"
8454
# Show the updated file
8555
cat ./Package.swift
8656
@@ -137,4 +107,4 @@ jobs:
137107
138108
See the README.md for detailed integration instructions.
139109
env:
140-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 54 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,39 @@ on:
77
workflow_dispatch:
88

99
env:
10-
SCHEME: C2PAExample
10+
SCHEME: Library
1111

1212
jobs:
13+
lint:
14+
name: Lint
15+
runs-on: macos-15
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Xcode
20+
uses: maxim-lobanov/setup-xcode@v1
21+
with:
22+
xcode-version: "16.4"
23+
24+
- name: Install SwiftLint
25+
run: brew install swiftlint
26+
27+
- name: Run SwiftLint
28+
run: make lint
29+
1330
test:
1431
name: ${{ matrix.device }} Xcode ${{ matrix.xcode }}
15-
runs-on: macos-14
32+
runs-on: macos-15
1633
strategy:
1734
fail-fast: false
1835
matrix:
19-
xcode: ["16.1"]
36+
xcode: ["16.4"]
2037
device:
2138
[
2239
"iPhone 16 Pro",
23-
"iPhone 16",
24-
"iPhone SE (3rd generation)",
25-
"iPad Pro 11-inch (M4)",
40+
"iPhone 16"
2641
]
27-
ios: ["18.1"]
42+
ios: ["18.5"]
2843

2944
steps:
3045
- uses: actions/checkout@v4
@@ -37,178 +52,85 @@ jobs:
3752
- name: Verify Xcode version
3853
run: xcodebuild -version
3954

40-
- name: Build iOS Framework
41-
run: make ios-framework
42-
43-
- name: Setup Signing Server
44-
run: |
45-
echo "Setting up C2PA signing server..."
46-
make setup-server
47-
48-
- name: Build Signing Server
49-
run: |
50-
cd signing-server
51-
swift build
55+
- name: Build Library
56+
run: make library DESTINATION="platform=iOS Simulator,name=${{ matrix.device }},OS=${{ matrix.ios }}"
5257

5358
- name: Start Signing Server
5459
run: |
55-
cd signing-server
56-
DYLD_LIBRARY_PATH=libs:$DYLD_LIBRARY_PATH .build/debug/Run serve --env development --hostname 127.0.0.1 --port 8080 &
57-
echo $! > ../server.pid
58-
echo "Server started with PID $(cat ../server.pid)"
60+
make signing-server-start
61+
sleep 5
5962
6063
- name: Wait for Server to be Ready
61-
run: |
62-
echo "Waiting for signing server to be ready..."
63-
max_attempts=30
64-
attempt=0
65-
while [ $attempt -lt $max_attempts ]; do
66-
if curl -s http://127.0.0.1:8080/health > /dev/null 2>&1; then
67-
echo "✓ Signing server is ready"
68-
break
69-
fi
70-
echo "Waiting for server... (attempt $((attempt + 1))/$max_attempts)"
71-
sleep 2
72-
attempt=$((attempt + 1))
73-
done
74-
75-
if [ $attempt -eq $max_attempts ]; then
76-
echo "❌ Server failed to start after $max_attempts attempts"
77-
exit 1
78-
fi
64+
run: make signing-server-wait
7965

8066
- name: Verify Server Endpoints
81-
run: |
82-
echo "Testing server endpoints..."
83-
curl -v http://127.0.0.1:8080/health || echo "Health check failed"
84-
echo ""
85-
echo "Server is listening on:"
86-
lsof -i :8080 || echo "No process on port 8080"
87-
88-
- name: Clean Build Directory
89-
run: |
90-
cd example
91-
xcodebuild clean -project C2PAExample.xcodeproj -scheme "$SCHEME"
92-
93-
- name: Resolve Package Dependencies
94-
run: |
95-
cd example
96-
xcodebuild -resolvePackageDependencies -project C2PAExample.xcodeproj -scheme "$SCHEME"
67+
run: make signing-server-verify
9768

9869
- name: Build & Test
9970
run: |
10071
set -o pipefail
101-
cd example
10272
echo "CI environment variable: true"
10373
echo "Testing with server at http://127.0.0.1:8080"
104-
TEST_RUNNER_CI=true xcrun xcodebuild test \
105-
-project C2PAExample.xcodeproj \
106-
-scheme "$SCHEME" \
107-
-sdk iphonesimulator \
108-
-destination "platform=iOS Simulator,name=${{ matrix.device }},OS=${{ matrix.ios }}" \
109-
-resultBundlePath TestResults \
110-
-enableCodeCoverage YES \
111-
| xcpretty --test --color
74+
TEST_RUNNER_CI=true make test-library DESTINATION="platform=iOS Simulator,name=${{ matrix.device }},OS=${{ matrix.ios }}"
11275
11376
- name: Generate test summary
11477
if: always()
115-
run: |
116-
cd example
117-
if [ -d TestResults.xcresult ]; then
118-
echo "=== Test Summary ==="
119-
xcrun xcresulttool get test-results summary --path TestResults.xcresult || true
120-
echo ""
121-
echo "=== Test Results ==="
122-
xcrun xcresulttool get test-results tests --path TestResults.xcresult || true
123-
echo ""
124-
echo "=== Exporting JSON ==="
125-
# Use the legacy flag as required by newer versions
126-
xcrun xcresulttool get --legacy --path TestResults.xcresult --format json > test-results.json 2>&1 || echo "Failed to export JSON"
127-
if [ -s test-results.json ]; then
128-
echo "Successfully exported test results to JSON ($(wc -c < test-results.json) bytes)"
129-
else
130-
echo "Warning: test-results.json is empty or not created"
131-
fi
132-
else
133-
echo "TestResults.xcresult not found"
134-
fi
78+
run: make test-summary
13579

13680
- name: Upload test summary
13781
if: always()
13882
uses: actions/upload-artifact@v4
13983
with:
14084
name: TestSummary-${{ matrix.xcode }}-${{ matrix.device }}
14185
path: |
142-
example/test-results.json
143-
example/TestResults.xcresult
86+
TestResults.xcresult
87+
if-no-files-found: warn
14488

14589
- name: Export coverage LCOV
14690
if: success()
14791
run: |
148-
cd example
149-
150-
# Get DerivedData path from xcodebuild
151-
DERIVED_DATA=$(xcodebuild -showBuildSettings -project C2PAExample.xcodeproj -scheme C2PAExample -sdk iphonesimulator | grep -m 1 " BUILD_DIR " | sed 's/.*= //' | sed 's|/Build/Products||')
152-
echo "Derived data path: $DERIVED_DATA"
153-
154-
# Find Coverage.profdata - search in common locations
155-
PROFDATA_PATH=$(find ~/Library/Developer/Xcode/DerivedData -path "*/Build/ProfileData/*/Coverage.profdata" -type f 2>/dev/null | grep -i c2paexample | head -1 || true)
156-
157-
echo "Coverage.profdata path: $PROFDATA_PATH"
158-
159-
# Find the test binary
160-
TEST_BINARY_PATH=$(find ~/Library/Developer/Xcode/DerivedData -path "*/C2PAExampleTests.xctest/C2PAExampleTests" -type f 2>/dev/null | grep -i c2paexample | head -1 || true)
161-
162-
echo "Test binary path: $TEST_BINARY_PATH"
163-
164-
# Try to generate LCOV if we have both files
165-
if [ -n "$PROFDATA_PATH" ] && [ -n "$TEST_BINARY_PATH" ]; then
166-
# Export to LCOV format
167-
# Use a sanitized filename to avoid shell issues with special characters
168-
DEVICE_NAME="${{ matrix.device }}"
169-
SANITIZED_DEVICE=$(echo "$DEVICE_NAME" | tr ' ()' '---')
170-
171-
xcrun llvm-cov export \
172-
-format=lcov \
173-
-instr-profile="$PROFDATA_PATH" \
174-
"$TEST_BINARY_PATH" \
175-
> "../coverage-${{ matrix.xcode }}-${SANITIZED_DEVICE}.lcov"
176-
177-
echo "LCOV coverage report generated successfully"
178-
else
179-
echo "ERROR: Could not generate LCOV report - missing profdata or binary"
180-
echo "PROFDATA_PATH: $PROFDATA_PATH"
181-
echo "TEST_BINARY_PATH: $TEST_BINARY_PATH"
182-
exit 1
92+
make coverage-lcov
93+
# Also keep the JSON for better Codecov support
94+
if [ -f "coverage.json" ]; then
95+
echo "Coverage JSON found ($(wc -c < coverage.json) bytes)"
96+
fi
97+
if [ -f "coverage.lcov" ]; then
98+
echo "Coverage LCOV found ($(wc -c < coverage.lcov) bytes)"
99+
# Create a copy with device/xcode info
100+
SANITIZED_DEVICE=$(echo "${{ matrix.device }}" | tr ' ()' '---')
101+
cp coverage.lcov "coverage-${{ matrix.xcode }}-${SANITIZED_DEVICE}.lcov"
183102
fi
184103
185104
- name: Upload coverage report to GitHub
186105
if: success()
187106
uses: actions/upload-artifact@v4
188107
with:
189108
name: coverage-${{ matrix.xcode }}-${{ matrix.device }}
190-
path: coverage-*.lcov
109+
path: |
110+
coverage.lcov
111+
coverage.json
112+
coverage-*.lcov
113+
if-no-files-found: warn
191114

192115
- name: Upload coverage report to Codecov
193116
if: success()
194117
uses: codecov/codecov-action@v5
195118
with:
196119
token: ${{ secrets.CODECOV_TOKEN }}
197120
slug: contentauth/c2pa-ios
121+
files: ./coverage.lcov,./coverage.json
122+
flags: unittests
123+
name: c2pa-ios-${{ matrix.device }}
124+
fail_ci_if_error: false
125+
verbose: true
198126

199127
- name: Stop Signing Server
200128
if: always()
201-
run: |
202-
if [ -f server.pid ]; then
203-
SERVER_PID=$(cat server.pid)
204-
echo "Stopping signing server (PID: $SERVER_PID)..."
205-
kill $SERVER_PID || true
206-
rm server.pid
207-
fi
129+
run: make signing-server-stop || true
208130

209131
- name: Upload Server Logs
210132
if: failure()
211133
uses: actions/upload-artifact@v4
212134
with:
213135
name: server-logs-${{ matrix.xcode }}-${{ matrix.device }}
214-
path: signing-server/.build/debug/*.log
136+
path: signing-server.log

0 commit comments

Comments
 (0)