From 9b04b74597836508172dc382201b063a310f41a3 Mon Sep 17 00:00:00 2001 From: Ofek Shaked <32914127+oshaked1@users.noreply.github.com> Date: Sun, 2 Jun 2024 18:16:15 +0300 Subject: [PATCH] Added workflow for creating a release build (#1) --- .../install-wireshark-headers-unix/action.yml | 22 +++ .../action.yml | 17 +++ .github/workflows/release.yml | 132 ++++++++++++++++++ scripts/make_cmake.bat | 11 +- 4 files changed, 175 insertions(+), 7 deletions(-) create mode 100644 .github/actions/install-wireshark-headers-unix/action.yml create mode 100644 .github/actions/install-wireshark-headers-windows/action.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/actions/install-wireshark-headers-unix/action.yml b/.github/actions/install-wireshark-headers-unix/action.yml new file mode 100644 index 0000000..6223d3c --- /dev/null +++ b/.github/actions/install-wireshark-headers-unix/action.yml @@ -0,0 +1,22 @@ +name: Install Wireshark headers (Unix) +runs: + using: 'composite' + steps: + - name: Configure Wireshark + run: | + mkdir wireshark/build + cmake -G Ninja -B wireshark/build -S wireshark -DENABLE_CCACHE=Yes + shell: bash + - name: Install headers + id: install_headers + run: sudo ninja -C wireshark/build install-headers + continue-on-error: true + shell: bash + # Install headers is not available in older versions, use the full installation instead + - name: Install Wireshark + id: install_wireshark + if: ${{ steps.install_headers.outcome == 'failure' }} + run: | + ninja -C wireshark/build -j$(nproc) + sudo ninja -C wireshark/build install + shell: bash \ No newline at end of file diff --git a/.github/actions/install-wireshark-headers-windows/action.yml b/.github/actions/install-wireshark-headers-windows/action.yml new file mode 100644 index 0000000..3c6d8f6 --- /dev/null +++ b/.github/actions/install-wireshark-headers-windows/action.yml @@ -0,0 +1,17 @@ +name: Install Wireshark headers (Windows) +runs: + using: 'composite' + steps: + - name: Configure Wireshark + run: | + mkdir build + cd build + set WIRESHARK_BASE_DIR=..\ + set WIRESHARK_QT6_PREFIX_PATH=$QT_ROOT_DIR + cmake -G "Visual Studio 17 2022" -A x64 ..\wireshark + shell: cmd + - name: Install headers + run: | + cd build + msbuild install-headers.vcxproj + shell: cmd \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d12b291 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,132 @@ +name: Release + +on: + workflow_dispatch: + inputs: + tag: + description: The tag to be released, e.g. v0.1.0 + required: true + release_body: + description: Description of the release + required: false + +jobs: + create-release: + name: Create release + runs-on: ubuntu-latest + steps: + - name: Create GitHub release + id: create-release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.event.inputs.tag }} + release_name: ${{ github.event.inputs.tag }} + body: ${{ github.event.inputs.release_body }} + draft: true + prerelease: true + outputs: + upload_url: ${{ steps.create-release.outputs.upload_url }} + + build: + name: Build + runs-on: ${{ matrix.os }} + needs: create-release + strategy: + matrix: + # macos-14 is ARM64, macos-13 is x86-64 + #os: [ubuntu-latest, macos-14, macos-13, windows-latest] + os: [windows-latest] + wireshark_version: [wireshark-4.2.5] + #include: + # Ubuntu 22.04 Wireshark package version + # - os: ubuntu-latest + # wireshark_version: wireshark-3.6.2 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.tag }} + + - name: Clone Wireshark + run: git clone --depth 1 --branch ${{ matrix.wireshark_version }} https://github.com/wireshark/wireshark + + - name: Install dependencies (Ubuntu) + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt update + sudo apt install -y ninja-build + sudo wireshark/tools/debian-setup.sh + + - name: Install dependencies (Macos) + if: matrix.os == 'macos-14' || matrix.os == 'macos-13' + run: wireshark/tools/macos-setup-brew.sh + + - name: Install dependencies (Windows) + if: matrix.os == 'windows-latest' + run: choco install -y winflexbison3 + + - name: Install Qt (Windows) + if: matrix.os == 'windows-latest' + uses: jurplel/install-qt-action@v4 + with: + version: 6.5 + modules: qt5compat + + - name: Add msbuild to PATH (Windows) + if: matrix.os == 'windows-latest' + uses: microsoft/setup-msbuild@v2 + + - name: Install Wireshark headers (Unix) + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14' || matrix.os == 'macos-13' + uses: ./.github/actions/install-wireshark-headers-unix + + - name: Install Wireshark headers (Windows) + if: matrix.os == 'windows-latest' + uses: ./.github/actions/install-wireshark-headers-windows + + - name: Build Traceeshark (Unix) + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14' || matrix.os == 'macos-13' + run: | + make cmake + make + + - name: Build Traceeshark (Windows) + if: matrix.os == 'windows-latest' + run: | + set WIRESHARK_BASE_DIR=%CD% + set WIRESHARK_QT6_PREFIX_PATH=$QT_ROOT_DIR + call scripts\make_cmake.bat + call scripts\make.bat + shell: cmd + + - name: Create distribution archive (Unix) + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14' || matrix.os == 'macos-13' + run: | + make dist + DIST_PATH=$(ls dist/*.zip | head -n 1) + DIST_NAME=$(basename $DIST_PATH) + echo "dist_archive=$DIST_NAME" >> $GITHUB_ENV + + - name: Create distribution archive (Windows) + if: matrix.os == 'windows-latest' + run: | + cmd /C scripts\make_dist.bat + $DIST_PATH = Get-ChildItem -Path "dist/*.zip" | Select-Object -First 1 + $DIST_NAME = $DIST_PATH.Name + echo $DIST_NAME + echo "dist_archive=$DIST_NAME" >> $GITHUB_ENV + echo $GITHUB_ENV + shell: powershell + + - name: Upload distribution archive + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_path: dist/${{ env.dist_archive }} + asset_name: ${{ env.dist_archive }} + asset_content_type: application/zip diff --git a/scripts/make_cmake.bat b/scripts/make_cmake.bat index 40c6aae..b4fcbf3 100644 --- a/scripts/make_cmake.bat +++ b/scripts/make_cmake.bat @@ -5,17 +5,14 @@ FOR /F "tokens=*" %%i in ('type .env') do SET %%i rmdir /S /Q wireshark\plugins\epan\tracee-event rmdir /S /Q wireshark\plugins\epan\tracee-network-capture rmdir /S /Q wireshark\plugins\wiretap\tracee-json -mkdir wireshark\plugins\epan\tracee-event -mkdir wireshark\plugins\epan\tracee-network-capture -mkdir wireshark\plugins\wiretap\tracee-json -copy /Y plugins\epan\tracee-event wireshark\plugins\epan\tracee-event -copy /Y plugins\epan\tracee-network-capture wireshark\plugins\epan\tracee-network-capture -copy /Y plugins\wiretap\tracee-json wireshark\plugins\wiretap\tracee-json +del /Q wireshark\plugins\epan\common.h +del /Q wireshark\plugins\epan\wsjson_extensions.c +xcopy /Y /E plugins wireshark\plugins\ copy /Y CMakeListsCustom.txt wireshark rmdir /S /Q build mkdir build pushd build -cmake -G "Visual Studio 17 2022" -A x64 -DTRACEESHARK_VERSION=%TRACEESHARK_VERSION% -DENABLE_CCACHE=Yes ..\wireshark +cmake -G "Visual Studio 17 2022" -A x64 -DTRACEESHARK_VERSION=%TRACEESHARK_VERSION% ..\wireshark popd endlocal \ No newline at end of file