Skip to content

ubuntu

ubuntu #1

Workflow file for this run

name: ubuntu
on:
workflow_dispatch:
jobs:
ubuntu:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os_name: [ubuntu]
ver:
- { cv: 4.9.0, cmake: 3.28.6, python: 3.8.19, ant: 1.10.14, jdk: openjdk-8-jdk }
list:
- { os_ver: 14.04, os_id: trusty }
- { os_ver: 16.04, os_id: xenial }
- { os_ver: 18.04, os_id: bionic }
- { os_ver: 20.04, os_id: focal }
- { os_ver: 22.04, os_id: jammy }
arch:
[
386,
amd64,
arm,
arm64,
ppc64le,
]
exclude:
- list: { os_ver: 14.04, os_id: trusty }
arch: ppc64le
- list: { os_ver: 20.04, os_id: focal }
arch: 386
- list: { os_ver: 22.04, os_id: jammy }
arch: 386
name: ubuntu-${{ matrix.list.os_ver }}-${{ matrix.arch }}
env:
BUILD_SCRIPT: build-opencv4-linux.sh
BUILD_OPTIONS: opencv4_cmake_options.txt
PKG_NAME: opencv-${{ matrix.ver.cv }}-ubuntu-${{ matrix.list.os_ver }}-${{ matrix.arch }}
JAVA_PKG_NAME: opencv-${{ matrix.ver.cv }}-ubuntu-${{ matrix.list.os_ver }}-${{ matrix.arch }}-java
steps:
# 检出代码
- uses: actions/checkout@v4
# 检出opencv
- name: checkout opencv
uses: actions/checkout@v4
with:
repository: opencv/opencv
path: opencv-${{ matrix.ver.cv }}
ref: ${{ matrix.ver.cv }}
submodules: recursive
# 复制
- name: copy
run: |
cp ${{ env.BUILD_SCRIPT }} opencv-${{ matrix.ver.cv }}
cp ${{ env.BUILD_OPTIONS }} opencv-${{ matrix.ver.cv }}
- name: Host - update
run: sudo apt-get update
- name: Host - Install host qemu-static
run: sudo apt-get install -y qemu binfmt-support qemu-user-static
- name: Host - Docker multiarch bootstrap
run: sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: deploy cmake
run: |
wget https://github.com/benjaminwan/CmakeBuilder/releases/download/${{ matrix.ver.cmake }}/cmake-${{ matrix.ver.cmake }}-${{ matrix.os_name }}-${{ matrix.list.os_ver }}-${{ matrix.arch }}.7z -O cmake-${{ matrix.ver.cmake }}.7z
7z x cmake-${{ matrix.ver.cmake }}.7z -aoa
rm cmake-${{ matrix.ver.cmake }}.7z
- name: deploy python
run: |
wget https://github.com/benjaminwan/PythonBuilder/releases/download/${{ matrix.ver.python }}/python-${{ matrix.ver.python }}-${{ matrix.os_name }}-${{ matrix.list.os_ver }}-${{ matrix.arch }}.7z -O python-${{ matrix.ver.python }}.7z
7z x python-${{ matrix.ver.python }}.7z -aoa
rm python-${{ matrix.ver.python }}.7z
- name: deploy ant
run: |
wget https://dlcdn.apache.org/ant/binaries/apache-ant-${{ matrix.ver.ant }}-bin.tar.gz -O apache-ant-${{ matrix.ver.ant }}.tar.gz
tar -xf apache-ant-${{ matrix.ver.ant }}.tar.gz
rm apache-ant-${{ matrix.ver.ant }}.tar.gz
- name: Host - Create Docker template env file
run: |
echo "PATH=/root/cmake-${{ matrix.ver.cmake }}/bin:/root/python-${{ matrix.ver.python }}/bin:/root/apache-ant-${{ matrix.ver.ant }}/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" > env.custom
echo "DEBIAN_FRONTEND=noninteractive" >> env.custom
echo "TZ=Etc/UTC" >> env.custom
- name: Host - Create docker container
run: docker run --name ${{ matrix.os_name }} --env-file env.custom --platform linux/${{ matrix.arch }} -it -d -w /root -v ${{ github.workspace }}:/root ${{ matrix.os_name }}:${{ matrix.list.os_id }}
- name: Docker - apt-get update
run: docker exec --env-file env.custom -w /root ${{ matrix.os_name }} apt-get update
- name: Docker - install build deps
run: docker exec --env-file env.custom -w /root ${{ matrix.os_name }} apt-get install -y build-essential git software-properties-common
- name: Docker - install jdk
run: |
docker exec --env-file env.custom -w /root ${{ matrix.os_name }} add-apt-repository -y ppa:openjdk-r/ppa
docker exec --env-file env.custom -w /root ${{ matrix.os_name }} apt-get update
docker exec --env-file env.custom -w /root ${{ matrix.os_name }} apt-get -y install ${{ matrix.ver.jdk }}
docker exec --env-file env.custom -w /root ${{ matrix.os_name }} java -version
JAVA_DIR=$(docker exec ${{ matrix.os_name }} readlink -f /usr/bin/javac | sed "s:/bin/javac::")
echo "$JAVA_DIR"
echo "JAVA_HOME=$JAVA_DIR" >> env.custom
echo "JAVA_INCLUDE_PATH=$JAVA_DIR/include" >> env.custom
- name: Docker - build
run: |
docker exec --env-file env.custom -w /root ${{ matrix.os_name }} git config --global --add safe.directory "*"
docker exec --env-file env.custom -w /root/opencv-${{ matrix.ver.cv }} ${{ matrix.os_name }} chmod a+x ${{ env.BUILD_SCRIPT }}
docker exec --env-file env.custom -w /root/opencv-${{ matrix.ver.cv }} ${{ matrix.os_name }} ./${{ env.BUILD_SCRIPT }} -n '${{ matrix.arch }}'
# install文件夹改名linux,并使用7z压缩
- name: 7zip
run: |
cp -r opencv-${{ matrix.ver.cv }}/build-Release-${{ matrix.arch }}/install linux
7z a ${{ env.PKG_NAME }}.7z linux
rm -r -f linux
- name: Docker - build
run: |
docker exec --env-file env.custom -w /root/opencv-${{ matrix.ver.cv }} ${{ matrix.os_name }} chmod a+x ${{ env.BUILD_SCRIPT }}
docker exec --env-file env.custom -w /root/opencv-${{ matrix.ver.cv }} ${{ matrix.os_name }} ./${{ env.BUILD_SCRIPT }} -n '${{ matrix.arch }}' -j
- name: 7zip java
run: |
cp -r opencv-${{ matrix.ver.cv }}/build-Release-${{ matrix.arch }}/install/share/java/opencv4 ${{ env.JAVA_PKG_NAME }}
7z a ${{ env.JAVA_PKG_NAME }}.7z ${{ env.JAVA_PKG_NAME }}
# 上传artifact
# - name: upload
# uses: actions/upload-artifact@v4
# with:
# name: ${{ env.PKG_NAME }}
# path: ${{ env.PKG_NAME }}.7z
# - name: upload
# uses: actions/upload-artifact@v4
# with:
# name: ${{ env.JAVA_PKG_NAME }}
# path: ${{ env.JAVA_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: 'opencv-*.7z'
allowUpdates: true
artifactContentType: application/x-7z-compressed
token: ${{ secrets.GITHUB_TOKEN }}