Skip to content

Commit 60671f4

Browse files
authored
Simplify structure of artifact bundle (#6239)
1 parent dcbdcc9 commit 60671f4

File tree

5 files changed

+29
-32
lines changed

5 files changed

+29
-32
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,18 @@
44

55
### Breaking
66

7-
* None.
7+
* The structure of `SwiftLintBinary.artifactbundle.zip` is now simpler. Internal paths no
8+
longer contain version numbers, especially. So in an Xcode Run Script build phase,
9+
you can refer to the `swiftlint` binary like this:
10+
11+
```bash
12+
SWIFT_PACKAGE_DIR="${BUILD_DIR%Build/*}SourcePackages/artifacts"
13+
SWIFTLINT_CMD="$SWIFT_PACKAGE_DIR/swiftlintplugins/SwiftLintBinary/SwiftLintBinary.artifactbundle/macos/swiftlint"
14+
```
15+
16+
All other consumers of the artifact bundle do not need to change anything. Swift Package
17+
Manager resolves the new paths automatically.
18+
[SimplyDanny](https://github.com/SimplyDanny)
819

920
### Experimental
1021

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,11 @@ portable_zip: installables
107107
(cd "$(TEMPORARY_FOLDER)"; zip -yr - "swiftlint" "LICENSE") > "./portable_swiftlint.zip"
108108

109109
spm_artifactbundle: swiftlint swiftlint_linux_amd64 swiftlint_linux_arm64
110-
mkdir -p "$(ARTIFACT_BUNDLE_PATH)/swiftlint-$(VERSION_STRING)-macos/bin"
111-
mkdir -p "$(ARTIFACT_BUNDLE_PATH)/swiftlint-$(VERSION_STRING)-linux-gnu/bin"
110+
mkdir -p "$(ARTIFACT_BUNDLE_PATH)/macos" "$(ARTIFACT_BUNDLE_PATH)/linux/{amd,arm}64"
112111
sed 's/__VERSION__/$(VERSION_STRING)/g' tools/info.json.template > "$(ARTIFACT_BUNDLE_PATH)/info.json"
113-
cp -f swiftlint "$(ARTIFACT_BUNDLE_PATH)/swiftlint-$(VERSION_STRING)-macos/bin/swiftlint"
114-
cp -f swiftlint_linux_amd64 "$(ARTIFACT_BUNDLE_PATH)/swiftlint-$(VERSION_STRING)-linux-gnu/bin/swiftlint_amd64"
115-
cp -f swiftlint_linux_arm64 "$(ARTIFACT_BUNDLE_PATH)/swiftlint-$(VERSION_STRING)-linux-gnu/bin/swiftlint_arm64"
112+
cp -f swiftlint "$(ARTIFACT_BUNDLE_PATH)/macos/swiftlint"
113+
cp -f swiftlint_linux_amd64 "$(ARTIFACT_BUNDLE_PATH)/linux/amd64/swiftlint"
114+
cp -f swiftlint_linux_arm64 "$(ARTIFACT_BUNDLE_PATH)/linux/arm64/swiftlint"
116115
cp -f LICENSE "$(ARTIFACT_BUNDLE_PATH)"
117116
(cd "$(TEMPORARY_FOLDER)"; zip -yr - "SwiftLintBinary.artifactbundle") > "./SwiftLintBinary.artifactbundle.zip"
118117

Package.swift

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ let swiftFeatures: [SwiftSetting] = [
1414
let strictConcurrency = [SwiftSetting.enableExperimentalFeature("StrictConcurrency=complete")]
1515
let targetedConcurrency = [SwiftSetting.enableExperimentalFeature("StrictConcurrency=targeted")]
1616

17-
let swiftLintPluginDependencies: [Target.Dependency]
18-
19-
#if os(macOS)
20-
swiftLintPluginDependencies = [.target(name: "SwiftLintBinary")]
21-
#else
22-
swiftLintPluginDependencies = [.target(name: "swiftlint")]
23-
#endif
24-
2517
let package = Package(
2618
name: "SwiftLint",
2719
platforms: [.macOS(.v13)],
@@ -72,7 +64,7 @@ let package = Package(
7264
.plugin(
7365
name: "SwiftLintBuildToolPlugin",
7466
capability: .buildTool(),
75-
dependencies: swiftLintPluginDependencies,
67+
dependencies: [.target(name: "SwiftLintBinary")],
7668
packageAccess: false
7769
),
7870
.plugin(
@@ -85,7 +77,7 @@ let package = Package(
8577
),
8678
]
8779
),
88-
dependencies: swiftLintPluginDependencies,
80+
dependencies: [.target(name: "SwiftLintBinary")],
8981
packageAccess: false
9082
),
9183
.target(
@@ -212,15 +204,10 @@ let package = Package(
212204
path: "Tests/TestHelpers",
213205
swiftSettings: swiftFeatures + strictConcurrency
214206
),
207+
.binaryTarget(
208+
name: "SwiftLintBinary",
209+
url: "https://github.com/realm/SwiftLint/releases/download/0.61.0/SwiftLintBinary.artifactbundle.zip",
210+
checksum: "b765105fa5c5083fbcd35260f037b9f0d70e33992d0a41ba26f5f78a17dc65e7"
211+
),
215212
]
216213
)
217-
218-
#if os(macOS)
219-
package.targets.append(
220-
.binaryTarget(
221-
name: "SwiftLintBinary",
222-
url: "https://github.com/realm/SwiftLint/releases/download/0.61.0/SwiftLintBinary.artifactbundle.zip",
223-
checksum: "b765105fa5c5083fbcd35260f037b9f0d70e33992d0a41ba26f5f78a17dc65e7"
224-
)
225-
)
226-
#endif

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,13 @@ following way:
339339

340340
```bash
341341
SWIFT_PACKAGE_DIR="${BUILD_DIR%Build/*}SourcePackages/artifacts"
342-
SWIFTLINT_CMD=$(ls "$SWIFT_PACKAGE_DIR"/swiftlintplugins/SwiftLintBinary/SwiftLintBinary.artifactbundle/swiftlint-*-macos/bin/swiftlint | head -n 1)
342+
SWIFTLINT_CMD="$SWIFT_PACKAGE_DIR/swiftlintplugins/SwiftLintBinary/SwiftLintBinary.artifactbundle/macos/swiftlint"
343343

344344
if test -f "$SWIFTLINT_CMD" 2>&1
345345
then
346346
"$SWIFTLINT_CMD"
347347
else
348-
echo "warning: `swiftlint` command not found - See https://github.com/realm/SwiftLint#installation for installation instructions."
348+
echo "warning: `swiftlint` command not found - See https://github.com/realm/SwiftLint#xcode-run-script-build-phase for installation instructions."
349349
fi
350350
```
351351

tools/info.json.template

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
"type": "executable",
77
"variants": [
88
{
9-
"path": "swiftlint-__VERSION__-macos/bin/swiftlint",
9+
"path": "macos/swiftlint",
1010
"supportedTriples": ["x86_64-apple-macosx", "arm64-apple-macosx"]
1111
},
1212
{
13-
"path": "swiftlint-__VERSION__-linux-gnu/bin/swiftlint_amd64",
14-
"supportedTriples": ["x86_64-unknown-linux-gnu"]
13+
"path": "linux/amd64/swiftlint",
14+
"supportedTriples": ["x86_64-unknown-linux-gnu", "amd64-unknown-linux-gnu"]
1515
},
1616
{
17-
"path": "swiftlint-__VERSION__-linux-gnu/bin/swiftlint_arm64",
17+
"path": "linux/arm64/swiftlint",
1818
"supportedTriples": ["aarch64-unknown-linux-gnu", "arm64-unknown-linux-gnu"]
1919
}
2020
]

0 commit comments

Comments
 (0)