Skip to content

Commit 81267c6

Browse files
authored
chore: gha cleanup (#740)
1 parent ce169e4 commit 81267c6

File tree

3 files changed

+26
-149
lines changed

3 files changed

+26
-149
lines changed

.github/workflows/build-develop.yml

Lines changed: 13 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,11 @@ env:
1919

2020
jobs:
2121
unit-tests-mac:
22-
# The CMake configure and build commands are platform agnostic and should work equally
23-
# well on Windows or Mac. You can convert this to a matrix build if you need
24-
# cross-platform coverage.
25-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
26-
2722
runs-on: macos-latest
2823
steps:
2924
- uses: actions/checkout@v4
3025

3126
- name: Create Build Environment
32-
# Some projects don't allow in-source building, so create a separate build directory
33-
# We'll use this as our working directory for all subsequent commands
3427
run: cmake -E make_directory ${{github.workspace}}/build
3528

3629
- name: Python Setup
@@ -55,34 +48,21 @@ jobs:
5548
restore-keys: conan-${{ runner.os }}-
5649

5750
- name: Configure CMake
58-
# Use a bash shell so we can use the same syntax for environment variable
59-
# access regardless of the host operating system
6051
shell: bash
6152
working-directory: ${{github.workspace}}/build
62-
# Note the current convention is to use the -S and -B options here to specify source
63-
# and build directories, but this is only available with CMake 3.13 and higher.
64-
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
6553
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
6654

6755
- name: Build
6856
working-directory: ${{github.workspace}}/build
6957
shell: bash
70-
# Execute the build. You can specify a specific target with "--target <NAME>"
71-
run: cmake --build . --config $BUILD_TYPE -- -j 2
58+
run: cmake --build . --config $BUILD_TYPE -- -j 4
7259

7360
- name: Test
7461
working-directory: ${{github.workspace}}/build
7562
shell: bash
76-
# Execute tests defined by the CMake configuration.
77-
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
7863
run: ctest -C $BUILD_TYPE
7964

8065
unit-tests-linux:
81-
# The CMake configure and build commands are platform agnostic and should work equally
82-
# well on Windows or Mac. You can convert this to a matrix build if you need
83-
# cross-platform coverage.
84-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
85-
8666
runs-on: ubuntu-latest
8767
outputs:
8868
version_number: ${{ env.VERSION }}
@@ -91,8 +71,6 @@ jobs:
9171
- uses: actions/checkout@v4
9272

9373
- name: Create Build Environment
94-
# Some projects don't allow in-source building, so create a separate build directory
95-
# We'll use this as our working directory for all subsequent commands
9674
run: cmake -E make_directory ${{github.workspace}}/build
9775

9876
- name: Get Conan
@@ -101,11 +79,6 @@ jobs:
10179
with:
10280
version: 1.66.0
10381

104-
- name: linux package install
105-
run: |
106-
sudo apt-get update
107-
sudo apt-get install --yes --no-install-recommends jq
108-
10982
- name: Setup Conan Cache
11083
uses: actions/cache@v4
11184
with:
@@ -114,50 +87,34 @@ jobs:
11487
restore-keys: conan-${{ runner.os }}-
11588

11689
- name: Configure CMake
117-
# Use a bash shell so we can use the same syntax for environment variable
118-
# access regardless of the host operating system
11990
shell: bash
12091
working-directory: ${{github.workspace}}/build
121-
# Note the current convention is to use the -S and -B options here to specify source
122-
# and build directories, but this is only available with CMake 3.13 and higher.
123-
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
12492
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
12593

12694
- name: Get VERSION
12795
id: build
12896
run: |
12997
echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV
130-
echo "::set-output name=version::$(cat ${{github.workspace}}/build/VERSION)"
13198
echo "COMMIT=`git rev-parse --short HEAD`" >> $GITHUB_ENV
13299
133100
- name: Build
134101
working-directory: ${{github.workspace}}/build
135102
shell: bash
136-
# Execute the build. You can specify a specific target with "--target <NAME>"
137-
run: cmake --build . --config $BUILD_TYPE -- -j 2
103+
run: cmake --build . --config $BUILD_TYPE -- -j 4
138104

139105
- name: Test
140106
working-directory: ${{github.workspace}}/build
141107
shell: bash
142-
# Execute tests defined by the CMake configuration.
143-
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
144108
run: sudo ctest -C $BUILD_TYPE
145109

146110
build-win64:
147-
# The CMake configure and build commands are platform agnostic and should work equally
148-
# well on Windows or Mac. You can convert this to a matrix build if you need
149-
# cross-platform coverage.
150-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
151-
152111
runs-on: windows-2019
153112
outputs:
154113
version_number: ${{ env.VERSION }}
155114
steps:
156115
- uses: actions/checkout@v4
157116

158117
- name: Create Build Environment
159-
# Some projects don't allow in-source building, so create a separate build directory
160-
# We'll use this as our working directory for all subsequent commands
161118
run: cmake -E make_directory ${{github.workspace}}\build
162119

163120
- name: Get Conan
@@ -174,13 +131,8 @@ jobs:
174131
restore-keys: conan-${{ runner.os }}-
175132

176133
- name: Configure CMake
177-
# Use a bash shell so we can use the same syntax for environment variable
178-
# access regardless of the host operating system
179134
shell: bash
180135
working-directory: ${{github.workspace}}\build
181-
# Note the current convention is to use the -S and -B options here to specify source
182-
# and build directories, but this is only available with CMake 3.13 and higher.
183-
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
184136
run: PKG_CONFIG_PATH=${{github.workspace}}\local\lib\pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
185137

186138
- name: Get VERSION
@@ -193,7 +145,6 @@ jobs:
193145
- name: Build
194146
working-directory: ${{github.workspace}}\build
195147
shell: bash
196-
# Execute the build. You can specify a specific target with "--target <NAME>"
197148
run: cmake --build . --config $BUILD_TYPE -- -m
198149

199150
# TODO: Fix unit tests for windows platform
@@ -310,13 +261,9 @@ jobs:
310261
id: build
311262
run: |
312263
echo "VERSION=${{needs.unit-tests-linux.outputs.version_number}}" >> $GITHUB_ENV
313-
echo "::set-output name=version::$(echo env.VERSION)"
314264
315265
- name: Generate ref tag (develop)
316-
run: |
317-
echo "REF_TAG=latest-develop" >> $GITHUB_ENV
318-
echo "PRERELEASE=true" >> $GITHUB_ENV
319-
echo "DRAFT=false" >> $GITHUB_ENV
266+
run: echo "REF_TAG=latest-develop" >> $GITHUB_ENV
320267

321268
- name: Debug ref tag
322269
run: echo ${{ env.REF_TAG }}
@@ -353,18 +300,12 @@ jobs:
353300
context: .
354301
file: ./docker/Dockerfile.crashhandler
355302
platforms: linux/amd64
356-
tags: ${{ env.IMAGE_NAME }}:${{ needs.unit-tests-linux.outputs.version_number }} , ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
303+
push: true
304+
tags: |
305+
${{ env.IMAGE_NAME }}:${{ needs.unit-tests-linux.outputs.version_number }}
306+
${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
357307
outputs: type=docker,dest=/tmp/amd64.tar
358308

359-
- name: Load image
360-
env:
361-
IMAGE_NAME: netboxlabs/pktvisor
362-
run: |
363-
docker load --input /tmp/amd64.tar
364-
docker image ls -a
365-
docker push ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
366-
docker push ${{ env.IMAGE_NAME }}:${{ needs.unit-tests-linux.outputs.version_number }}
367-
368309
build-app-image-x64:
369310
needs: [ package-amd64 ]
370311
runs-on: ubuntu-latest
@@ -388,20 +329,15 @@ jobs:
388329

389330
- name: Get VERSION
390331
id: build
391-
run: |
392-
echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV
393-
echo "::set-output name=version::$(cat ${{github.workspace}}/build/VERSION)"
332+
run: echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV
394333

395334
- name: Debug version
396335
run: |
397336
echo ${{ env.VERSION }}
398-
echo ${{ steps.build.outputs.version }}
399337
400338
- name: Generate ref tag (develop)
401339
run: |
402340
echo "REF_TAG=latest-develop" >> $GITHUB_ENV
403-
echo "PRERELEASE=true" >> $GITHUB_ENV
404-
echo "DRAFT=false" >> $GITHUB_ENV
405341
406342
- name: Prepare version file
407343
run: |
@@ -498,10 +434,7 @@ jobs:
498434
run: ls -lha .
499435

500436
- name: Generate ref tag (develop)
501-
run: |
502-
echo "REF_TAG=latest-develop" >> $GITHUB_ENV
503-
echo "PRERELEASE=true" >> $GITHUB_ENV
504-
echo "DRAFT=false" >> $GITHUB_ENV
437+
run: echo "REF_TAG=latest-develop" >> $GITHUB_ENV
505438

506439
- name: Debug ref tag
507440
run: echo ${{ env.REF_TAG }}
@@ -539,14 +472,8 @@ jobs:
539472
context: .
540473
file: ./docker/Dockerfile.crashhandler
541474
platforms: linux/arm64
542-
tags: ${{ env.IMAGE_NAME }}:${{ needs.unit-tests-linux.outputs.version_number }} , ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
475+
push: true
476+
tags: |
477+
${{ env.IMAGE_NAME }}:${{ needs.unit-tests-linux.outputs.version_number }}
478+
${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
543479
outputs: type=docker,dest=/tmp/arm64.tar
544-
545-
- name: Load image
546-
env:
547-
IMAGE_NAME: netboxlabs/pktvisor
548-
run: |
549-
docker load --input /tmp/arm64.tar
550-
docker image ls -a
551-
docker push ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
552-
docker push ${{ env.IMAGE_NAME }}:${{ needs.unit-tests-linux.outputs.version_number }}

.github/workflows/build-release.yml

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ jobs:
4141
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
4242
restore-keys: conan-${{ runner.os }}-
4343

44-
- name: linux package install
45-
if: matrix.os == 'ubuntu-latest'
46-
run: |
47-
sudo apt-get update
48-
sudo apt-get install --yes --no-install-recommends jq
49-
5044
- name: Configure CMake
5145
shell: bash
5246
working-directory: ${{github.workspace}}/build
@@ -55,7 +49,7 @@ jobs:
5549
- name: Build
5650
working-directory: ${{github.workspace}}/build
5751
shell: bash
58-
run: cmake --build . --config $BUILD_TYPE -- -j 2
52+
run: cmake --build . --config $BUILD_TYPE -- -j 4
5953

6054
- name: Test
6155
working-directory: ${{github.workspace}}/build
@@ -93,16 +87,12 @@ jobs:
9387

9488
- name: Get VERSION
9589
id: build
96-
run: |
97-
echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV
98-
echo "::set-output name=version::$(cat ${{github.workspace}}/build/VERSION)"
90+
run: echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV
9991

10092
- name: Get branch name
10193
id: branch
10294
shell: bash
103-
run: |
104-
echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
105-
echo "::set-output name=name::$(echo ${GITHUB_REF#refs/heads/} | tr / -)"
95+
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
10696

10797
- name: Persist to workspace
10898
uses: actions/upload-artifact@v4
@@ -171,20 +161,13 @@ jobs:
171161
prerelease: false
172162

173163
build-win64:
174-
# The CMake configure and build commands are platform agnostic and should work equally
175-
# well on Windows or Mac. You can convert this to a matrix build if you need
176-
# cross-platform coverage.
177-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
178-
179164
runs-on: windows-2019
180165
outputs:
181166
version_number: ${{ env.VERSION }}
182167
steps:
183168
- uses: actions/checkout@v4
184169

185170
- name: Create Build Environment
186-
# Some projects don't allow in-source building, so create a separate build directory
187-
# We'll use this as our working directory for all subsequent commands
188171
run: cmake -E make_directory ${{github.workspace}}\build
189172

190173
- name: Get Conan
@@ -201,13 +184,8 @@ jobs:
201184
restore-keys: conan-${{ runner.os }}-
202185

203186
- name: Configure CMake
204-
# Use a bash shell so we can use the same syntax for environment variable
205-
# access regardless of the host operating system
206187
shell: bash
207188
working-directory: ${{github.workspace}}\build
208-
# Note the current convention is to use the -S and -B options here to specify source
209-
# and build directories, but this is only available with CMake 3.13 and higher.
210-
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
211189
run: PKG_CONFIG_PATH=${{github.workspace}}\local\lib\pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
212190

213191
- name: Get VERSION
@@ -353,8 +331,7 @@ jobs:
353331
run: echo ${{ env.BRANCH_NAME }}
354332

355333
- name: Get VERSION
356-
run: |
357-
echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV
334+
run: echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV
358335

359336
- name: Debug version
360337
run: echo ${{ env.VERSION }}
@@ -363,8 +340,6 @@ jobs:
363340
if: ${{ env.BRANCH_NAME == 'master' }}
364341
run: |
365342
echo "REF_TAG=latest" >> $GITHUB_ENV
366-
echo "PRERELEASE=false" >> $GITHUB_ENV
367-
echo "DRAFT=true" >> $GITHUB_ENV
368343
369344
- name: Debug ref tag
370345
run: echo ${{ env.REF_TAG }}
@@ -474,18 +449,14 @@ jobs:
474449
run: echo ${{ env.BRANCH_NAME }}
475450

476451
- name: Get VERSION
477-
run: |
478-
echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV
452+
run: echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV
479453

480454
- name: Debug version
481455
run: echo ${{ env.VERSION }}
482456

483457
- name: Generate ref tag (master)
484458
if: ${{ env.BRANCH_NAME == 'master' }}
485-
run: |
486-
echo "REF_TAG=latest" >> $GITHUB_ENV
487-
echo "PRERELEASE=false" >> $GITHUB_ENV
488-
echo "DRAFT=true" >> $GITHUB_ENV
459+
run: echo "REF_TAG=latest" >> $GITHUB_ENV
489460

490461
- name: Debug ref tag
491462
run: echo ${{ env.REF_TAG }}

0 commit comments

Comments
 (0)