|
| 1 | +name: Build OpenVPNAdapter for Apple |
| 2 | + |
| 3 | +on: [push] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build-ios: |
| 7 | + name: 'OpenVPNAdapter for iOS' |
| 8 | + runs-on: macos-latest |
| 9 | + if: | |
| 10 | + contains(github.event.head_commit.message, '[all]') || |
| 11 | + contains(github.event.head_commit.message, '[ios]') || |
| 12 | + contains(github.event.head_commit.message, '[openvpnadapter-ios]') || |
| 13 | + contains(github.event.head_commit.message, '[openvpnadapter]') |
| 14 | +
|
| 15 | + steps: |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v3 |
| 18 | + with: |
| 19 | + submodules: recursive |
| 20 | + |
| 21 | + - name: 'Get OpenVPNAdapter' |
| 22 | + uses: actions/checkout@v3 |
| 23 | + with: |
| 24 | + repository: amnezia-vpn/OpenVPNAdapter |
| 25 | + ref: master-amnezia |
| 26 | + path: OpenVPNAdapter |
| 27 | + submodules: recursive |
| 28 | + |
| 29 | + - name: Configure amnezia.xcconfig |
| 30 | + run: | |
| 31 | + export WORKINGDIR=`pwd` |
| 32 | + echo "Configuring amnezia.xcconfig..." |
| 33 | + cat $WORKINGDIR/OpenVPNAdapter/Configuration/Project.xcconfig > $WORKINGDIR/OpenVPNAdapter/Configuration/amnezia.xcconfig |
| 34 | + cat << EOF >> $WORKINGDIR/OpenVPNAdapter/Configuration/amnezia.xcconfig |
| 35 | + PROJECT_TEMP_DIR = $WORKINGDIR/OpenVPNAdapter/build/OpenVPNAdapter.build |
| 36 | + CONFIGURATION_BUILD_DIR = $WORKINGDIR/OpenVPNAdapter/build/Release-iphoneos |
| 37 | + BUILT_PRODUCTS_DIR = $WORKINGDIR/OpenVPNAdapter/build/Release-iphoneos |
| 38 | + EOF |
| 39 | +
|
| 40 | + - name: Build OpenVPNAdapter for iOS |
| 41 | + run: | |
| 42 | + export SDK_PATH=`xcrun --sdk iphoneos --show-sdk-path` |
| 43 | + export CLANG=`xcrun --sdk iphoneos --find clang` |
| 44 | + export XCODEBUILD="/usr/bin/xcodebuild" |
| 45 | +
|
| 46 | + cd OpenVPNAdapter |
| 47 | + $XCODEBUILD -scheme OpenVPNAdapter \ |
| 48 | + -configuration Release \ |
| 49 | + -xcconfig Configuration/amnezia.xcconfig \ |
| 50 | + -sdk iphoneos \ |
| 51 | + -destination 'generic/platform=iOS' \ |
| 52 | + -project OpenVPNAdapter.xcodeproj \ |
| 53 | + CODE_SIGNING_ALLOWED=NO |
| 54 | +
|
| 55 | + # With CODE_SIGNING_ALLOWED=NO this part is redundant, but it's not just signatures are being deleted here, |
| 56 | + # It's also dependant frameworks and debug symbols. |
| 57 | + - name: Remove CodeSignature |
| 58 | + run: | |
| 59 | + export WORKINGDIR=`pwd` |
| 60 | + echo "Removing CodeSignature if exists..." |
| 61 | + rm -rf $WORKINGDIR/OpenVPNAdapter/build/Release-iphoneos/OpenVPNAdapter.framework/Versions/A/_CodeSignature |
| 62 | + rm -rf $WORKINGDIR/OpenVPNAdapter/build/Release-iphoneos/OpenVPNAdapter.framework/Versions/Current/_CodeSignature |
| 63 | + rm -rf $WORKINGDIR/OpenVPNAdapter/build/Release-iphoneos/LZ4.framework |
| 64 | + rm -rf $WORKINGDIR/OpenVPNAdapter/build/Release-iphoneos/OpenVPNClient.framework |
| 65 | + rm -rf $WORKINGDIR/OpenVPNAdapter/build/Release-iphoneos/mbedTLS.framework |
| 66 | + rm -rf $WORKINGDIR/OpenVPNAdapter/build/Release-iphoneos/OpenVPNAdapter.framework.dSYM |
| 67 | +
|
| 68 | + - name: Generate Checksums for OpenVPNAdapter.framework |
| 69 | + run: | |
| 70 | + export WORKINGDIR=`pwd` |
| 71 | + if [ -d "$WORKINGDIR/OpenVPNAdapter/build/Release-iphoneos/OpenVPNAdapter.framework" ]; then |
| 72 | + echo "Generating checksums for OpenVPNAdapter.framework..." |
| 73 | + find $WORKINGDIR/OpenVPNAdapter/build/Release-iphoneos/OpenVPNAdapter.framework \ |
| 74 | + -type f \ |
| 75 | + -exec sh -c 'openssl dgst -sha256 -r "$1" > "$1.sha256"' _ {} \; |
| 76 | + else |
| 77 | + echo "Directory $WORKINGDIR/OpenVPNAdapter/build/Release-iphoneos/OpenVPNAdapter.framework does not exist." |
| 78 | + exit 1 |
| 79 | + fi |
| 80 | + |
| 81 | + - name: Archive Build |
| 82 | + uses: actions/upload-artifact@v3 |
| 83 | + with: |
| 84 | + name: OpenVPNAdapter-ios |
| 85 | + path: 'OpenVPNAdapter/build/Release-iphoneos' |
| 86 | + |
| 87 | + github-release: |
| 88 | + name: GitHub Release |
| 89 | + needs: [build-ios] |
| 90 | + runs-on: ubuntu-latest |
| 91 | + if: startsWith(github.ref, 'refs/tags/') |
| 92 | + |
| 93 | + steps: |
| 94 | + - name: Setup | Checkout |
| 95 | + uses: actions/checkout@v3 |
| 96 | + |
| 97 | + - name: Setup | Download macOS Artifact |
| 98 | + uses: actions/download-artifact@v3 |
| 99 | + with: |
| 100 | + name: OpenVPNAdapter-macos |
| 101 | + path: openvpnadapter-mac/ |
| 102 | + |
| 103 | + - name: Setup | Download iOS Artifact |
| 104 | + uses: actions/download-artifact@v3 |
| 105 | + with: |
| 106 | + name: OpenVPNAdapter-ios |
| 107 | + path: openvpnadapter-ios/ |
| 108 | + |
| 109 | + - name: Create Combined Folder |
| 110 | + run: | |
| 111 | + mkdir -p openvpnadapter |
| 112 | + cp -r openvpnadapter-mac/ openvpnadapter/ |
| 113 | + cp -r openvpnadapter-ios/ openvpnadapter/ |
| 114 | +
|
| 115 | + - name: Zip Combined Artifacts |
| 116 | + run: | |
| 117 | + zip -r openvpnadapter.zip openvpnadapter/ |
| 118 | + shell: bash |
| 119 | + |
| 120 | + - name: List Generated Files |
| 121 | + run: ls -l |
| 122 | + |
| 123 | + - name: Upload Binaries to GitHub Release |
| 124 | + uses: svenstaro/upload-release-action@v2 |
| 125 | + with: |
| 126 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 127 | + tag: ${{ github.ref }} |
| 128 | + overwrite: true |
| 129 | + file: openvpnadapter.zip |
| 130 | + file_glob: false |
0 commit comments