chore: Update Snort build workflow to use /tmp/work directory #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Package Snort | |
on: | |
push: | |
branches: | |
- "*" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: "1.22.4" | |
- name: Install dependencies | |
run: | | |
sudo apt-get update && sudo apt-get install -y --no-install-recommends \ | |
git libtool pkg-config autoconf gettext \ | |
libpcap-dev g++ vim make cmake wget libssl-dev \ | |
liblzma-dev python3-pip unzip protobuf-compiler \ | |
golang nano net-tools automake checkinstall | |
- name: Build and install Snort | |
run: | | |
# Variables | |
LIBDAQ_VERSION=3.0.15 | |
LIBDNET_VERSION=1.14 | |
FLEX_VERSION=2.6.4 | |
HWLOC_VERSION=2.5.0 | |
PCRE_VERSION=8.45 | |
ZLIB_VERSION=1.2.13 | |
SNORT_VER=3.2.2.0 | |
WORK_DIR=/tmp/work | |
# Create working directories | |
sudo mkdir -p $WORK_DIR | |
sudo chown $USER:$USER $WORK_DIR | |
# Install libdaq | |
cd $WORK_DIR | |
wget https://github.com/snort3/libdaq/archive/refs/tags/v${LIBDAQ_VERSION}.tar.gz | |
tar -xvf v${LIBDAQ_VERSION}.tar.gz | |
cd libdaq-${LIBDAQ_VERSION} | |
./bootstrap && ./configure && make && sudo make install | |
cd $WORK_DIR | |
rm -rf v${LIBDAQ_VERSION}.tar.gz | |
# Install libdnet | |
wget https://github.com/ofalk/libdnet/archive/refs/tags/libdnet-${LIBDNET_VERSION}.tar.gz | |
tar -xvf libdnet-${LIBDNET_VERSION}.tar.gz | |
cd libdnet-libdnet-${LIBDNET_VERSION} | |
./configure && make && sudo make install | |
cd $WORK_DIR | |
rm -rf libdnet-${LIBDNET_VERSION} libdnet-${LIBDNET_VERSION}.tar.gz | |
# Install Flex | |
wget https://github.com/westes/flex/releases/download/v${FLEX_VERSION}/flex-${FLEX_VERSION}.tar.gz | |
tar -xvf flex-${FLEX_VERSION}.tar.gz | |
cd flex-${FLEX_VERSION} | |
./configure && make && sudo make install | |
cd $WORK_DIR | |
rm -rf flex-${FLEX_VERSION} flex-${FLEX_VERSION}.tar.gz | |
# Install hwloc | |
wget https://download.open-mpi.org/release/hwloc/v2.5/hwloc-${HWLOC_VERSION}.tar.gz | |
tar -xvf hwloc-${HWLOC_VERSION}.tar.gz | |
cd hwloc-${HWLOC_VERSION} | |
./configure && make && sudo make install | |
cd $WORK_DIR | |
rm -rf hwloc-${HWLOC_VERSION} hwloc-${HWLOC_VERSION}.tar.gz | |
# Install LuaJIT with update | |
cd $WORK_DIR | |
git clone https://luajit.org/git/luajit.git | |
cd luajit | |
make && sudo make install | |
cd $WORK_DIR | |
rm -rf luajit | |
# Install PCRE | |
wget https://sourceforge.net/projects/pcre/files/pcre/${PCRE_VERSION}/pcre-${PCRE_VERSION}.tar.gz | |
tar -xvf pcre-${PCRE_VERSION}.tar.gz | |
cd pcre-${PCRE_VERSION} | |
./configure && make && sudo make install | |
cd $WORK_DIR | |
rm -rf pcre-${PCRE_VERSION} pcre-${PCRE_VERSION}.tar.gz | |
# Install zlib | |
wget https://github.com/madler/zlib/releases/download/v${ZLIB_VERSION}/zlib-${ZLIB_VERSION}.tar.gz | |
tar -xvf zlib-${ZLIB_VERSION}.tar.gz | |
cd zlib-${ZLIB_VERSION} | |
./configure && make && sudo make install | |
cd $WORK_DIR | |
rm -rf zlib-${ZLIB_VERSION} zlib-${ZLIB_VERSION}.tar.gz | |
# Install Snort 3 | |
wget https://github.com/snort3/snort3/archive/refs/tags/${SNORT_VER}.tar.gz | |
tar -xvf ${SNORT_VER}.tar.gz | |
cd snort3-${SNORT_VER} | |
export my_path=/usr/local | |
./configure_cmake.sh --prefix=$my_path | |
cd build | |
make -j$(nproc) install | |
cd $WORK_DIR | |
rm -rf snort3-${SNORT_VER} ${SNORT_VER}.tar.gz | |
- name: Create Debian package | |
run: | | |
cd /work/snort3-${SNORT_VER}/build | |
sudo checkinstall --pkgname=snort3 --pkgversion=${SNORT_VER} --backup=no --deldoc=yes --fstrans=no --default | |
- name: Upload Debian package | |
uses: actions/upload-artifact@v2 | |
with: | |
name: snort3-deb | |
path: /work/snort3-${SNORT_VER}/build/snort3_${SNORT_VER}_amd64.deb | |
- name: Publish to GitHub Packages | |
run: | | |
curl -u ${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }} \ | |
-H "Content-Type: $(file -b --mime-type /work/snort3-${SNORT_VER}/build/snort3_${SNORT_VER}_amd64.deb)" \ | |
--data-binary @/work/snort3-${SNORT_VER}/build/snort3_${SNORT_VER}_amd64.deb \ | |
"https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/latest/assets?name=snort3_${SNORT_VER}_amd64.deb" |