Skip to content

Commit 6a41e14

Browse files
committed
docs: standardize README and add CI/CD infrastructure
- Add standard badge set (CI + Development Status) - Remove marketing language from Features section - Fix code examples for compilation (ECDSA verification) - Simplify Related Packages with exact GitHub descriptions - Add ReadmeVerificationTests.swift (11 tests, all passing) - Add CI workflows (ci.yml, swift-format.yml, swiftlint.yml) - Add configuration files (.swift-format, dependabot.yml) - Update CI to use macos-26 runners with Xcode 26.0 - Add dual Swift version testing (5.9 + 6.2) - Add Linux (6.2) and Windows (6.2) testing - Add README validation job to CI
1 parent 2e3d0bb commit 6a41e14

File tree

7 files changed

+437
-26
lines changed

7 files changed

+437
-26
lines changed

.github/dependabot.yml

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

.github/workflows/ci.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ci-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
macos-swift59:
15+
name: macOS (Swift 5.9)
16+
runs-on: macos-26
17+
strategy:
18+
matrix:
19+
xcode: ['26.0']
20+
config: ['debug', 'release']
21+
steps:
22+
- uses: actions/checkout@v5
23+
- name: Select Xcode ${{ matrix.xcode }}
24+
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
25+
- name: Print Swift version
26+
run: swift --version
27+
- name: Cache Swift packages
28+
uses: actions/cache@v4
29+
with:
30+
path: .build
31+
key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }}
32+
restore-keys: ${{ runner.os }}-spm-
33+
- name: Build
34+
run: swift build -c ${{ matrix.config }}
35+
- name: Run tests
36+
run: swift test -c ${{ matrix.config }}
37+
38+
macos-swift62:
39+
name: macOS (Swift 6.2)
40+
runs-on: macos-26
41+
strategy:
42+
matrix:
43+
xcode: ['26.0']
44+
config: ['debug', 'release']
45+
steps:
46+
- uses: actions/checkout@v5
47+
- name: Select Xcode ${{ matrix.xcode }}
48+
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
49+
- name: Print Swift version
50+
run: swift --version
51+
- name: Cache Swift packages
52+
uses: actions/cache@v4
53+
with:
54+
path: .build
55+
key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }}
56+
restore-keys: ${{ runner.os }}-spm-
57+
- name: Build
58+
run: swift build -c ${{ matrix.config }}
59+
- name: Run tests
60+
run: swift test -c ${{ matrix.config }}
61+
62+
linux-swift62:
63+
name: Ubuntu (Swift 6.2)
64+
runs-on: ubuntu-latest
65+
container: swift:6.2
66+
steps:
67+
- uses: actions/checkout@v5
68+
- name: Build
69+
run: swift build
70+
- name: Run tests
71+
run: swift test
72+
73+
windows:
74+
name: Windows (Swift 6.2)
75+
runs-on: windows-latest
76+
steps:
77+
- uses: actions/checkout@v5
78+
- uses: SwiftyLab/setup-swift@latest
79+
with:
80+
swift-version: "6.2"
81+
- name: Build
82+
run: swift build
83+
- name: Run tests
84+
run: swift test
85+
86+
readme-validation:
87+
name: README Code Examples
88+
runs-on: macos-26
89+
steps:
90+
- uses: actions/checkout@v5
91+
- name: Select Xcode
92+
run: sudo xcode-select -s /Applications/Xcode_26.0.app
93+
- name: Run README verification tests
94+
run: swift test --filter ReadmeVerificationTests

.github/workflows/swift-format.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Swift Format
2+
on:
3+
push:
4+
branches: [main]
5+
6+
jobs:
7+
format:
8+
runs-on: macos-26
9+
steps:
10+
- uses: actions/checkout@v5
11+
- name: Format code
12+
run: swift-format format --recursive --in-place Sources Tests
13+
- name: Commit changes
14+
uses: stefanzweifel/git-auto-commit-action@v7
15+
with:
16+
commit_message: "Run swift-format"

.github/workflows/swiftlint.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: SwiftLint
2+
on:
3+
pull_request:
4+
branches: [main]
5+
6+
jobs:
7+
lint:
8+
runs-on: macos-26
9+
steps:
10+
- uses: actions/checkout@v5
11+
- name: SwiftLint
12+
run: swiftlint lint
13+
continue-on-error: true

.swift-format

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"version": 1,
3+
"lineLength": 100,
4+
"indentation": {
5+
"spaces": 2
6+
},
7+
"respectsExistingLineBreaks": true,
8+
"lineBreakBeforeControlFlowKeywords": false,
9+
"lineBreakBeforeEachArgument": true
10+
}

README.md

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
# swift-jwt
22

3-
A Swift package for creating, signing, and verifying JSON Web Tokens (JWTs) using Apple's Crypto framework. This package provides a convenient Swift wrapper around RFC 7519 JWT implementation with built-in cryptographic support.
3+
[![CI](https://github.com/coenttb/swift-jwt/workflows/CI/badge.svg)](https://github.com/coenttb/swift-jwt/actions/workflows/ci.yml)
4+
![Development Status](https://img.shields.io/badge/status-active--development-blue.svg)
5+
6+
A Swift package for creating, signing, and verifying JSON Web Tokens (JWTs) using Apple's Crypto framework.
47

58
## Features
69

7-
- **Multiple Signing Algorithms**: HMAC-SHA256/384/512 and ECDSA-SHA256 support
8-
- **Built on Standards**: Uses `swift-rfc-7519` for RFC compliance and `swift-crypto` for cryptography
9-
- **Convenience Methods**: Easy-to-use static methods for common JWT operations
10-
- **Flexible Configuration**: Full control over JWT headers, claims, and timing
11-
- **Type Safety**: Leverages Swift's type system for secure JWT handling
12-
- **Comprehensive Validation**: Signature verification with timing validation
10+
- HMAC-SHA256/384/512 and ECDSA-SHA256 signing algorithms
11+
- RFC 7519 compliant JWT implementation via `swift-rfc-7519`
12+
- Apple Crypto framework integration via `swift-crypto`
13+
- Static methods for HMAC and ECDSA JWT creation
14+
- JWT header, claims, and timing configuration
15+
- Type-safe JWT handling via Swift's type system
16+
- Signature verification with timing validation (exp, nbf, iat)
1317

1418
## Requirements
1519

@@ -92,15 +96,26 @@ let isFullyValid = try jwt.verifyAndValidate(with: verificationKey)
9296

9397
```swift
9498
import JWT
99+
import Crypto
95100

96-
// Create verification key from public key
101+
// Create verification key from signing key
102+
let privateKey = P256.Signing.PrivateKey()
97103
let verificationKey = VerificationKey.ecdsa(from: .ecdsa(privateKey))!
98104

99-
// Or from raw public key data
105+
// Verify the JWT
106+
let isValid = try jwt.verifyAndValidate(with: verificationKey)
107+
```
108+
109+
Alternative - using raw public key data:
110+
111+
```swift
112+
import JWT
113+
import Crypto
114+
115+
let privateKey = P256.Signing.PrivateKey()
100116
let publicKeyData = privateKey.publicKey.rawRepresentation
101117
let verificationKey = try VerificationKey.ecdsa(rawRepresentation: publicKeyData)
102118

103-
// Verify the JWT
104119
let isValid = try jwt.verifyAndValidate(with: verificationKey)
105120
```
106121

@@ -234,23 +249,10 @@ The package includes comprehensive tests covering:
234249
- Edge cases and error conditions
235250
- Key management operations
236251

237-
## Related projects
238-
239-
### The coenttb stack
240-
241-
* [swift-css](https://www.github.com/coenttb/swift-css): A Swift DSL for type-safe CSS.
242-
* [swift-html](https://www.github.com/coenttb/swift-html): A Swift DSL for type-safe HTML & CSS, integrating [swift-css](https://www.github.com/coenttb/swift-css) and [pointfree-html](https://www.github.com/coenttb/pointfree-html).
243-
* [swift-web](https://www.github.com/coenttb/swift-web): Foundational tools for web development in Swift.
244-
* [coenttb-html](https://www.github.com/coenttb/coenttb-html): Builds on [swift-html](https://www.github.com/coenttb/swift-html), and adds functionality for HTML, Markdown, Email, and printing HTML to PDF.
245-
* [coenttb-web](https://www.github.com/coenttb/coenttb-web): Builds on [swift-web](https://www.github.com/coenttb/swift-web), and adds functionality for web development.
246-
* [coenttb-server](https://www.github.com/coenttb/coenttb-server): Build fast, modern, and safe servers that are a joy to write. `coenttb-server` builds on [coenttb-web](https://www.github.com/coenttb/coenttb-web), and adds functionality for server development.
247-
* [coenttb-vapor](https://www.github.com/coenttb/coenttb-server-vapor): `coenttb-server-vapor` builds on [coenttb-server](https://www.github.com/coenttb/coenttb-server), and adds functionality and integrations with Vapor and Fluent.
248-
* [coenttb-com-server](https://www.github.com/coenttb/coenttb-com-server): The backend server for coenttb.com, written entirely in Swift and powered by [coenttb-server-vapor](https://www.github.com/coenttb-server-vapor).
252+
## Related Packages
249253

250-
### PointFree foundations
251-
* [coenttb/pointfree-html](https://www.github.com/coenttb/pointfree-html): A Swift DSL for type-safe HTML, forked from [pointfreeco/swift-html](https://www.github.com/pointfreeco/swift-html) and updated to the version on [pointfreeco/pointfreeco](https://github.com/pointfreeco/pointfreeco).
252-
* [coenttb/pointfree-web](https://www.github.com/coenttb/pointfree-html): Foundational tools for web development in Swift, forked from [pointfreeco/swift-web](https://www.github.com/pointfreeco/swift-web).
253-
* [coenttb/pointfree-server](https://www.github.com/coenttb/pointfree-html): Foundational tools for server development in Swift, forked from [pointfreeco/swift-web](https://www.github.com/pointfreeco/swift-web).
254+
* [swift-html](https://www.github.com/coenttb/swift-html): The Swift library for domain-accurate and type-safe HTML & CSS.
255+
* [swift-web](https://www.github.com/coenttb/swift-web): A Swift package with tools to simplify web development.
254256

255257
## Feedback is Much Appreciated!
256258

0 commit comments

Comments
 (0)