diff --git a/.github/actions/build-go/action.yml b/.github/actions/build-go/action.yml index 8501d8e5c..d952eee56 100644 --- a/.github/actions/build-go/action.yml +++ b/.github/actions/build-go/action.yml @@ -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' - \ No newline at end of file + diff --git a/.github/actions/build-go/entrypoint.sh b/.github/actions/build-go/entrypoint.sh index bd4054b2c..f40cc59d1 100644 --- a/.github/actions/build-go/entrypoint.sh +++ b/.github/actions/build-go/entrypoint.sh @@ -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() { @@ -15,4 +15,4 @@ function copy() { } build -copy \ No newline at end of file +copy diff --git a/.github/workflows/build-develop.yml b/.github/workflows/build-develop.yml index 6f6700e05..a6485ac31 100644 --- a/.github/workflows/build-develop.yml +++ b/.github/workflows/build-develop.yml @@ -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. @@ -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 @@ -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 ] diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 74cce3459..8e9c8ff8e 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -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 " + 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 ]