Skip to content

Commit d3acce4

Browse files
committed
ci: add complete CI/CD workflows and Dependabot
- Add release.yml for automated releases with validation - Add swift-format.yml for auto-formatting on main (Point-Free style) - Add swiftlint.yml for code quality checks on PRs - Add dependabot.yml for automated dependency updates
1 parent a501f4c commit d3acce4

File tree

4 files changed

+221
-0
lines changed

4 files changed

+221
-0
lines changed

.github/dependabot.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for Swift Package Manager
4+
- package-ecosystem: "swift"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
time: "09:00"
10+
timezone: "America/New_York"
11+
open-pull-requests-limit: 5
12+
reviewers:
13+
- "coenttb"
14+
labels:
15+
- "dependencies"
16+
- "swift"
17+
commit-message:
18+
prefix: "deps"
19+
include: "scope"
20+
21+
# Enable version updates for GitHub Actions
22+
- package-ecosystem: "github-actions"
23+
directory: "/"
24+
schedule:
25+
interval: "monthly"
26+
day: "monday"
27+
time: "09:00"
28+
timezone: "America/New_York"
29+
open-pull-requests-limit: 3
30+
reviewers:
31+
- "coenttb"
32+
labels:
33+
- "dependencies"
34+
- "github-actions"
35+
commit-message:
36+
prefix: "ci"
37+
include: "scope"

.github/workflows/release.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Tag to release'
10+
required: true
11+
type: string
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
validate:
18+
name: Validate Release
19+
runs-on: macos-15
20+
steps:
21+
- uses: actions/checkout@v5
22+
23+
- name: Select Xcode
24+
run: sudo xcode-select -s /Applications/Xcode_16.0.app
25+
26+
- name: Validate tag format
27+
run: |
28+
TAG="${{ github.event.release.tag_name || github.event.inputs.tag }}"
29+
if [[ ! "$TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
30+
echo "❌ Invalid tag format: $TAG"
31+
echo "Tag must follow semantic versioning (e.g., 0.1.0)"
32+
exit 1
33+
fi
34+
echo "✅ Valid tag format: $TAG"
35+
36+
- name: Build in release mode
37+
run: swift build -c release
38+
39+
- name: Run all tests
40+
run: swift test -c release
41+
42+
- name: Run README verification tests
43+
run: swift test -c release --filter ReadmeVerificationTests
44+
45+
create-release-artifacts:
46+
name: Create Release Artifacts
47+
needs: validate
48+
runs-on: macos-15
49+
steps:
50+
- uses: actions/checkout@v5
51+
52+
- name: Select Xcode
53+
run: sudo xcode-select -s /Applications/Xcode_16.0.app
54+
55+
- name: Build library archives
56+
run: |
57+
swift build -c release --arch arm64
58+
swift build -c release --arch x86_64
59+
cd .build
60+
tar -czf swift-css-types-macos.tar.gz \
61+
arm64-apple-macosx/release/*.swiftmodule \
62+
x86_64-apple-macosx/release/*.swiftmodule \
63+
2>/dev/null || true
64+
echo "✅ Created library archives"
65+
66+
- name: Generate documentation
67+
run: |
68+
swift package \
69+
--allow-writing-to-directory ./docs \
70+
generate-documentation \
71+
--target CSSTypes \
72+
--output-path ./docs \
73+
--transform-for-static-hosting \
74+
--hosting-base-path swift-css-types
75+
zip -r documentation.zip docs/
76+
continue-on-error: true
77+
78+
- name: Upload artifacts to release
79+
if: github.event_name == 'release'
80+
uses: softprops/action-gh-release@v2
81+
with:
82+
files: |
83+
.build/swift-css-types-macos.tar.gz
84+
documentation.zip
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/swift-format.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Format
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: format-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
swift_format:
14+
name: swift-format
15+
runs-on: macos-15
16+
permissions:
17+
contents: write
18+
steps:
19+
- uses: actions/checkout@v5
20+
21+
- name: Select Xcode
22+
run: sudo xcode-select -s /Applications/Xcode_16.0.app
23+
24+
- name: Cache swift-format
25+
id: cache-swift-format
26+
uses: actions/cache@v4
27+
with:
28+
path: /usr/local/bin/swift-format
29+
key: ${{ runner.os }}-swift-format-${{ hashFiles('.github/workflows/swift-format.yml') }}
30+
31+
- name: Install swift-format
32+
if: steps.cache-swift-format.outputs.cache-hit != 'true'
33+
run: |
34+
git clone --depth 1 --branch main https://github.com/apple/swift-format.git
35+
cd swift-format
36+
swift build -c release
37+
sudo cp .build/release/swift-format /usr/local/bin/
38+
cd ..
39+
rm -rf swift-format
40+
41+
- name: Format
42+
run: swift-format format --recursive --in-place Sources Tests
43+
44+
- uses: stefanzweifel/git-auto-commit-action@v5
45+
with:
46+
commit_message: Run swift-format
47+
branch: 'main'

.github/workflows/swiftlint.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: SwiftLint
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**.swift'
7+
workflow_dispatch:
8+
9+
jobs:
10+
swiftlint:
11+
name: Check Code Quality
12+
runs-on: macos-15
13+
steps:
14+
- uses: actions/checkout@v5
15+
16+
- name: Cache SwiftLint
17+
id: cache-swiftlint
18+
uses: actions/cache@v4
19+
with:
20+
path: /usr/local/bin/swiftlint
21+
key: ${{ runner.os }}-swiftlint-0.57.0
22+
23+
- name: Install SwiftLint
24+
if: steps.cache-swiftlint.outputs.cache-hit != 'true'
25+
run: |
26+
brew install swiftlint
27+
28+
- name: Verify SwiftLint installation
29+
run: |
30+
if ! command -v swiftlint &> /dev/null; then
31+
echo "❌ SwiftLint installation failed"
32+
exit 1
33+
fi
34+
swiftlint version
35+
36+
- name: Run SwiftLint
37+
run: |
38+
echo "Checking Swift code quality..."
39+
swiftlint lint --reporter github-actions-logging
40+
41+
- name: Provide fix instructions on failure
42+
if: failure()
43+
run: |
44+
echo ""
45+
echo "⚠️ SwiftLint violations found. These are warnings only."
46+
echo ""
47+
echo "To see violations locally, run:"
48+
echo " swiftlint lint"
49+
echo ""
50+
echo "To auto-fix some violations:"
51+
echo " swiftlint --fix"

0 commit comments

Comments
 (0)