Skip to content

Commit 407ceeb

Browse files
authored
Merge pull request #510 from ahoppen/pr/swiftsyntax-release-documentation
Add documentation how to create a SwiftSyntax release
2 parents f91b0d4 + d91ea6b commit 407ceeb

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Create SwiftSyntax snapshot release with parser library
2+
3+
## Create release tag
4+
1. Check out the tag you want to release in the SwiftSyntax repository
5+
2. Download the matching Swift release from <https://swift.org> and install it
6+
3. Create an `.xcframework` by running
7+
```bash
8+
xcodebuild -create-xcframework -library /Library/Developer/Toolchains/<toolchain-name>.xctoolchain/usr/lib/swift/macosx/lib_InternalSwiftSyntaxParser.dylib -output _InternalSwiftSyntaxParser.xcframework
9+
```
10+
4. Zip up the framework
11+
```bash
12+
zip -r _InternalSwiftSyntaxParser.xcframework.zip _InternalSwiftSyntaxParser.xcframework
13+
```
14+
5. Compute the checksum for the generated `.xcframework.zip`
15+
```bash
16+
/Library/Developer/Toolchains/<toolchain-name>.xctoolchain/usr/bin/swift package --package-path /path/to/swift-syntax/ compute-checksum _InternalSwiftSyntaxParser.xcframework.zip
17+
```
18+
6. Apply the following diff to `Package.swift`, adjusting `<release tag>` and `<checksum>`
19+
```diff
20+
diff --git a/Package.swift b/Package.swift
21+
index 4c6db83a..7a953fc6 100644
22+
--- a/Package.swift
23+
+++ b/Package.swift
24+
@@ -23,6 +23,21 @@ if ProcessInfo.processInfo.environment["SWIFT_BUILD_SCRIPT_ENVIRONMENT"] != nil
25+
swiftSyntaxSwiftSettings = []
26+
}
27+
28+
+// Include the parser library as a binary dependency if both the host and the target are macOS.
29+
+// - We need to require that the host is macOS (checked by `#if os(macOS)`) because package resolve will download and unzip the referenced framework, which requires `unzip` to be installed. Only macOS guarantees that `unzip` is installed, the Swift Docker images don’t have unzip installed, so package resolve would fail.
30+
+// - We need to require that the target is macOS (checked by `.when`) because binary dependencies are only supported by SwiftPM on macOS.
31+
+#if os(macOS)
32+
+let parserLibraryTarget: [Target] = [.binaryTarget(
33+
+ name: "_InternalSwiftSyntaxParser",
34+
+ url: "https://github.com/apple/swift-syntax/releases/download/<release tag>/_InternalSwiftSyntaxParser.xcframework.zip",
35+
+ checksum: "<checksum>"
36+
+)]
37+
+let parserLibraryDependency: [Target.Dependency] = [.target(name: "_InternalSwiftSyntaxParser", condition: .when(platforms: [.macOS]))]
38+
+#else
39+
+let parserLibraryTarget: [Target] = []
40+
+let parserLibraryDependency: [Target.Dependency] = []
41+
+#endif
42+
+
43+
let package = Package(
44+
name: "SwiftSyntax",
45+
products: [
46+
@@ -65,7 +80,7 @@ let package = Package(
47+
"Tokens.swift.gyb",
48+
]
49+
),
50+
- .target(name: "SwiftSyntaxParser", dependencies: ["SwiftSyntax"], exclude: [
51+
+ .target(name: "SwiftSyntaxParser", dependencies: ["SwiftSyntax"] + parserLibraryDependency, exclude: [
52+
"NodeDeclarationHash.swift.gyb"
53+
]),
54+
.target(
55+
@@ -90,5 +105,5 @@ let package = Package(
56+
dependencies: ["SwiftSyntax", "SwiftSyntaxParser"],
57+
exclude: ["Inputs"]
58+
),
59+
- ]
60+
+ ] + parserLibraryTarget
61+
)
62+
```
63+
7. Commit the changes
64+
8. Create a tag and push it to your personal GitHub repository
65+
9. On your personal GitHub repo create new release, select the tag, name it and upload `_InternalSwiftSyntaxParser.xcframework.zip`
66+
67+
## Smoke test on macOS
68+
69+
1. Change the binary target in `Package.swift` to point to your personal GitHub repo
70+
2. Open the SwiftSyntax package with an Xcode version that contains no or an incompatible parser library
71+
3. Update to Latest Package Versions in Xcode
72+
4. Run tests
73+
74+
## Smoke test on Linux
75+
76+
1. Pull the latest development snapshot docker image for the release, e.g. `docker pull swiftlang/swift:nightly-5.6-focal`
77+
2. Start a development docker image `docker run -it --rm swiftlang/swift:nightly-5.6-focal`
78+
3. `git clone https://github.com/<your github account>/swift-syntax`
79+
4. `cd swift-syntax`
80+
5. `git checkout <release tag>`
81+
6. `swift test`
82+
83+
## Publish Release
84+
85+
1. Push tag to apple/swift-syntax
86+
2. On apple/swift-syntax create a new release using the just-pushed tag and upload the parser library as `_InternalSwiftSyntaxParser.xcframework.zip`
87+
3. If this is a snapshot release, check “This is a pre-release”
88+
4. Publish 🎉
89+
90+
## Integration test
91+
92+
1. Create a new Swift package on macOS that depends on SwiftSyntax and verify that it can parser Swift source into a syntax tree
93+
2. Do the same on Linux

0 commit comments

Comments
 (0)