-
Notifications
You must be signed in to change notification settings - Fork 0
204 lines (170 loc) · 6.5 KB
/
release.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# This is a basic workflow to help you get started with Actions
name: test and release
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
tags-ignore:
- '*-release'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test:
name: test for release
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-20.04, ubuntu-22.04 ]
env:
CC: gcc-10
CXX: g++-10
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: checkout code
uses: actions/checkout@v3
- name: hardwares - cpu
run: nproc; cat /proc/cpuinfo
- name: Install ccache, check gcc version
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update && sudo apt-get install -y ccache
gcc --version
g++ --version
- name: prepare libopencv ccache
run: |
sudo apt-get install libopencv-dev ccache
- name: Use cmake
run: cmake --version
- name: cmake prepare for compile
run: cmake -S . -B ./CMAKE_DEBUG_PATH -DCMAKE_BUILD_TYPE=DEBUG
- name: cmake compile lab_00
working-directory: ./CMAKE_DEBUG_PATH/lab_00
run: cmake --build . --config DEBUG --parallel
- name: cmake compile algorithm/2021F
working-directory: ./CMAKE_DEBUG_PATH/algorithm/2021F
run: cmake --build . --config DEBUG --parallel
- name: cmake compile algorithm/matrix
working-directory: ./CMAKE_DEBUG_PATH/algorithm/matrix
run: cmake --build . --config DEBUG --parallel
- name: cmake compile algorithm
working-directory: ./CMAKE_DEBUG_PATH/algorithm/
run: cmake --build .
- name: cmake compile basic
working-directory: ./CMAKE_DEBUG_PATH/basic
run: cmake --build . --config DEBUG --parallel
- name: cmake compile
working-directory: ./CMAKE_DEBUG_PATH
run: cmake --build . --config DEBUG --parallel
- name: cmake test
working-directory: ./CMAKE_DEBUG_PATH
run: ctest --parallel $(nproc)
# This workflow contains a single job called "build"
build:
name: publish release
if: github.repository == 'Certseeds/CS203_DSAA_template'
needs: test
# The type of runner that the job will run on
runs-on: ubuntu-22.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: checkout code
uses: actions/checkout@v3
- name: Branch name
id: branch_name
run: |
echo "SOURCE_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
echo "SOURCE_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: tag name output
run: |
echo ${SOURCE_NAME};echo ${SOURCE_BRANCH};echo ${SOURCE_TAG}
env:
SOURCE_NAME: ${{ steps.branch_name.outputs.SOURCE_NAME }}
SOURCE_BRANCH: ${{ steps.branch_name.outputs.SOURCE_BRANCH }}
SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }}
- name: prepare libopencv
run: |
sudo apt-get update && sudo apt-get install libopencv-dev
# ensure the path and files of project
- name: ensure the path and files of project
run: sudo apt-get install tree; tree; mkdir -p ./cmake_build_release
- name: cmake install dependencies
run: |
cmake -S . -B ./cmake_build_release -DCMAKE_BUILD_TYPE=Debug
rm -rf ./cmake_build_release
- name: move cmake-fetchcontent to folder
working-directory: ./third_party
run: |
rm ./CMakeLists.txt
mv ./CMakeLists.release.txt ./CMakeLists.txt
- name: run script
working-directory: ./script
run: python3 file_template.py
- name: zip the packet
working-directory: ./../
run: |
zip -r script_no_need.zip ./CS203_DSAA_template -x "*/.git/*"
tree
- name: release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ./../script_no_need.zip
prerelease: false
generate_release_notes: true
- name: tree
run: tree
release-branch:
name: publish release-branch
if: github.repository == 'Certseeds/CS203_DSAA_template'
needs: [ test, build ]
# The type of runner that the job will run on
runs-on: ubuntu-22.04
env:
GCC_V: 11
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: checkout code
uses: actions/checkout@v3
- name: Branch name
id: branch_name
run: |
echo "SOURCE_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: tag name output
run: |
echo ${SOURCE_NAME};
env:
SOURCE_NAME: ${{ steps.branch_name.outputs.SOURCE_NAME }}
- name: git operations
run: |
git config --global user.name 'Certseeds'
git config --global user.email '[email protected]'
git checkout -b release
mkdir cmake_build_release
- name: prepare libopencv
run: |
sudo apt-get update && sudo apt-get install libopencv-dev
- name: cmake install dependencies
run: |
cmake -S . -B ./cmake_build_release -DCMAKE_BUILD_TYPE=Debug
rm -rf ./cmake_build_release
- name: move cmake-fetchcontent to folder
working-directory: ./third_party
run: |
echo '**/.github/*' > ./.gitignore
rm ./CMakeLists.txt
mv ./CMakeLists.release.txt ./CMakeLists.txt
git add .
git commit -am "dependencies: add dependencies to release branch"
- name: run script
working-directory: ./script
run: python3 file_template.py
- name: git operations
working-directory: ./
run: |
git add .
git commit -am "release ${{ steps.branch_name.outputs.SOURCE_NAME }}"
git push --set-upstream origin release --force