From 0268051a4de724965037134ffb06248d44b1acb3 Mon Sep 17 00:00:00 2001 From: Max Cobb Date: Wed, 19 Apr 2023 15:45:15 +0100 Subject: [PATCH 1/3] added initial docc deployment pieces --- .github/workflows/deploy_docs.yml | 50 ++++++++++++++++++ .gitignore | 4 ++ doc_gen/dl_framework.sh | 12 +++++ doc_gen/docc_builder.zip | Bin 0 -> 7426 bytes doc_gen/headers_to_xcodeproj.sh | 54 ++++++++++++++++++++ doc_gen/move_header_files.sh | 82 ++++++++++++++++++++++++++++++ 6 files changed, 202 insertions(+) create mode 100644 .github/workflows/deploy_docs.yml create mode 100644 doc_gen/dl_framework.sh create mode 100644 doc_gen/docc_builder.zip create mode 100644 doc_gen/headers_to_xcodeproj.sh create mode 100644 doc_gen/move_header_files.sh diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml new file mode 100644 index 0000000..30e029c --- /dev/null +++ b/.github/workflows/deploy_docs.yml @@ -0,0 +1,50 @@ +# Simple workflow for deploying static content to GitHub Pages +name: Deploy DocC + +on: + # Runs on new releases + release: + types: [published] + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow one concurrent deployment +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + # Single deploy job since we're just deploying + deploy: + # Will only publish if the new release matches with the latest main branch commit. + if: ${{ github.event.release.prerelease == false && github.event.release.draft == false }} + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: macos-12 + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 + - name: Build DocC + run: | + sh -e doc_gen/dl_framework.sh AgoraChat + sh -e doc_gen/move_header_files.sh AgoraChat.xcframework AgoraChat.docc + sh -e doc_gen/headers_to_xcodeproj.sh AgoraChat docc_builder + xcodebuild -project docc_builder/AgoraChat.xcodeproj docbuild -scheme AgoraChat -derivedDataPath /tmp/docbuild -destination generic/platform=iOS + $(xcrun --find docc) process-archive \ + transform-for-static-hosting /tmp/docbuild/Build/Products/Debug-iphoneos/AgoraChat.doccarchive \ + --hosting-base-path AgoraChat_iOS \ + --output-path docs; + echo "" > docs/index.html + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + # Upload docs directory + path: 'docs' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 diff --git a/.gitignore b/.gitignore index 3b29812..51b1f33 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,7 @@ DerivedData/ .swiftpm/config/registries.json .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata .netrc +*.xcframework +*.xcframework.zip +docc_builder +docs \ No newline at end of file diff --git a/doc_gen/dl_framework.sh b/doc_gen/dl_framework.sh new file mode 100644 index 0000000..5a5c9a1 --- /dev/null +++ b/doc_gen/dl_framework.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +framework_name=$1 + +# Get URL for AgoraRtcKit binary target from Package.swift +url=$(grep -m 1 "https.*$framework_name.*.xcframework.zip" Package.swift | sed -E "s/.*(https.*$framework_name.*.xcframework.zip).*/\1/") + +# Download the AgoraRtcKit xcframework zip file +curl -O $url + +# Extract the contents of the zip file to the current directory +unzip $(basename $url) diff --git a/doc_gen/docc_builder.zip b/doc_gen/docc_builder.zip new file mode 100644 index 0000000000000000000000000000000000000000..0614f76f791c2620dbb8860b72aa7f57b2e1c37f GIT binary patch literal 7426 zcmb_g2RzjMA3uA9kiAz%I3r2O2$9X%n>+j5$sO6d>?j$D4jF|CA%u`*9T}Aol9??# z;(u5Fo=QE{^Ln12*Y|w!@)_^X=lgxXe;-{9JbY3B_VEjdHTtyq{|7mM1ptAA!Pa)3 z&QOTGhlrs82>`F)i6mqevpl^I0dVlwaR2~(8q7cFV$5K_69cYGM;Xy9EKvzy|HJ?Q z&>b`bR0dgtkZ=$CPxcf|#Ua>rz}`a2sQMF8nuwq~w8ui%JW_mc?coV=oy;qT7aKKl z@ACIt$tJdXIlXeipJS=EWM%i-WvvFW*UwiKx75?pC31L90XmlJ=J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>`0ch%=BOX55oynF7C^;=b41 z?4@-Lg=N&md>AxKaQJmKF>wj4&R5vmFu?qEk6|{zKLy6o8R_f@`!e?{!k~g(2av(~ z`8-EVEekg?n|IMP#rVK-Ki_ZsKs?>te1M;B!%utyPZfd`{Wz%XeKpVDBSL1C?Zh*>Y2csp&?Onl#GlF zjB_Cd9`;jo6ZA>^m6It`xje~`sp<1L7z)S1WyAY9iIW2`9rWp;1k@{HHwOl*1fK`1 zKY)QX`FCU0FD3zioDkK6CckMzjP0KcSbr5R?>FHtDAr?c&+o$h#T@bXdHgs<{G12I z2__E?+&}g8!%Pw5`X}?mU!^JiU7Flv|J3z25)yN%{66&`mF%~vr~E7bf3IsXas5Qo z{t6e>?{K+9{%>$OAVB{Nr0?bDw;&Nw{Aa=Zy%_yHVn52cFNcv5u%Kvh_&*EstGN5; zL0NuR#>xLasDnc9_aPpnY?kjr^r!qKZhv&few2J)DucaVdVb^K`&;uT;_p|-hUdFv zim88{%vUw?`!n&Q7WpHFlc%H*eX^O?bZWchDh@?kjX7nC6KB{|?XoR3NK vr+ojF;(lcO&ptm>L;P=ie#ie9XITFKAwdE{49x&2F<-Zc0DyC}*q{Cf*%8Wq literal 0 HcmV?d00001 diff --git a/doc_gen/headers_to_xcodeproj.sh b/doc_gen/headers_to_xcodeproj.sh new file mode 100644 index 0000000..78eea6e --- /dev/null +++ b/doc_gen/headers_to_xcodeproj.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +xcframework_path=$1 +frameworkname=$(basename "$xcframework_path" | cut -f 1 -d '.') +xcoderoot="$2" + +# Set the path to the .pbxproj file +pbxproj_path="$xcoderoot/$frameworkname.xcodeproj/project.pbxproj" +echo "Building framework: $frameworkname" + +# Set the path to the directory containing the header files +headers_dir="$xcoderoot/$frameworkname/Headers" +#!/bin/bash + +private_headers="AgoraChat-Swift.h, AgoraChatOptions+PrivateDeploy.h, NSObject+Coding.h" + +# Add each header file to the project +for file_path in "$headers_dir"/*.h; do + if [ "$(basename "$file_path")" = "$frameworkname.h" ]; then + continue + fi + file_name=$(basename "$file_path") + file_uuid=$(uuidgen) + echo "Adding $file_name to project" + + # Add a line to the PBXFileReference section :done for basic files: + file_ref_line=" $file_uuid /* $file_name */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"$file_name\"; sourceTree = \"\\"; };" + sed -i '' -e $'/End PBXFileReference section/ i\\\n'"$file_ref_line" "$pbxproj_path" + + # Add a line to the PBXBuildFile section :done for basic files: + build_file_uuid=$(uuidgen) + build_file_line=" $build_file_uuid /* $file_name in Headers */ = {isa = PBXBuildFile; fileRef = $file_uuid /* $file_name */; };" + if [[ "$private_headers" == *"$file_name"* ]]; then + echo $file_name + else + build_file_line="$build_file_uuid /* $file_name in Headers */ = {isa = PBXBuildFile; fileRef = $file_uuid /* $file_name */; settings = {ATTRIBUTES = (Public, ); }; };" + sed -i '' -E "s/#import +\"(.*)\"/#import <$frameworkname\/\1>/" "$file_path" + fi + + sed -i '' -e $'/End PBXBuildFile section/ i\\\n'"$build_file_line" "$pbxproj_path" + + # Add the file to the Headers group in the PBXGroup section + line_number=$(awk '/path = Headers;/ {print NR-1; exit}' "$pbxproj_path") + # Insert the file to the children list in the PBXGroup section + group_line=" $file_uuid /* $file_name */," + sed -i '' -e "${line_number}i\\ + $group_line" "$pbxproj_path" + + # Add the file to the Headers build phase in the PBXHeadersBuildPhase section + line_number=$(awk '/isa = PBXHeadersBuildPhase;/ {print NR+3; exit}' "$pbxproj_path") + build_phase_line=" $build_file_uuid /* $file_name in Headers */," + sed -i '' -e "${line_number}i\\ + $build_phase_line" "$pbxproj_path" +done \ No newline at end of file diff --git a/doc_gen/move_header_files.sh b/doc_gen/move_header_files.sh new file mode 100644 index 0000000..e84be08 --- /dev/null +++ b/doc_gen/move_header_files.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +zippedxcodeproj=$(dirname "${BASH_SOURCE[0]}")/docc_builder.zip + +unzip "$zippedxcodeproj" + +xcframework_path=$1 +frameworkname="$(basename "$xcframework_path" | cut -f 1 -d '.')" +xcoderoot=docc_builder +doccpath=$2 +pbxproj_path="$xcoderoot/$frameworkname.xcodeproj/project.pbxproj" + +# Set the source and destination directories +src_dir="$xcframework_path/ios-arm64_armv7/$frameworkname.framework/Headers" +dest_dir="$xcoderoot/$frameworkname" + +# Replace all instances of "FRAMEWORK_NAME" with the new value +mv $xcoderoot/FRAMEWORK_NAME.xcodeproj $xcoderoot/$frameworkname.xcodeproj +mv $xcoderoot/FRAMEWORK_NAME $xcoderoot/$frameworkname +sed -i '' "s/FRAMEWORK_NAME/$frameworkname/g" $pbxproj_path +# main_group=$(grep -o 'mainGroup = [[:alnum:]]\{24\}' $pbxproj_path | cut -d' ' -f3 | tr -d ';') + +# Copy all header files including "AgoraRtcKit.h" to the Headers subdirectory +find "$src_dir" -type f -name "*.h" -exec cp {} "$dest_dir/Headers" \; + +file_name=$(basename "$frameworkname.h") +file_uuid=$(uuidgen) +echo "Adding $file_name to project" +build_file_uuid=$(uuidgen) +# F3B5915329E28E6E007A92E3 /* AgoraRtcKit.h in Headers */ = {isa = PBXBuildFile; fileRef = F3B5915229E28E6E007A92E3 /* AgoraRtcKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; +build_file_line=" $build_file_uuid /* $file_name in Headers */ = {isa = PBXBuildFile; fileRef = $file_uuid /* $file_name */; settings = {ATTRIBUTES = (Public, ); }; };" +echo "$build_file_line" +sed -i '' -e $'/End PBXBuildFile section/ i\\\n'"$build_file_line" "$pbxproj_path" + +# F3B5915229E28E6E007A92E3 /* AgoraRtcKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AgoraRtcKit.h; sourceTree = ""; }; +file_ref_line=" $file_uuid /* $file_name */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"$file_name\"; sourceTree = \"\"; };" +echo "$file_ref_line" +sed -i '' -e $'/End PBXFileReference section/ i\\\n'"$file_ref_line" "$pbxproj_path" + +# Add the file to the Headers group in the PBXGroup section +line_number=$(awk '/path = Headers;/ {print NR-1; exit}' "$pbxproj_path") +# Insert the file to the children list in the PBXGroup section +group_line=" $file_uuid /* $file_name */," +sed -i '' -e "${line_number}i\\ + $group_line" "$pbxproj_path" + +# Add the file to the Headers build phase in the PBXHeadersBuildPhase section +line_number=$(awk '/isa = PBXHeadersBuildPhase;/ {print NR+3; exit}' "$pbxproj_path") +build_phase_line=" $build_file_uuid /* $file_name in Headers */," +sed -i '' -e "${line_number}i\\ + $build_phase_line" "$pbxproj_path" + +if [ ! -z $2 ]; then + # Add DocC + # cp -r $doccpath $dest_dir + file_name=$(basename "$dest_dir/$doccpath") + file_uuid=$(uuidgen) + echo "Adding $file_name to project" + docc_relpath="../$doccpath" + + build_file_uuid=$(uuidgen) + build_file_line=" $build_file_uuid /* $file_name in Sources */ = {isa = PBXBuildFile; fileRef = $file_uuid /* $file_name */; };" + sed -i '' -e $'/End PBXBuildFile section/ i\\\n'"$build_file_line" "$pbxproj_path" + + file_ref_line=" $file_uuid /* $file_name */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; name = $file_name; path = $docc_relpath; sourceTree = SOURCE_ROOT; };" + + echo "$file_ref_line" + sed -i '' -e $'/End PBXFileReference section/ i\\\n'"$file_ref_line" "$pbxproj_path" + + # Add the file to the Headers build phase in the PBXSourcesBuildPhase section + line_number=$(awk '/isa = PBXSourcesBuildPhase;/ {print NR+3; exit}' "$pbxproj_path") + build_phase_line=" $build_file_uuid /* $file_name */," + echo "$build_phase_line" + sed -i '' -e "${line_number}i\\ + $build_phase_line" "$pbxproj_path" + + line_number=$(awk -v frameworkname=$frameworkname -v string="path = ${frameworkname};" '$0 ~ string {print NR-2; exit}' $pbxproj_path) + file_ref_line=" $file_uuid /* $file_name */," + echo "$file_ref_line" + sed -i '' -e "${line_number}i\\ + $file_ref_line" "$pbxproj_path" +fi From eef1010ecb7b8eab5001ce1e0f762ca4b8c5c5a1 Mon Sep 17 00:00:00 2001 From: Max Cobb Date: Wed, 19 Apr 2023 16:33:05 +0100 Subject: [PATCH 2/3] updated build rules for docc deployment --- .github/workflows/deploy_docs.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index 30e029c..3530a7e 100644 --- a/.github/workflows/deploy_docs.yml +++ b/.github/workflows/deploy_docs.yml @@ -5,6 +5,8 @@ on: # Runs on new releases release: types: [published] + push: + branches: [docc_deploy] # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: @@ -32,7 +34,7 @@ jobs: - name: Build DocC run: | sh -e doc_gen/dl_framework.sh AgoraChat - sh -e doc_gen/move_header_files.sh AgoraChat.xcframework AgoraChat.docc + sh -e doc_gen/move_header_files.sh AgoraChat.xcframework sh -e doc_gen/headers_to_xcodeproj.sh AgoraChat docc_builder xcodebuild -project docc_builder/AgoraChat.xcodeproj docbuild -scheme AgoraChat -derivedDataPath /tmp/docbuild -destination generic/platform=iOS $(xcrun --find docc) process-archive \ From 106ac4e2d622233ed8f857fc31ef32a4dd0880bd Mon Sep 17 00:00:00 2001 From: Max Cobb Date: Wed, 19 Apr 2023 16:44:06 +0100 Subject: [PATCH 3/3] updated build rules to fire on main branch pushes too --- .github/workflows/deploy_docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index 3530a7e..1ab77f0 100644 --- a/.github/workflows/deploy_docs.yml +++ b/.github/workflows/deploy_docs.yml @@ -6,7 +6,7 @@ on: release: types: [published] push: - branches: [docc_deploy] + branches: [docc_deploy, main] # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: