Skip to content

Commit ef1fb2e

Browse files
authored
Merge pull request #109 from fboemer/fboemer/append-docc-plugin-only-when-needed
2 parents 40c6b00 + a74cf14 commit ef1fb2e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

.github/workflows/scripts/check-docs.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,23 @@ if [ -z "$package_files" ]; then
3131
fatal "Package.swift not found. Please ensure you are running this script from the root of a Swift package."
3232
fi
3333

34-
for package_file in $package_files; do
35-
log "Editing $package_file..."
36-
cat <<EOF >> "$package_file"
34+
# yq 3.1.0-3 doesn't have filter, otherwise we could replace the grep call with "filter(.identity == "swift-docc-plugin") | keys | .[]"
35+
hasDoccPlugin=$(swift package dump-package | yq -r '.dependencies[].sourceControl' | grep -e "\"identity\": \"swift-docc-plugin\"" || true)
36+
if [[ -n $hasDoccPlugin ]]
37+
then
38+
log "swift-docc-plugin already exists"
39+
else
40+
log "Appending swift-docc-plugin"
41+
for package_file in $package_files; do
42+
log "Editing $package_file..."
43+
cat <<EOF >> "$package_file"
3744
3845
package.dependencies.append(
3946
.package(url: "https://github.com/swiftlang/swift-docc-plugin", "1.0.0"..<"1.4.0")
4047
)
4148
EOF
42-
done
49+
done
50+
fi
4351

4452
log "Checking documentation targets..."
4553
for target in $(yq -r '.builder.configs[].documentation_targets[]' .spi.yml); do

0 commit comments

Comments
 (0)