-
Notifications
You must be signed in to change notification settings - Fork 19
185 lines (156 loc) · 7.38 KB
/
linux.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: ubuntu
on:
workflow_dispatch:
push:
tags:
- '*'
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:
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@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
run: |
cp build-opencv4-linux.sh opencv-${{ matrix.ver.cv }}
cp build-opencv4-linux-java.sh opencv-${{ matrix.ver.cv }}
cp opencv4_cmake_options.txt 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
- 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
- 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
- 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 build-opencv4-linux.sh
docker exec --env-file env.custom -w /root/opencv-${{ matrix.ver.cv }} ${{ matrix.os_name }} ./build-opencv4-linux.sh "${{ matrix.arch }}"
# install文件夹改名linux,并使用7z压缩
- name: 7zip
run: |
cp -r opencv-${{ matrix.ver.cv }}/build-Release/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 build-opencv4-linux-java.sh
docker exec --env-file env.custom -w /root/opencv-${{ matrix.ver.cv }} ${{ matrix.os_name }} ./build-opencv4-linux-java.sh "${{ matrix.arch }}"
- name: 7zip java
run: |
cp -r opencv-${{ matrix.ver.cv }}/build-Release/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@v3
with:
name: ${{ env.PKG_NAME }}
path: ${{ env.PKG_NAME }}.7z
# 上传artifact
- name: upload
uses: actions/upload-artifact@v3
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: ${{ env.PKG_NAME }}.7z, ${{ env.JAVA_PKG_NAME }}.7z
allowUpdates: true
artifactContentType: application/x-7z-compressed
token: ${{ secrets.GITHUB_TOKEN }}