Skip to content
Merged
7 changes: 6 additions & 1 deletion .github/actions/build-go/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ inputs:
description: "Dockerfile used to build the image"
required: true
default: "./Dockerfile"

goos:
description: "OS for cross-build"
required: false
default: "linux"

runs:
using: 'docker'
image: 'Dockerfile'


4 changes: 2 additions & 2 deletions .github/actions/build-go/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function build() {
# Copying this from previous build (cpp)
cp -rf ./version.go /src/pkg/client/version.go
cd /src
go build -o pktvisor-cli cmd/pktvisor-cli/main.go
GOOS=$INPUT_GOOS go build -o pktvisor-cli cmd/pktvisor-cli/main.go
}

function copy() {
Expand All @@ -15,4 +15,4 @@ function copy() {
}

build
copy
copy
64 changes: 63 additions & 1 deletion .github/workflows/build-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
- name: Cache conan packages
run: CONAN_USER_HOME=${{github.workspace}}/build/conan_home conan upload "*" --all -r ns1labs -c

build-windows:
build-win64:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
Expand Down Expand Up @@ -179,6 +179,23 @@ jobs:
# # Execute tests defined by the CMake configuration.
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ctest -C $BUILD_TYPE

- name: Debug artifacts
shell: pwsh
run: |
Get-ChildItem -Force ${{github.workspace}}
Get-ChildItem -Force ${{github.workspace}}\build
Get-ChildItem -Force ${{github.workspace}}\build\bin

- name: Persist to workspace
uses: actions/upload-artifact@v2
with:
name: windows-build
path: |
${{github.workspace}}\build\bin\pktvisor-reader.exe
${{github.workspace}}\build\bin\pktvisord.exe
${{github.workspace}}\golang\pkg\client\version.go
retention-days: 1

- name: Login to ns1labs conan
shell: pwsh
Expand All @@ -191,6 +208,51 @@ jobs:
run: |
$env:CONAN_USER_HOME = "${{github.workspace}}\build\conan_home"
conan upload "*" --all -r ns1labs -c

build-cli-win64:
needs: [ build-win64 ]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Attach to workspace
uses: actions/download-artifact@v3
with:
name: windows-build

- name: Debug artifacts
shell: bash
run: |
ls -lha

- name: Debug artifacts
shell: bash
run: |
ls -lha
mv src pktvisor-src
cp -rpf golang/pkg/client/version.go .
ls -lha

- name: Build pktvisor-cli
uses: ./.github/actions/build-go
with:
context: "."
goos: windows
file: "./Dockerfile"

- name: Debug artifacts
shell: bash
run: |
mv ./pktvisor-cli pktvisor-cli.exe
mv ./build/bin/pktvisord.exe ./pktvisord.exe
mv ./build/bin/pktvisor-reader.exe ./pktvisor-reader.exe
ls -lha

- name: compacting windows binary
run: |
zip pktvisor-win64.zip pktvisor-cli.exe pktvisor-reader.exe pktvisord.exe
ls -lha

package-amd64:
needs: [ unit-tests-linux ]
Expand Down
129 changes: 129 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,135 @@ jobs:
path: |
.github/hosted-runner/amd64/terraform.tfstate
retention-days: 1

build-win64:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix

runs-on: windows-2019
outputs:
version_number: ${{ env.VERSION }}
steps:
- uses: actions/checkout@v2

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

- name: Get Conan
# You may pin to the exact commit or the version.
# uses: turtlebrowser/get-conan@4dc7e6dd45c8b1e02e909979d7cfc5ebba6ddbe2
uses: turtlebrowser/get-conan@v1.0

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

- name: Get VERSION
shell: pwsh
id: build
run: |
$text = Get-Content ${{github.workspace}}\build\VERSION -Raw
echo "VERSION=$text" >> $env:GITHUB_ENV

- name: Build
working-directory: ${{github.workspace}}\build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE -- -m

# TODO: Fix unit tests for windows platform
#- name: Test
# working-directory: ${{github.workspace}}/build
# shell: bash
# # Execute tests defined by the CMake configuration.
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ctest -C $BUILD_TYPE

- name: Debug artifacts
shell: pwsh
run: |
Get-ChildItem -Force ${{github.workspace}}
Get-ChildItem -Force ${{github.workspace}}\build
Get-ChildItem -Force ${{github.workspace}}\build\bin

- name: Persist to workspace
uses: actions/upload-artifact@v2
with:
name: windows-build
path: |
${{github.workspace}}\build\bin\pktvisor-reader.exe
${{github.workspace}}\build\bin\pktvisord.exe
${{github.workspace}}\golang\pkg\client\version.go
retention-days: 1

- name: Login to ns1labs conan
shell: pwsh
run: |
$env:CONAN_USER_HOME = "${{github.workspace}}\build\conan_home"
conan user -p ${{ secrets.CONAN_LABS_PASSWORD }} -r ns1labs ${{ secrets.CONAN_LABS_USERNAME }}

- name: Cache conan packages
shell: pwsh
run: |
$env:CONAN_USER_HOME = "${{github.workspace}}\build\conan_home"
conan upload "*" --all -r ns1labs -c

build-cli-win64:
needs: [ build-win64 ]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Attach to workspace
uses: actions/download-artifact@v3
with:
name: windows-build

- name: Debug artifacts
shell: bash
run: |
ls -lha

- name: Debug artifacts
shell: bash
run: |
mv src pktvisor-src
cp -rpf golang/pkg/client/version.go .

- name: Build pktvisor-cli
uses: ./.github/actions/build-go
with:
context: "."
goos: windows
file: "./Dockerfile"

- name: Debug artifacts
shell: bash
run: |
mv ./pktvisor-cli pktvisor-cli.exe
mv ./build/bin/pktvisord.exe ./pktvisord.exe
mv ./build/bin/pktvisor-reader.exe ./pktvisor-reader.exe

- name: compacting windows binary
run: |
zip pktvisor-win64.zip pktvisor-cli.exe pktvisor-reader.exe pktvisord.exe

- name: Upload win64 binary to latest release
shell: bash
run: |
chmod a+x ./docker/upload-gh-asset.sh
./docker/upload-gh-asset.sh github_api_token=${{ secrets.BOT_TOKEN }} owner=ns1labs repo=pktvisor tag=LATEST filename=./pktvisor-win64.zip

package-arm64:
needs: [ spinup-arm64-runner ]
Expand Down