|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +env: |
| 10 | + FRAMEWORK: net9.0 |
| 11 | + CONFIGURATION: Release |
| 12 | + DOTNET_CLI_TELEMETRY_OPTOUT: true |
| 13 | + MIN_SDK: 21 |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + toolchain: |
| 21 | + - aarch64-linux-android |
| 22 | + - armv7a-linux-androideabi |
| 23 | + - x86_64-linux-android |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + submodules: true |
| 29 | + |
| 30 | + - name: Build OpenSSL |
| 31 | + run: | |
| 32 | + declare -A TARGETS |
| 33 | + TARGETS["aarch64-linux-android"]=android-arm64 |
| 34 | + TARGETS["armv7a-linux-androideabi"]=android-arm |
| 35 | + TARGETS["x86_64-linux-android"]=android-x86_64 |
| 36 | + TARGETS["i686-linux-android"]=android-x86 |
| 37 | + |
| 38 | + TOOLCHAIN="$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64" |
| 39 | + export PATH="$TOOLCHAIN/bin:$PATH" |
| 40 | + |
| 41 | + cd openssl |
| 42 | + ./Configure ${TARGETS[${{ matrix.toolchain }}]} -D__ANDROID_API__=$MIN_SDK -static -fpic -no-shared -no-fuzz-afl -no-fuzz-libfuzzer -no-tests -no-apps '-Wno-macro-redefined' |
| 43 | + make -j 4 |
| 44 | + |
| 45 | + - name: Build SQLCipher |
| 46 | + run: | |
| 47 | + TOOLCHAIN="$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64" |
| 48 | + TARGET="${{ matrix.toolchain }}$MIN_SDK" |
| 49 | + OPENSSL_HEADERS=$(realpath openssl/include) |
| 50 | + OPENSSL_LIB=$(realpath openssl/libcrypto.a) |
| 51 | +
|
| 52 | + export CC="$TOOLCHAIN/bin/clang --target=$TARGET" |
| 53 | + export CXX="$TOOLCHAIN/bin/clang++ --target=$TARGET" |
| 54 | + export LD="$TOOLCHAIN/bin/ld" |
| 55 | + |
| 56 | + cd sqlcipher |
| 57 | + ./configure --with-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -DSQLITE_EXTRA_INIT=sqlcipher_extra_init -DSQLITE_EXTRA_SHUTDOWN=sqlcipher_extra_shutdown -D__ANDROID_API__=$MIN_SDK -I$OPENSSL_HEADERS" LDFLAGS="$OPENSSL_LIB -llog -Wl,-z,max-page-size=16384" |
| 58 | + make -j 4 |
| 59 | +
|
| 60 | + "$TOOLCHAIN/bin/llvm-strip" libsqlite3.so |
| 61 | +
|
| 62 | + - name: Upload artifact |
| 63 | + uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: sqlcipher-${{ matrix.toolchain }} |
| 66 | + path: sqlcipher/libsqlite3.so |
| 67 | + |
| 68 | + package: |
| 69 | + runs-on: ubuntu-latest |
| 70 | + needs: build |
| 71 | + |
| 72 | + steps: |
| 73 | + - name: Checkout |
| 74 | + uses: actions/checkout@v4 |
| 75 | + |
| 76 | + - name: Set up .NET |
| 77 | + uses: actions/setup-dotnet@v4 |
| 78 | + with: |
| 79 | + dotnet-version: '9' |
| 80 | + |
| 81 | + - name: Download artifacts |
| 82 | + uses: actions/download-artifact@v4 |
| 83 | + with: |
| 84 | + pattern: sqlcipher-* |
| 85 | + path: artifacts |
| 86 | + |
| 87 | + - name: Build |
| 88 | + run: | |
| 89 | + mkdir -p "Stratum.SQLCipher/runtimes/android-arm64-v8a" |
| 90 | + cp "artifacts/sqlcipher-aarch64-linux-android/libsqlite3.so" "Stratum.SQLCipher/runtimes/android-arm64-v8a/libsqlcipher.so" |
| 91 | + |
| 92 | + mkdir -p "Stratum.SQLCipher/runtimes/android-armeabi-v7a" |
| 93 | + cp "artifacts/sqlcipher-armv7a-linux-androideabi/libsqlite3.so" "Stratum.SQLCipher/runtimes/android-armeabi-v7a/libsqlcipher.so" |
| 94 | + |
| 95 | + mkdir -p "Stratum.SQLCipher/runtimes/android-x86_64" |
| 96 | + cp "artifacts/sqlcipher-x86_64-linux-android/libsqlite3.so" "Stratum.SQLCipher/runtimes/android-x86_64/libsqlcipher.so" |
| 97 | +
|
| 98 | + dotnet build --configuration $CONFIGURATION Stratum.SQLCipher.sln |
| 99 | +
|
| 100 | + - name: Upload artifact |
| 101 | + uses: actions/upload-artifact@v4 |
| 102 | + with: |
| 103 | + name: stratum-sqlcipher |
| 104 | + path: Stratum.SQLCipher/bin/**/Stratum.SQLCipher*.nupkg |
| 105 | + |
| 106 | + - name: Publish package |
| 107 | + run: | |
| 108 | + pkg=$(find Stratum.SQLCipher/bin/$CONFIGURATION/ -name '*.nupkg') |
| 109 | + dotnet nuget push $pkg --api-key ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json |
0 commit comments