diff --git a/Makefile b/Makefile index 537d3ec7..b98e412a 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,20 @@ PREFIX?=/usr/local -TEMPORARY_FOLDER=./tmp_portable_licenseplist +TEMPORARY_FOLDER=./tmp_licenseplist -build: +VERSION_STRING=$(shell ./Tools/get-version) +LICENSE_PATH="$(shell pwd)/LICENSE" + +ARTIFACT_BUNDLE_PATH=$(TEMPORARY_FOLDER)/LicensePlistBinary.artifactbundle + +clean: + rm -rf "$(TEMPORARY_FOLDER)" + swift package clean + +build: clean swift build --disable-sandbox -c release -build_portable: +build_portable: clean swift build --disable-sandbox -c release --arch x86_64 --arch arm64 test: @@ -14,9 +23,6 @@ test: lint: swiftlint -clean: - swift package clean - xcode: swift package generate-xcodeproj @@ -30,3 +36,10 @@ portable_zip: build_portable cp -f "LICENSE" "$(TEMPORARY_FOLDER)" (cd $(TEMPORARY_FOLDER); zip -r - LICENSE license-plist) > "./portable_licenseplist.zip" rm -r "$(TEMPORARY_FOLDER)" + +spm_artifactbundle_macos: build + mkdir -p "$(ARTIFACT_BUNDLE_PATH)/license-plist-$(VERSION_STRING)-macos/bin" + sed 's/__VERSION__/$(VERSION_STRING)/g' Tools/info-macos.json.template > "$(ARTIFACT_BUNDLE_PATH)/info.json" + cp -f ".build/release/license-plist" "$(ARTIFACT_BUNDLE_PATH)/license-plist-$(VERSION_STRING)-macos/bin" + cp -f "$(LICENSE_PATH)" "$(ARTIFACT_BUNDLE_PATH)" + (cd "$(TEMPORARY_FOLDER)"; zip -yr - "LicensePlistBinary.artifactbundle") > "./LicensePlistBinary-macos.artifactbundle.zip" diff --git a/Package.swift b/Package.swift index 304d353f..79c4933f 100644 --- a/Package.swift +++ b/Package.swift @@ -48,5 +48,10 @@ let package = Package( "XcodeProjects", ] ), + .binaryTarget( + name: "LicensePlistBinary", + url: "https://github.com/mono0926/LicensePlist/releases/download/3.24.1/LicensePlistBinary-macos.artifactbundle.zip", + checksum: "a9609355bc9a72f6e610a96cfaa3e828329564d6eda9b08cfcabc75a90af7275" + ) ] ) diff --git a/Tools/get-version b/Tools/get-version new file mode 100755 index 00000000..6f782e8d --- /dev/null +++ b/Tools/get-version @@ -0,0 +1,5 @@ +#!/bin/bash + +set -euo pipefail + +cat Sources/LicensePlistCore/Consts.swift | grep "version =" | awk -F '"' '{print $2}' | xargs diff --git a/Tools/info-macos.json.template b/Tools/info-macos.json.template new file mode 100644 index 00000000..40c0921e --- /dev/null +++ b/Tools/info-macos.json.template @@ -0,0 +1,15 @@ +{ + "schemaVersion": "1.0", + "artifacts": { + "license-plist": { + "version": "__VERSION__", + "type": "executable", + "variants": [ + { + "path": "license-plist-__VERSION__-macos/bin/license-plist", + "supportedTriples": ["x86_64-apple-macosx", "arm64-apple-macosx"] + } + ] + } + } +} diff --git a/Tools/update-artifact-bundle.sh b/Tools/update-artifact-bundle.sh new file mode 100755 index 00000000..848672f4 --- /dev/null +++ b/Tools/update-artifact-bundle.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -euo pipefail + +readonly version="$1" +readonly artifactbundle="LicensePlistBinary-macos.artifactbundle.zip" +readonly checksum="$(shasum -a 256 "$artifactbundle" | cut -d " " -f1 | xargs)" + +sed -i '' \ + "s/.*\/releases\/download\/.*/ url: \"https:\/\/github.com\/mono0926\/LicensePlist\/releases\/download\/$version\/LicensePlistBinary-macos\.artifactbundle\.zip\",/g" \ + Package.swift + +sed -i '' \ + "s/.*checksum.*/ checksum: \"$checksum\"/g" \ + Package.swift diff --git a/release.sh b/release.sh index 8178d080..ed452dfc 100755 --- a/release.sh +++ b/release.sh @@ -18,6 +18,16 @@ echo "Token: '${token}'" filename="${tag}.tar.gz" echo "Filename: '${filename}'" +# Prepare artifact bundle +binary_artifact="LicensePlistBinary-macos.artifactbundle.zip" +make spm_artifactbundle_macos +./Tools/update-artifact-bundle.sh "${tag}" + +# Push updated binary target definition +git add Package.swift +git commit -m "release ${tag}" +git push origin HEAD + # Push tag git tag $tag git push origin $tag @@ -66,6 +76,16 @@ github-release upload \ rm $lib_name.zip +# Upload artifact bundle +github-release upload \ + --user mono0926 \ + --repo LicensePlist \ + --tag $tag \ + --name $binary_artifact \ + --file $binary_artifact + +rm $binary_artifact + # CocoaPods make portable_zip portable_zip_name="portable_licenseplist.zip"