-
Notifications
You must be signed in to change notification settings - Fork 5
135 lines (115 loc) · 6.99 KB
/
build_libssh_android.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: libssh-android
on: [push]
env:
# Expected filename: https://zlib.net/zlib-${{env.ZLIB_VERSION}}.tar.gz
ZLIB_VERSION: 1.3.1
# Expected filename: https://www.openssl.org/source/openssl-${{env.OPENSSL_VERSION}}.tar.gz
OPENSSL_VERSION: 3.0.13
# Exoected filename: ${{env.LIBSSH_SOURCE}}libssh-${{env.LIBSSH_VERSION}}.tar.xz
LIBSSH_SOURCE: https://www.libssh.org/files/0.10/
LIBSSH_VERSION: 0.10.6
jobs:
Build-LibSSH-Android:
runs-on: ubuntu-latest
if: |
contains(github.event.head_commit.message, '[all]') ||
contains(github.event.head_commit.message, '[android]') ||
contains(github.event.head_commit.message, '[android-libssh]') ||
contains(github.event.head_commit.message, '[libssh]')
strategy:
matrix:
arch: [x86_64, arm64-v8a, armeabi-v7a, x86]
# no-crypto=yes: builds version with all crypto disabled
# no-crypto=no: builds version with all crypto enabled (where required dependencies are available)
no_crypto:
- no
# - yes
env:
ANDROID_ARCH: ${{ matrix.arch }}
steps:
- name: Setup Android NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r21e
- name: Get dependencies
run: |
# Get and unpack zlibx
curl -LOJ https://zlib.net/zlib-${{env.ZLIB_VERSION}}.tar.gz
tar -xzf zlib-${{env.ZLIB_VERSION}}.tar.gz
# Get and unpack openssl
curl -LOJ https://www.openssl.org/source/openssl-${{env.OPENSSL_VERSION}}.tar.gz
tar -xzf openssl-${{env.OPENSSL_VERSION}}.tar.gz
# Get and unpack libssh
curl -LOJ ${{env.LIBSSH_SOURCE}}libssh-${{env.LIBSSH_VERSION}}.tar.xz
tar -xf libssh-${{env.LIBSSH_VERSION}}.tar.xz
cd libssh-${{env.LIBSSH_VERSION}}
mkdir build
- name: Build zlib
run: |
cd zlib-${{env.ZLIB_VERSION}}
cmake ./ -DCMAKE_SYSTEM_NAME=Android -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_SYSTEM_VERSION=24 -DANDROID_ABI=$ANDROID_ARCH -DCMAKE_ANDROID_ARCH_ABI=$ANDROID_ARCH -DANDROID_NDK=$ANDROID_NDK_ROOT -DCMAKE_ANDROID_NDK=$ANDROID_NDK_ROOT -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake
PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH make
make zlibstatic
cp ./libz.a ${{github.workspace}}/libssh-${{env.LIBSSH_VERSION}}/build/libz.a
- name: Build openssl
run: |
cd openssl-${{env.OPENSSL_VERSION}}
case "${{ matrix.arch }}" in
arm64-v8a)
ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH ./Configure android-arm64 no-tests -U__ANDROID_API__ -D__ANDROID_API__=21 && PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH make
;;
armeabi-v7a)
ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH ./Configure android-arm no-tests -U__ANDROID_API__ -D__ANDROID_API__=21 && PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH make
;;
x86_64)
ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH ./Configure android-x86_64 no-tests -U__ANDROID_API__ -D__ANDROID_API__=21 && PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH make
;;
x86)
ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH ./Configure android-x86 no-tests -U__ANDROID_API__ -D__ANDROID_API__=21 && PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH make
;;
esac
- name: Build libssh
run: |
cd libssh-${{env.LIBSSH_VERSION}}
sed -i 's/add_c_compiler_flag("-Werror=strict-prototypes" SUPPORTED_COMPILER_FLAGS)/#add_c_compiler_flag("-Werror=strict-prototypes" SUPPORTED_COMPILER_FLAGS)/g' ./CompilerChecks.cmake
cd src
export OPENSSL_ROOT_DIR=${{github.workspace}}/openssl-${{env.OPENSSL_VERSION}}
export ZLIB_ROOT_DIR=${{github.workspace}}/zlib-${{env.ZLIB_VERSION}}
export OPENSSL_CRYPTO_LIBRARY=${{github.workspace}}/openssl-${{env.OPENSSL_VERSION}}/libcrypto.a:${{github.workspace}}/openssl-${{env.OPENSSL_VERSION}}/libssl.a
export OPENSSL_INCLUDE_DIR=${{github.workspace}}/openssl-${{env.OPENSSL_VERSION}}/include
wget https://raw.githubusercontent.com/termux/termux-packages/master/packages/libandroid-glob/glob.c --no-check-certificate
wget https://raw.githubusercontent.com/termux/termux-packages/master/packages/libandroid-glob/glob.h --no-check-certificate
sed -i 's/legacy.c/legacy.c glob.c/g' ./CMakeLists.txt
cd ../build
cmake .. -DANDROID_PLATFORM=android-21 -DCMAKE_ANDROID_API_MIN=21 -DCMAKE_ANDROID_API=21 -DWITH_GSSAPI=OFF -DCMAKE_CXX_FLAGS="-D__USE_BSD=1 " -DCMAKE_C_FLAGS="-D__USE_BSD=1" -DCMAKE_SYSTEM_NAME=Android -DWITH_SERVER=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_SYSTEM_VERSION=24 -DANDROID_ABI=$ANDROID_ARCH -DCMAKE_ANDROID_ARCH_ABI=$ANDROID_ARCH -DANDROID_NDK=$ANDROID_NDK_ROOT -DCMAKE_ANDROID_NDK=$ANDROID_NDK_ROOT -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DOPENSSL_USE_STATIC_LIBS=TRUE -DZLIB_LIBRARY=${{github.workspace}}/zlib-${{env.ZLIB_VERSION}}/libz.a -DZLIB_INCLUDE=${{github.workspace}}/zlib-${{env.ZLIB_VERSION}} -DOPENSSL_CRYPTO_LIBRARY=${{github.workspace}}/openssl-${{env.OPENSSL_VERSION}}/libcrypto.a -DOPENSSL_SSL_LIBRARY=${{github.workspace}}/openssl-${{env.OPENSSL_VERSION}}/libssl.a -DOPENSSL_INCLUDE_DIR=${{github.workspace}}/openssl-${{env.OPENSSL_VERSION}}/include -DCMAKE_EXE_LINKER_FLAGS="-static"
PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH make ssh
- name: Upload Artifact
uses: actions/[email protected]
with:
name: libssh-android-${{ matrix.arch }}
path: ${{ github.workspace }}/libssh-${{env.LIBSSH_VERSION}}/build
if-no-files-found: error
retention-days: 7
github-release:
name: GitHub Release
needs: Build-LibSSH-Android
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Setup | Checkout
uses: actions/checkout@v2
- name: Setup | Artifacts
uses: actions/download-artifact@v2
- name: Setup | Checksums
run: for file in $(find ./ -name '*.so' ); do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done
- name: Zip ALL
run: for file in *; do zip -r ${file%.*}.zip $file; done
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: "*.zip"
tag: ${{ github.ref }}
overwrite: true
file_glob: true