Skip to content

Commit 7c03722

Browse files
Merge pull request #14 from SwiftPackageIndex/swift-5.8
Add support for Swift 5.8
2 parents b81db33 + 260f17e commit 7c03722

File tree

4 files changed

+99
-43
lines changed

4 files changed

+99
-43
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,55 +17,45 @@ name: CI
1717
on:
1818
push:
1919
branches: [ '*' ]
20-
pull_request: [ main ]
20+
pull_request:
21+
branches: [ main ]
2122

2223
jobs:
23-
build:
24+
macos:
2425
strategy:
2526
fail-fast: false
2627
matrix:
2728
# https://github.com/actions/virtual-environments
28-
os: [macos-12, macos-11, ubuntu-20.04]
29-
29+
os: [macos-13, macos-12, macos-11]
3030
runs-on: ${{ matrix.os }}
31-
env:
32-
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app/Contents/Developer
33-
3431
steps:
3532
- uses: actions/checkout@v2
36-
- name: Release Build
33+
- name: Test
34+
run: make test
35+
- name: Build for release
3736
run: make build
37+
- name: Install
38+
run: env prefix=/tmp make install
39+
- name: Uninstall
40+
run: env prefix=/tmp make uninstall
3841

39-
test:
42+
linux:
4043
strategy:
4144
fail-fast: false
4245
matrix:
43-
# https://github.com/actions/virtual-environments
44-
os: [macos-12, macos-11, ubuntu-20.04]
45-
46-
runs-on: ${{ matrix.os }}
47-
env:
48-
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app/Contents/Developer
49-
46+
image: ['swift:5.7-focal', 'swift:5.8-focal']
47+
runs-on: ubuntu-latest
48+
container:
49+
image: ${{ matrix.image }}
5050
steps:
5151
- uses: actions/checkout@v2
52+
- run: apt-get -y update && apt-get install make
5253
- name: Test
5354
run: make test
54-
55-
install:
56-
strategy:
57-
fail-fast: false
58-
matrix:
59-
# https://github.com/actions/virtual-environments
60-
os: [macos-12, macos-11, ubuntu-20.04]
61-
62-
runs-on: ${{ matrix.os }}
63-
env:
64-
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app/Contents/Developer
65-
66-
steps:
67-
- uses: actions/checkout@v2
55+
- name: Build for release
56+
run: make build
6857
- name: Install
6958
run: env prefix=/tmp make install
7059
- name: Uninstall
7160
run: env prefix=/tmp make uninstall
61+

Package.resolved

Lines changed: 24 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ let package = Package(
2828
.package(url: "https://github.com/SwiftPackageIndex/SemanticVersion",
2929
from: "0.3.1"),
3030
.package(url: "https://github.com/apple/swift-argument-parser",
31-
from: "1.0.0"),
32-
.package(url: "https://github.com/pointfreeco/swift-parsing",
33-
from: "0.4.1"),
31+
from: "1.0.0")
3432
],
3533
targets: [
3634
.executableTarget(
@@ -47,7 +45,18 @@ let package = Package(
4745
),
4846
.testTarget(
4947
name: "ReleaseNotesTests",
50-
dependencies: ["ReleaseNotesCore"]
48+
dependencies: ["ReleaseNotesCore"],
49+
exclude: ["Fixtures"]
5150
),
5251
]
5352
)
53+
54+
#if compiler(<5.8)
55+
package.dependencies.append(
56+
.package(url: "https://github.com/pointfreeco/swift-parsing", revision: "0.11.0")
57+
)
58+
#else
59+
package.dependencies.append(
60+
.package(url: "https://github.com/pointfreeco/swift-parsing", from: "0.12.0")
61+
)
62+
#endif

Sources/ReleaseNotesCore/Parser.swift

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,17 @@ import SemanticVersion
1818

1919
enum Parser {
2020

21+
#if compiler(<5.8)
2122
static let dependencyStart = Parse {
2223
Int.parser()
2324
Skip { " dependenc" }
2425
}
26+
#else
27+
static let dependencyStart = Parse(input: Substring.self) {
28+
Int.parser()
29+
Skip { " dependenc" }
30+
}
31+
#endif
2532

2633
static let progressLine = Parse {
2734
Not { dependencyStart }
@@ -30,6 +37,7 @@ enum Parser {
3037

3138
static let progress = Many { progressLine }
3239

40+
#if compiler(<5.8)
3341
static let dependencyCount = Parse {
3442
Int.parser()
3543
Skip {
@@ -40,11 +48,23 @@ enum Parser {
4048
}
4149
}
4250
}
51+
#else
52+
static let dependencyCount = Parse(input: Substring.self) {
53+
Int.parser()
54+
Skip {
55+
OneOf {
56+
" dependency has changed:"
57+
" dependencies have changed:"
58+
" dependencies have changed."
59+
}
60+
}
61+
}
62+
#endif
4363

4464
static let semanticVersion = Parse(Revision.tag) {
4565
Prefix { $0 != " " }
46-
.map { (s: Substring) -> String in return String.init(s) }
47-
.compactMap(SemanticVersion.init)
66+
.map { (s: Substring) -> String in return String.init(s) }
67+
.compactMap(SemanticVersion.init)
4868
}
4969

5070
static let revision = OneOf {
@@ -56,10 +76,15 @@ enum Parser {
5676

5777
static let newPackageToken: Character = "+"
5878
static let updatedRevisionToken: Character = "~"
79+
#if compiler(<5.8)
5980
static let upToStart = Parse {
6081
Prefix { $0 != newPackageToken && $0 != updatedRevisionToken }
6182
}
62-
83+
#else
84+
static let upToStart = Parse(input: Substring.self) {
85+
Prefix { $0 != newPackageToken && $0 != updatedRevisionToken }
86+
}
87+
#endif
6388
static let newPackage = Parse { Update(packageId: $0, oldRevision: nil) } with: {
6489
Skip {
6590
upToStart
@@ -92,6 +117,7 @@ enum Parser {
92117

93118
static let updates = Many(element: { update }, separator: { "\n" })
94119

120+
#if compiler(<5.8)
95121
static let packageUpdate = Parse { (count, updates) -> [Update] in
96122
assert(updates.count == count)
97123
return updates
@@ -102,4 +128,17 @@ enum Parser {
102128
updates
103129
Skip { Many { "\n" } }
104130
}
131+
#else
132+
static let packageUpdate = Parse {
133+
Skip { progress }
134+
Skip { Many { "\n" } }
135+
dependencyCount
136+
updates
137+
Skip { Many { "\n" } }
138+
}.map { (count: Int, updates: [Update]) in
139+
assert(updates.count == count)
140+
return updates
141+
}
142+
#endif
143+
105144
}

0 commit comments

Comments
 (0)