update #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: release-apk | |
on: [push] | |
# on: | |
# push: | |
# tags: | |
# - '*' | |
env: | |
NCNN_VERSION: 20240410 | |
OPENCV_VERSION: 4.9.0 | |
OPENCV_MOBILE_TAG: v26 | |
BUILD_TOOLS_VERSION: 32.0.0 | |
jobs: | |
release-apk: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: setup-java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
- name: ncnn | |
run: | | |
wget -q https://github.com/Tencent/ncnn/releases/download/${NCNN_VERSION}/ncnn-${NCNN_VERSION}-android-vulkan.zip | |
unzip -q ncnn-${NCNN_VERSION}-android-vulkan.zip -d app/src/main/jni | |
- name: opencv-mobile | |
run: | | |
wget -q https://github.com/nihui/opencv-mobile/releases/download/${OPENCV_MOBILE_TAG}/opencv-mobile-${OPENCV_VERSION}-android.zip | |
unzip -q opencv-mobile-${OPENCV_VERSION}-android.zip -d app/src/main/jni | |
- name: modify-jni-cmakelists | |
run: | | |
sed -i "s@ncnn-[^-]*-android-vulkan@ncnn-${NCNN_VERSION}-android-vulkan@g" app/src/main/jni/CMakeLists.txt | |
sed -i "s@opencv-mobile-[^-]*-android@opencv-mobile-${OPENCV_VERSION}-android@g" app/src/main/jni/CMakeLists.txt | |
- name: build-apk | |
run: | | |
bash ./gradlew assembleRelease --stacktrace | |
- name: sign-apk | |
id: signapk | |
run: | | |
DATE=`date +'%Y%m%d'` | |
SHA_SHORT=`git rev-parse --short HEAD` | |
UNSIGNED_APK=`find app/build/outputs/apk/release -type f -name "*-release-unsigned.apk" | head -n 1` | |
ALIGNED_APK=${UNSIGNED_APK//-release-unsigned.apk/-release-unsigned-aligned.apk} | |
SIGNED_APK=${{ github.event.repository.name }}-${DATE}.${SHA_SHORT}.apk | |
keytool -genkey -noprompt -alias ncnn \ | |
-dname "CN=mqttserver.ibm.com, OU=ID, O=IBM, L=Hursley, S=Hants, C=GB"\ | |
-keystore ncnn.keystore -storepass 7767517 -keypass 7767517 \ | |
-keyalg RSA -keysize 2048 -validity 10000 | |
${ANDROID_HOME}/build-tools/${BUILD_TOOLS_VERSION}/zipalign -f -v 4 ${UNSIGNED_APK} ${SIGNED_APK} | |
${ANDROID_HOME}/build-tools/${BUILD_TOOLS_VERSION}/apksigner sign --ks ncnn.keystore --ks-key-alias ncnn \ | |
--ks-pass pass:7767517 --key-pass pass:7767517 --out ${SIGNED_APK} ${SIGNED_APK} | |
${ANDROID_HOME}/build-tools/${BUILD_TOOLS_VERSION}/apksigner verify ${SIGNED_APK} | |
echo "SIGNED_APK=${SIGNED_APK}" >> $GITHUB_OUTPUT | |
echo "APK_VERSION=${DATE}.${SHA_SHORT}" >> $GITHUB_OUTPUT | |
- name: create-release | |
uses: softprops/action-gh-release@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag_name: ${{ steps.signapk.outputs.APK_VERSION }} | |
name: Release ${{ steps.signapk.outputs.APK_VERSION }} | |
files: ${{ steps.signapk.outputs.SIGNED_APK }} |