Create script to create SPM artifact bundle (#1215)

This commit is contained in:
Andrew Lord
2022-07-12 07:49:41 +01:00
committed by Nick Lockwood
parent 378543f07b
commit c58df8066d
3 changed files with 52 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
set -e
REGEX="let swiftFormatVersion = \"([0-9]+.[0-9]+.[0-9]+)\""
while IFS= read -r line; do
if [[ $line =~ $REGEX ]]
then
echo "${BASH_REMATCH[1]}"
break
fi
done < Sources/SwiftFormat.swift
+25
View File
@@ -0,0 +1,25 @@
#!/bin/sh
set -e
ARTIFACT_BUNDLE=swiftformat.artifactbundle
INFO_TEMPLATE=Scripts/spm-macos-artifact-bundle-info.template
VERSION=$(./Scripts/get-version.sh)
BINARY_OUTPUT_DIR=$ARTIFACT_BUNDLE/swiftformat-$VERSION-macos/bin
mkdir $ARTIFACT_BUNDLE
# Copy license into bundle
cp LICENSE.md $ARTIFACT_BUNDLE
# Create bundle info.json from template, replacing version
sed 's/__VERSION__/'"${VERSION}"'/g' $INFO_TEMPLATE > "${ARTIFACT_BUNDLE}/info.json"
# Copy MacOS SwiftFormat binary into bundle
mkdir -p $BINARY_OUTPUT_DIR
cp CommandLineTool/swiftformat $BINARY_OUTPUT_DIR
# Create ZIP
zip -yr - $ARTIFACT_BUNDLE > "${ARTIFACT_BUNDLE}.zip"
rm -rf $ARTIFACT_BUNDLE
@@ -0,0 +1,15 @@
{
"schemaVersion": "1.0",
"artifacts": {
"swiftformat": {
"version": "__VERSION__",
"type": "executable",
"variants": [
{
"path": "swiftformat-__VERSION__-macos/bin/swiftformat",
"supportedTriples": ["x86_64-apple-macosx", "arm64-apple-macosx"]
}
]
}
}
}