Skip to content

Update GELFsender.c #19

Update GELFsender.c

Update GELFsender.c #19

Workflow file for this run

name: Build Ubuntu Package
on:
push:
branches: [ main ]
jobs:
build-package-and-upload:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # This ensures all history and tags are fetched
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential debhelper dh-make
- name: Build project
run: |
cd source
make
- name: Run tests
run: |
cd source
make test
- name: Prepare package files
run: |
# Try to get the latest tag, use a default if none exists
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0")
# If no tag was found, use the short commit hash
if [ "$LATEST_TAG" = "v0.1.0" ]; then
LATEST_TAG=$(git rev-parse --short HEAD)
fi
cd source
mkdir -p debian
mkdir -p debian/package/DEBIAN
mkdir -p debian/package/usr/bin # Path
cp GELFsender debian/package/usr/bin/ # target
chmod 711 debian/package/usr/bin/GELFsender
cat << EOF > debian/control
Source: json-graylog-tcp-logger
Section: utils
Priority: optional
Maintainer: Darek <[email protected]>
Build-Depends: debhelper (>= 9)
Standards-Version: 3.9.8
Package: json-graylog-tcp-logger
Architecture: any
Depends: \${shlibs:Depends}, \${misc:Depends}
Description: STDIN to TCP Graylog logger
This is Graylog TCP logger written in C
This process takes STDIN as input, assuming one message per line, terminated by 0x0a.
Then, replaces termination with 0x00 to comply with Graylog TCP format and sends it to one of (up to) two Graylog servers.
EOF
echo "11" > debian/compat
cat << EOF > debian/rules
#!/usr/bin/make -f
%:
dh \$@
EOF
chmod +x debian/rules
cat << EOF > debian/changelog
json-graylog-tcp-logger ($LATEST_TAG) unstable; urgency=medium
* Release $LATEST_TAG
-- Darek <[email protected]> $(date -R)
EOF
# Verify files were created
#ls -R debian
- name: Build Debian package
run: |
cd source
dpkg-buildpackage -us -uc -b
# - name: Upload package artifact
# uses: actions/upload-artifact@v4
# with:
# name: ubuntu-package
# path: ./*.deb
# if-no-files-found: error
- name: Find .deb file
id: find_deb
run: |
DEB_FILE=$(find . -maxdepth 1 -name "*.deb" -print -quit)
if [ -z "$DEB_FILE" ]; then
echo "No .deb file found"
exit 1
fi
echo "deb_file=${DEB_FILE}" >> $GITHUB_OUTPUT
echo "deb_name=$(basename ${DEB_FILE})" >> $GITHUB_OUTPUT
shell: bash
- name: Get latest release
id: get_latest_release
run: |
release_info=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/latest")
if [ "$(echo $release_info | jq -r .message)" = "Not Found" ]; then
echo "No releases found. Please create a release first."
exit 1
fi
echo "release_id=$(echo $release_info | jq -r .id)" >> $GITHUB_OUTPUT
echo "upload_url=$(echo $release_info | jq -r .upload_url)" >> $GITHUB_OUTPUT
shell: bash
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_latest_release.outputs.upload_url }}
asset_path: ${{ steps.find_deb.outputs.deb_file }}
asset_name: ${{ steps.find_deb.outputs.deb_name }}
asset_content_type: application/vnd.debian.binary-package