From 7ddaa0d69f6f92064ffef264c113f9d79cd421d8 Mon Sep 17 00:00:00 2001 From: Homayoun Date: Tue, 18 Jul 2023 20:23:07 +0330 Subject: [PATCH] Patch fula ios build (#153) * add patch to build for ios * add github action for cocoapods builds * add cocoapods bundler * add gomobile init * small fix * small fix * Add headers to cocoapods bundle * typo fix * lipo ios archs * lipo: remove unused arm64 arch * fix ios version * switch to vendored frameworks * add proper versining * update the ios workflows * removed extra whitspace --------- Co-authored-by: Homayoun Co-authored-by: ehsan shariati --- .github/workflows/build-ios.yml | 33 ++++++++++++++------ .github/workflows/ensure-podspec-version.yml | 30 ++++++++++++++++++ .gitignore | 5 ++- FulaMobile.podspec => Fula.podspec | 16 +++++----- Makefile | 13 +++++--- 5 files changed, 74 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/ensure-podspec-version.yml rename FulaMobile.podspec => Fula.podspec (58%) diff --git a/.github/workflows/build-ios.yml b/.github/workflows/build-ios.yml index 408a21a8..819c4aee 100644 --- a/.github/workflows/build-ios.yml +++ b/.github/workflows/build-ios.yml @@ -2,8 +2,9 @@ name: Build for iOS on: push: - tags: - - '*' + pull_request: + release: + types: [published] jobs: build: @@ -11,6 +12,7 @@ jobs: runs-on: macos-latest permissions: contents: write + steps: - name: Checkout uses: actions/checkout@v3 @@ -26,13 +28,26 @@ jobs: run: go test -v -shuffle=on ./mobile - name: Build the artifact - if: startsWith(github.ref, 'refs/tags/') run: make fula-xcframework - - name: Release - uses: softprops/action-gh-release@v1 - # if: startsWith(github.ref, 'refs/tags/') + - name: Upload release asset + if: github.event_name == 'release' + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./build/cocoapods-bundle.zip + asset_name: cocoapods-bundle.zip + asset_content_type: application/zip + + - name: Upload release asset checksum + if: github.event_name == 'release' + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - files: | - build/cocoapods-bundle.zip - build/cocoapods-bundle.zip.sha256 + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./build/cocoapods-bundle.zip.sha256 + asset_name: cocoapods-bundle.zip.sha256 + asset_content_type: text/plain \ No newline at end of file diff --git a/.github/workflows/ensure-podspec-version.yml b/.github/workflows/ensure-podspec-version.yml new file mode 100644 index 00000000..9c49bf3d --- /dev/null +++ b/.github/workflows/ensure-podspec-version.yml @@ -0,0 +1,30 @@ +name: Update Podspec Version + +on: + release: + types: [published] + +jobs: + update-version: + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Update version + run: | + VERSION=$(echo ${{ github.event.release.tag_name }} | cut -c 2-) # remove the v from the tag name + sed -i 's/\(s.version\s*=\s*\).*$/\1\''"$VERSION"'\'/' Fula.podspec + sed -i 's/#{s.version}/'"$VERSION"'/' Fula.podspec + + - name: Set up Git + run: | + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + + - name: Commit and push + run: | + git add . + git commit -m "Update version to $VERSION" + git push \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0f46ecb3..d7be9631 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,7 @@ dist **.env */**/tmp wap/wap -.history/* \ No newline at end of file +.history/* +.env +build +tmp-fula-build diff --git a/FulaMobile.podspec b/Fula.podspec similarity index 58% rename from FulaMobile.podspec rename to Fula.podspec index af8ba80a..1fbf546d 100644 --- a/FulaMobile.podspec +++ b/Fula.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| - s.name = 'FulaMobile' # Name for your pod - s.version = '0.1.6' + s.name = 'Fula' # Name for your pod + s.version = '1.0.0' s.summary = 'Go-fula for iOS' s.homepage = 'https://github.com/functionland/go-fula' @@ -10,10 +10,10 @@ Pod::Spec.new do |s| s.platform = :ios # change the source location s.source = { :http => "https://github.com/functionland/go-fula/releases/download/v#{s.version}/cocoapods-bundle.zip" } - s.source_files = "include/*.{h}" - s.module_map = "include/module.modulemap" - s.ios.deployment_target = '11.0' - s.ios.vendored_libraries = 'Fula' - s.osx.vendored_libraries = 'Fula' + + s.ios.deployment_target = '13.0' + s.vendored_framework = 'Fula.xcframework' s.static_framework = true -end \ No newline at end of file + s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } + s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } +end diff --git a/Makefile b/Makefile index 47cfee2f..02a56eff 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,8 @@ GO_MOD_REPLACEMENT=replace github.com/raulk/go-watchdog => ./tmp-fula-build/go-w all: go test ./... -fula-xcframework: patch-go-watchdog prepare-gomobile build-fula-xcframework bundles +fula-xcframework: patch-go-watchdog prepare-gomobile build-fula-xcframework build-bundle zip + patch-go-watchdog: mkdir -p tmp-fula-build &&\ cd tmp-fula-build &&\ @@ -21,12 +22,14 @@ build-fula-xcframework: gomobile init &&\ gomobile bind -v -o Fula.xcframework -target=ios github.com/functionland/go-fula/mobile -bundles: +build-bundle: mkdir -p build &&\ cp LICENSE ./build/LICENSE && cd build &&\ - cp ../Fula.xcframework/ios-arm64/Fula.framework/Fula libfula_ios.a &&\ - cp ../Fula.xcframework/ios-arm64_x86_64-simulator/Fula.framework/Fula libfula_iossimulator.a &&\ - zip -r ./cocoapods-bundle.zip ./libfula_iossimulator.a ./libfula_ios.a && echo "$$(openssl dgst -sha256 ./cocoapods-bundle.zip)" > ./cocoapods-bundle.zip.sha256 + mv ../Fula.xcframework . + +zip: + cd build &&\ + zip -r ./cocoapods-bundle.zip ./Fula.xcframework ./LICENSE && echo "$$(openssl dgst -sha256 ./cocoapods-bundle.zip)" > ./cocoapods-bundle.zip.sha256 clean-up: grep -v "$(GO_MOD_REPLACEMENT)" ./go.mod > ./tmp.mod ; mv ./tmp.mod ./go.mod &&\