Skip to content

android

android #16

Workflow file for this run

name: android
on:
workflow_dispatch:
jobs:
android:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
ver:
- { cv: 4.9.0, ndk: 25.2.9519653 }
env:
PKG_NAME: opencv-${{ matrix.ver.cv }}-android
steps:
# 删除ndk -g参数
- name: ndk del -g
run: sed -i -e '/^ -g$/d' $ANDROID_NDK_HOME/build/cmake/android-legacy.toolchain.cmake
# 检出代码
- uses: actions/checkout@v3
# 检出opencv
- name: checkout opencv
uses: actions/checkout@v3
with:
repository: opencv/opencv
path: opencv-${{ matrix.ver.cv }}
ref: ${{ matrix.ver.cv }}
submodules: recursive
# 复制
- name: copy build script
run: |
cp build-opencv4-android.sh opencv-${{ matrix.ver.cv }}
cp opencv4_cmake_options.txt opencv-${{ matrix.ver.cv }}
# 编译
- name: build
run: |
cd opencv-${{ matrix.ver.cv }}
chmod a+x build-opencv4-android.sh
./build-opencv4-android.sh $ANDROID_NDK_HOME
# 压缩
- name: 7zip
run: |
mv opencv-${{ matrix.ver.cv }}/opencv-android ${{ env.PKG_NAME }}
7z a ${{ env.PKG_NAME }}.7z ${{ env.PKG_NAME }}
# 上传artifact
- name: upload
uses: actions/upload-artifact@v3
with:
name: ${{ env.PKG_NAME }}
path: ${{ env.PKG_NAME }}.7z
# 获取所有的git log和tag
- name: Unshallow
run: git fetch --prune --unshallow
# 获取git log 从 previousTag 到 lastTag
- name: Get git log
id: git-log
run: |
previousTag=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`)
lastTag=$(git describe --abbrev=0 --tags)
echo "previousTag:$previousTag ~ lastTag:$lastTag"
log=$(git log $previousTag..$lastTag --pretty=format:'- %cd %an: %s\n' --date=format:'%Y-%m-%d %H:%M:%S')
echo "$log"
echo "log_state="$log"" >> $GITHUB_ENV
# 创建Changelog文件 triggered by git tag push
- name: Generate Changelog
if: startsWith(github.ref, 'refs/tags/')
run: |
echo -e '${{ env.log_state }}' > release.md
# 创建release 上传release
# https://github.com/marketplace/actions/create-release
- name: Create release and upload-archive
uses: ncipollo/release-action@v1
with:
prerelease: false
bodyFile: release.md
artifacts: ${{ env.PKG_NAME }}.7z
allowUpdates: true
artifactContentType: application/x-7z-compressed
token: ${{ secrets.GITHUB_TOKEN }}