new: add sha256 to github action for ios

This commit is contained in:
Hiddify
2024-01-16 16:52:42 +00:00
parent 7b2bf9503c
commit e6fe03c190
3 changed files with 52 additions and 25 deletions

View File

@@ -83,7 +83,11 @@ jobs:
else
gzip -r -S ".gz" ./bin/hiddify-libcore*
fi
- name: Calculate SHA256 Checksum
if: startsWith(matrix.job.target,'ios')
run: |
sha256sum hiddify-libcore-ios.xcframework.zip > hiddify-libcore-ios.xcframework.zip.sha256
working-directory: bin
- uses: actions/upload-artifact@v3
if: ${{ success() }}
with:

View File

@@ -28,7 +28,7 @@ ios-full: lib_install
ios: lib_install
gomobile bind -v -target ios -libname=box -tags=$(TAGS),with_dhcp,with_low_memory,with_conntrack -trimpath -ldflags="-w -s" -o $(BINDIR)/$(PRODUCT_NAME).xcframework github.com/sagernet/sing-box/experimental/libbox ./mobile &&\
mv $(BINDIR)/$(PRODUCT_NAME).xcframework $(BINDIR)/$(NAME).xcframework &&\
cp Libcore.podspec $(BINDIR)/$(NAME).xcframework/
# cp Libcore.podspec $(BINDIR)/$(NAME).xcframework/
cp Info.plist $(BINDIR)/$(NAME).xcframework/
@@ -61,12 +61,14 @@ release: # Create a new tag for release.
VERSION_STR="$${VERSION_ARRAY[0]}.$${VERSION_ARRAY[1]}.$${VERSION_ARRAY[2]}" && \
BUILD_NUMBER=$$(( $${VERSION_ARRAY[0]} * 10000 + $${VERSION_ARRAY[1]} * 100 + $${VERSION_ARRAY[2]} )) && \
echo "version: $${VERSION_STR}+$${BUILD_NUMBER}" && \
sed -i "s/^s.version: .*/s.version = '$${VERSION_STR}'/g" Libcore.podspec && \
# sed -i "s/^s.version: .*/s.version = '$${VERSION_STR}'/g" Libcore.podspec && \
sed -i "s/^let version: .*/let version = \"v$${VERSION_STR}\"/g" Package.swift && \
sed -i -e "s|<key>CFBundleVersion</key>\s*<string>[^<]*</string>|<key>CFBundleVersion</key><string>$${VERSION_STR}</string>|" Info.plist &&\
sed -i -e "s|<key>CFBundleShortVersionString</key>\s*<string>[^<]*</string>|<key>CFBundleShortVersionString</key><string>$${VERSION_STR}</string>|" Info.plist &&\
git tag $${TAG} > /dev/null && \
git tag -d $${TAG} > /dev/null && \
git add Libcore.podspec Info.plist && \
git add Package.swift Info.plist && \
git commit -m "release: version $${TAG}" && \
echo "creating git tag : v$${TAG}" && \
git tag v$${TAG} && \

View File

@@ -3,24 +3,45 @@
import PackageDescription
let package = Package(
name: "Libcore",
platforms: [
.iOS(.v13) // Minimum platform version
],
products: [
.library(
name: "Libcore",
targets: ["Libcore"]),
],
dependencies: [
// No dependencies
],
targets: [
.binaryTarget(
name: "Libcore",
url: "https://github.com/hiddify/hiddify-next-core/releases/download/draft/hiddify-libcore-ios.xcframework.zip",
checksum: "70f84a51508898a706e72ab9eda4af8ab72c321bf79284b38313764b8f2091b2"
)
]
)
func fetchChecksum(from url: String) throws -> String {
guard let checksumURL = URL(string: url) else {
throw NSError(domain: "Invalid URL", code: 0, userInfo: nil)
}
let checksumString = try String(contentsOf: checksumURL)
return checksumString.trimmingCharacters(in: .whitespacesAndNewlines)
}
let version = "draft"
let baseURL = "https://github.com/hiddify/hiddify-next-core/releases/download/"
let packageURL = "\(baseURL)\(version)/hiddify-libcore-ios.xcframework.zip"
let checksumURL = "\(packageURL).sha256"
do {
let package = Package(
name: "Libcore",
platforms: [
.iOS(.v13) // Minimum platform version
],
products: [
.library(
name: "Libcore",
targets: ["Libcore"]),
],
dependencies: [
// No dependencies
],
targets: [
.binaryTarget(
name: "Libcore",
url: packageURL,
checksum: try fetchChecksum(from: checksumURL)
)
]
)
} catch {
// Handle URL or checksum fetch errors
print("Error: \(error)")
// You might want to exit or handle the error in a way suitable for your application
// exit(1)
}