From e6164200f867b29c3368092bc4c119587b9906da Mon Sep 17 00:00:00 2001 From: Ofek Shaked Date: Sun, 2 Jun 2024 10:16:45 +0300 Subject: [PATCH] Added workflow for creating a release build --- .../install-wireshark-headers/action.yml | 22 +++++ .github/workflows/release.yml | 81 +++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 .github/actions/install-wireshark-headers/action.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/actions/install-wireshark-headers/action.yml b/.github/actions/install-wireshark-headers/action.yml new file mode 100644 index 0000000..2a7a350 --- /dev/null +++ b/.github/actions/install-wireshark-headers/action.yml @@ -0,0 +1,22 @@ +name: Install Wireshark headers +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/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..31913aa --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,81 @@ +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: + release: + name: Release + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + wireshark_version: [wireshark-4.2.5] + include: + # Ubuntu 22.04 Wireshark 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 Wireshark headers (Unix) + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' + uses: ./.github/actions/install-wireshark-headers + + - name: Build Traceeshark (Unix) + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' + run: | + make cmake + make + + - name: Create distribution archive (Unix) + id: create_dist + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' + run: | + make dist + DIST_PATH=$(ls dist/*.zip | head -n 1) + DIST_NAME=$(basename $DIST_PATH) + echo "::set-output name=dist_archive::$DIST_NAME" + + - 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 + + - name: Upload distribution archive + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/${{ steps.create_dist.outputs.dist_archive }} + asset_name: ${{ steps.create_dist.outputs.dist_archive }} + asset_content_type: application/zip