Skip to content

Commit ef7b4aa

Browse files
Fix readme and try gh runner
1 parent 2ccc66b commit ef7b4aa

File tree

4 files changed

+467
-122
lines changed

4 files changed

+467
-122
lines changed

.github/README.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# GitHub Actions Workflows
2+
3+
This repository includes two GitHub Actions workflows for continuous integration and release management:
4+
5+
## CI Workflow (`.github/workflows/ci.yml`)
6+
7+
Runs on every push and pull request to `main` and `develop` branches.
8+
9+
### Features:
10+
- **Multi-Xcode Testing**: Tests against multiple Xcode versions (15.0, 15.1)
11+
- **Platform Compatibility**: Builds and tests on macOS, iOS, watchOS, and tvOS
12+
- **Code Coverage**: Generates and uploads coverage reports to Codecov
13+
- **Package Validation**: Validates Package.swift structure and dependencies
14+
- **Documentation Check**: Verifies documentation exists and can be generated
15+
- **Swift Linting**: Basic syntax validation for all Swift files
16+
17+
### Triggered by:
18+
- Push to `main` or `develop` branches
19+
- Pull requests to `main` or `develop` branches
20+
- Manual workflow dispatch
21+
22+
## Release Workflow (`.github/workflows/release.yml`)
23+
24+
Builds and packages the Swift package for GitHub releases.
25+
26+
### Features:
27+
- **Automated Testing**: Runs full test suite before release
28+
- **Multi-Platform Building**: Tests on macOS, iOS, watchOS, and tvOS
29+
- **Package Creation**: Creates `.tar.gz` and `.zip` archives of the package
30+
- **Documentation Generation**: Generates Swift-DocC documentation (if available)
31+
- **GitHub Release**: Automatically creates GitHub release with artifacts
32+
- **Release Notes**: Auto-generates release notes with installation instructions
33+
34+
### Triggered by:
35+
- Git tags starting with `v` (e.g., `v1.0.0`, `v2.1.3`)
36+
- Pull requests (for testing)
37+
- Manual workflow dispatch
38+
39+
## Creating a Release
40+
41+
To create a new release:
42+
43+
1. **Tag your commit**:
44+
```bash
45+
git tag v1.0.0
46+
git push origin v1.0.0
47+
```
48+
49+
2. **The workflow will automatically**:
50+
- Run all tests
51+
- Build the package for all platforms
52+
- Create package archives
53+
- Generate documentation
54+
- Create a GitHub release with artifacts
55+
56+
## Release Artifacts
57+
58+
Each release includes:
59+
60+
- **`TintedThemingSwift-vX.X.X.tar.gz`** - Complete package source (tar.gz format)
61+
- **`TintedThemingSwift-vX.X.X.zip`** - Complete package source (zip format)
62+
- **`TintedThemingSwift-Documentation-vX.X.X.tar.gz`** - Generated Swift-DocC documentation (if available)
63+
- **`PACKAGE_INFO.md`** - Package information and installation instructions
64+
65+
## Package Contents
66+
67+
Each package archive contains:
68+
- `Sources/` - All Swift source files
69+
- `Package.swift` - Swift Package Manager manifest
70+
- `README.md` - Project documentation
71+
- `LICENSE` - License file (if present)
72+
- `PACKAGE_INFO.md` - Version and installation information
73+
74+
## Installation from Release
75+
76+
Users can install the package by adding it to their `Package.swift`:
77+
78+
```swift
79+
.package(url: "https://github.com/aspauldingcode/TintedThemingSwift.git", from: "1.0.0")
80+
```
81+
82+
Or by downloading and extracting the release archives for manual integration.
83+
84+
## Workflow Requirements
85+
86+
- **macOS runner**: Required for Xcode and Swift Package Manager
87+
- **Xcode 15.0+**: For building and testing
88+
- **GitHub token**: Automatically provided by GitHub Actions
89+
- **Codecov token**: Optional, for code coverage reporting
90+
91+
## Customization
92+
93+
To customize the workflows:
94+
95+
1. **Update Xcode versions**: Modify the `matrix.xcode` values in both workflows
96+
2. **Change platforms**: Update the `matrix.destination` values
97+
3. **Modify release content**: Edit the release body template in `release.yml`
98+
4. **Add additional checks**: Extend the validation steps in `ci.yml`
99+
100+
Both workflows are designed to be robust and provide comprehensive testing and packaging for the TintedThemingSwift package.

.github/workflows/ci.yml

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
swift-test:
12+
name: Swift Tests
13+
runs-on: macos-latest
14+
strategy:
15+
matrix:
16+
xcode: ['15.1', '15.0']
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Select Xcode
23+
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
24+
25+
- name: Show Xcode and Swift versions
26+
run: |
27+
xcodebuild -version
28+
swift --version
29+
30+
- name: Cache Swift Package Manager
31+
uses: actions/cache@v3
32+
with:
33+
path: .build
34+
key: ${{ runner.os }}-spm-${{ matrix.xcode }}-${{ hashFiles('**/Package.resolved') }}
35+
restore-keys: |
36+
${{ runner.os }}-spm-${{ matrix.xcode }}-
37+
${{ runner.os }}-spm-
38+
39+
- name: Build Package
40+
run: swift build
41+
42+
- name: Run Tests
43+
run: swift test --enable-code-coverage
44+
45+
- name: Generate Code Coverage
46+
run: |
47+
xcrun llvm-cov export -format="lcov" \
48+
.build/debug/TintedThemingSwiftPackageTests.xctest/Contents/MacOS/TintedThemingSwiftPackageTests \
49+
-instr-profile .build/debug/codecov/default.profdata > coverage.lcov
50+
continue-on-error: true
51+
52+
- name: Upload Coverage to Codecov
53+
uses: codecov/codecov-action@v3
54+
with:
55+
file: ./coverage.lcov
56+
flags: swift
57+
name: codecov-swift-${{ matrix.xcode }}
58+
continue-on-error: true
59+
60+
platform-compatibility:
61+
name: Platform Compatibility
62+
runs-on: macos-latest
63+
strategy:
64+
matrix:
65+
destination:
66+
- 'platform=macOS'
67+
- 'platform=iOS Simulator,name=iPhone 15'
68+
- 'platform=iOS Simulator,name=iPhone 14'
69+
- 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm)'
70+
- 'platform=tvOS Simulator,name=Apple TV'
71+
72+
steps:
73+
- name: Checkout
74+
uses: actions/checkout@v4
75+
76+
- name: Select Xcode
77+
run: sudo xcode-select -s /Applications/Xcode_15.1.app/Contents/Developer
78+
79+
- name: Cache Swift Package Manager
80+
uses: actions/cache@v3
81+
with:
82+
path: .build
83+
key: ${{ runner.os }}-spm-platform-${{ hashFiles('**/Package.resolved') }}
84+
restore-keys: |
85+
${{ runner.os }}-spm-platform-
86+
${{ runner.os }}-spm-
87+
88+
- name: Build for Platform
89+
run: |
90+
if [[ "${{ matrix.destination }}" == "platform=macOS" ]]; then
91+
swift build
92+
else
93+
xcodebuild build \
94+
-scheme TintedThemingSwift \
95+
-destination '${{ matrix.destination }}'
96+
fi
97+
98+
- name: Test for Platform
99+
run: |
100+
if [[ "${{ matrix.destination }}" == "platform=macOS" ]]; then
101+
swift test
102+
else
103+
xcodebuild test \
104+
-scheme TintedThemingSwift \
105+
-destination '${{ matrix.destination }}'
106+
fi
107+
108+
package-validation:
109+
name: Package Validation
110+
runs-on: macos-latest
111+
112+
steps:
113+
- name: Checkout
114+
uses: actions/checkout@v4
115+
116+
- name: Validate Package Structure
117+
run: |
118+
swift package dump-package
119+
swift package show-dependencies
120+
swift package resolve
121+
122+
- name: Check Package Manifest
123+
run: |
124+
# Verify Package.swift is valid
125+
swift package describe --type json > package_info.json
126+
cat package_info.json
127+
128+
# Check for required fields
129+
if ! grep -q '"name"' package_info.json; then
130+
echo "Error: Package name not found"
131+
exit 1
132+
fi
133+
134+
if ! grep -q '"TintedThemingSwift"' package_info.json; then
135+
echo "Error: Expected package name 'TintedThemingSwift' not found"
136+
exit 1
137+
fi
138+
139+
- name: Lint Swift Code
140+
run: |
141+
# Basic Swift syntax check
142+
find Sources -name "*.swift" -exec swift -frontend -parse {} \;
143+
echo "Swift syntax check passed"
144+
145+
documentation:
146+
name: Documentation Check
147+
runs-on: macos-latest
148+
149+
steps:
150+
- name: Checkout
151+
uses: actions/checkout@v4
152+
153+
- name: Check Documentation
154+
run: |
155+
# Check if README exists and has content
156+
if [[ ! -f README.md ]]; then
157+
echo "Warning: README.md not found"
158+
else
159+
echo "README.md found ($(wc -l < README.md) lines)"
160+
fi
161+
162+
# Check if wiki documentation exists
163+
if [[ -f wiki.adoc ]]; then
164+
echo "Wiki documentation found ($(wc -l < wiki.adoc) lines)"
165+
fi
166+
167+
# Check for inline documentation in Swift files
168+
doc_count=$(find Sources -name "*.swift" -exec grep -l "///" {} \; | wc -l)
169+
echo "Swift files with documentation comments: $doc_count"
170+
171+
- name: Generate Documentation (if available)
172+
run: |
173+
if command -v swift-docc &> /dev/null; then
174+
echo "Generating documentation with Swift-DocC..."
175+
swift package generate-documentation --target TintedThemingSwift
176+
echo "Documentation generated successfully"
177+
else
178+
echo "Swift-DocC not available, skipping documentation generation"
179+
fi
180+
continue-on-error: true

0 commit comments

Comments
 (0)