Skip to content

Commit

Permalink
Merge pull request #5 from amnezia-vpn/fix/android-openssl3
Browse files Browse the repository at this point in the history
  • Loading branch information
pokamest authored Apr 13, 2024
2 parents 36d5926 + 8990c36 commit 2ef0b93
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 155 deletions.
99 changes: 0 additions & 99 deletions .github/workflows/build_openssl3_android.yml

This file was deleted.

117 changes: 61 additions & 56 deletions .github/workflows/build_openssl_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,36 @@ jobs:
contains(github.event.head_commit.message, '[all]') ||
contains(github.event.head_commit.message, '[android]') ||
contains(github.event.head_commit.message, '[android-openssl]') ||
contains(github.event.head_commit.message, '[openssl]')
contains(github.event.head_commit.message, '[openssl]')
env:
ANDROID_MIN_SDK: 24
ANDROID_NDK_VERSION: 'r26b'

strategy:
matrix:
arch: [x86, x86_64, armeabi-v7a, arm64-v8a]
fail-fast: false
include:
- arch: arm64-v8a
target: android-arm64
- arch: armeabi-v7a
target: android-arm
- arch: x86_64
target: android-x86_64
- arch: x86
target: android-x86

steps:
- name: 'Setup Android NDK'
id: setup-ndk
uses: nttld/setup-ndk@v1
with:
ndk-version: ${{ env.ANDROID_NDK_VERSION }}

- name: 'Install patchelf'
run: sudo apt-get install -y patchelf

- name: 'Get openssl'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: openssl/openssl
ref: openssl-3.0.13
Expand All @@ -29,69 +49,54 @@ jobs:
- name: 'Build OpenSSL Android'
run: |
cd openssl
mkdir build
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
mkdir build/arm64-v8a
cp libcrypto.a ./build/arm64-v8a/libcrypto.a
cp libssl.a ./build/arm64-v8a/libssl.a
cp -a ./include/. ./build/include
;;
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
mkdir build/armeabi-v7a
cp libcrypto.a ./build/armeabi-v7a/libcrypto.a
cp libssl.a ./build/armeabi-v7a/libssl.a
;;
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
mkdir build/x86_64
cp libcrypto.a ./build/x86_64/libcrypto.a
cp libssl.a ./build/x86_64/libssl.a
;;
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
mkdir build/x86
cp libcrypto.a ./build/x86/libcrypto.a
cp libssl.a ./build/x86/libssl.a
;;
esac
- name: Archive Android OpenSSL libs
uses: actions/upload-artifact@v3
PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
./Configure ${{ matrix.target }} shared no-tests -D__ANDROID_API__=${{ env.ANDROID_MIN_SDK }}
make -j$(nproc) SHLIB_VERSION_NUMBER= build_libs
mkdir -p build/${{ matrix.arch }}
cp libcrypto.so ./build/${{ matrix.arch }}/libcrypto_3.so
cp libssl.so ./build/${{ matrix.arch }}/libssl_3.so
cp libcrypto.a ./build/${{ matrix.arch }}/libcrypto.a
cp libssl.a ./build/${{ matrix.arch }}/libssl.a
[ ${{ matrix.arch }} == arm64-v8a ] && cp -a ./include/. ./build/include
cd ./build/${{ matrix.arch }}
patchelf --debug --set-soname libcrypto_3.so libcrypto_3.so
patchelf --debug --set-soname libssl_3.so libssl_3.so
patchelf --debug --replace-needed libcrypto.so libcrypto_3.so libssl_3.so
- name: 'Archive Android OpenSSL libs'
uses: actions/upload-artifact@v4
with:
retention-days: 1
name: android-openssl
path: '~/work/3rd-build-ga/3rd-build-ga/openssl/build'
name: android-openssl-${{ matrix.arch }}
path: openssl/build


github-release:
name: GitHub Release
needs: Build-Libs-OpenSSL-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 | Checkout
uses: actions/checkout@v4

- name: Setup | Checksums
run: for file in $(find ./ -name '*.a' ); do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done
- name: Setup | Artifacts
uses: actions/download-artifact@v4
with:
path: android-openssl
merge-multiple: true

- name: Zip ALL
run: for file in *; do zip -r ${file%.*}.zip $file; done
- name: Setup | Checksums
run: for file in $(find ./ -regex '.*\.\(a\|so\)' ); do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: android-openssl.zip
tag: ${{ github.ref }}
overwrite: true
file_glob: true

- 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: android-openssl.zip
tag: ${{ github.ref }}
overwrite: true
file_glob: true

0 comments on commit 2ef0b93

Please sign in to comment.