Introduce Windows Event Log integration and startup diagnostics enhan… #177
This file contains hidden or 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: Auto Release on master | |
| on: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - '**.go' | |
| - '*.sh' | |
| - 'lib/**' | |
| - '.github/workflows/**' | |
| - '!*.md' | |
| - '!docs/**' | |
| jobs: | |
| # Build Linux and Windows on ubuntu-latest | |
| build-linux-windows: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| date: ${{ steps.version.outputs.date }} | |
| hash: ${{ steps.version.outputs.hash }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.23' | |
| cache: false | |
| - name: Install zip | |
| run: sudo apt-get install zip -y | |
| - name: Get version metadata | |
| id: version | |
| run: | | |
| DATE=$(date +%Y%m%d) | |
| HASH=$(git rev-parse --short HEAD) | |
| VERSION="v${DATE}-${HASH}" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "date=$DATE" >> $GITHUB_OUTPUT | |
| echo "hash=$HASH" >> $GITHUB_OUTPUT | |
| - name: Clone NTrace-core | |
| run: | | |
| rm -rf lib/NTrace-core | |
| git clone --depth 1 https://github.com/netwatcherio/NTrace-core.git lib/NTrace-core | |
| - name: Build Linux and Windows | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| LDFLAGS="-s -w -X 'main.VERSION=$VERSION' -X 'main.buildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)' -X 'main.gitCommit=$(git rev-parse --short HEAD)'" | |
| mkdir -p bin | |
| # Linux builds - produce both .tar.gz and .zip for backward compatibility | |
| for arch in amd64 arm64 arm mips mipsle mips64 mips64le; do | |
| echo "Building linux/$arch..." | |
| CGO_ENABLED=0 GOOS=linux GOARCH=$arch go build -ldflags "$LDFLAGS" -o bin/netwatcher-linux-$arch . | |
| cd bin && tar czf netwatcher-${VERSION}-linux-$arch.tar.gz netwatcher-linux-$arch && zip netwatcher-${VERSION}-linux-$arch.zip netwatcher-linux-$arch && rm netwatcher-linux-$arch && cd .. | |
| done | |
| # Windows builds | |
| for arch in amd64 arm64; do | |
| echo "Building windows/$arch..." | |
| CGO_ENABLED=0 GOOS=windows GOARCH=$arch go build -ldflags "$LDFLAGS" -o bin/netwatcher-windows-$arch.exe . | |
| cd bin && zip netwatcher-${VERSION}-windows-$arch.zip netwatcher-windows-$arch.exe && rm netwatcher-windows-$arch.exe && cd .. | |
| done | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-windows-builds | |
| path: bin/ | |
| # Build macOS on macOS runner (requires CGO for pcap support) | |
| build-darwin: | |
| runs-on: macos-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| date: ${{ steps.version.outputs.date }} | |
| hash: ${{ steps.version.outputs.hash }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.23' | |
| cache: false | |
| - name: Get version metadata | |
| id: version | |
| run: | | |
| DATE=$(date +%Y%m%d) | |
| HASH=$(git rev-parse --short HEAD) | |
| VERSION="v${DATE}-${HASH}" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "date=$DATE" >> $GITHUB_OUTPUT | |
| echo "hash=$HASH" >> $GITHUB_OUTPUT | |
| - name: Clone NTrace-core | |
| run: | | |
| rm -rf lib/NTrace-core | |
| git clone --depth 1 https://github.com/netwatcherio/NTrace-core.git lib/NTrace-core | |
| - name: Build macOS | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| LDFLAGS="-s -w -X 'main.VERSION=$VERSION' -X 'main.buildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)' -X 'main.gitCommit=$(git rev-parse --short HEAD)'" | |
| mkdir -p bin | |
| # macOS builds (CGO required for pcap) | |
| for arch in amd64 arm64; do | |
| echo "Building darwin/$arch..." | |
| CGO_ENABLED=1 GOOS=darwin GOARCH=$arch go build -ldflags "$LDFLAGS" -o bin/netwatcher-darwin-$arch . | |
| cd bin && zip netwatcher-${VERSION}-darwin-$arch.zip netwatcher-darwin-$arch && rm netwatcher-darwin-$arch && cd .. | |
| done | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: darwin-builds | |
| path: bin/ | |
| # Create release with all artifacts | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: [build-linux-windows, build-darwin] | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download Linux/Windows artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: linux-windows-builds | |
| path: bin | |
| - name: Download macOS artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: darwin-builds | |
| path: bin | |
| - name: Verify artifacts exist | |
| run: | | |
| echo "Listing downloaded artifacts:" | |
| ls -la bin/ | |
| ARCHIVE_COUNT=$(ls bin/*.tar.gz bin/*.zip 2>/dev/null | wc -l) | |
| echo "Found $ARCHIVE_COUNT archive files" | |
| if [ "$ARCHIVE_COUNT" -lt 18 ]; then | |
| echo "ERROR: Expected 18 archive files (7 linux * 2 formats + 2 windows + 2 darwin = 18), but found $ARCHIVE_COUNT" | |
| exit 1 | |
| fi | |
| VERSION="${{ needs.build-linux-windows.outputs.version }}" | |
| echo "Verifying specific platform artifacts..." | |
| # Verify Linux artifacts (both .tar.gz and .zip) | |
| for arch in amd64 arm64 arm mips mipsle mips64 mips64le; do | |
| if [ ! -f "bin/netwatcher-${VERSION}-linux-${arch}.tar.gz" ]; then | |
| echo "ERROR: Missing Linux ${arch} tar.gz artifact" | |
| exit 1 | |
| fi | |
| if [ ! -f "bin/netwatcher-${VERSION}-linux-${arch}.zip" ]; then | |
| echo "ERROR: Missing Linux ${arch} zip artifact" | |
| exit 1 | |
| fi | |
| echo " [OK] Linux ${arch} (.tar.gz and .zip)" | |
| done | |
| # Verify Windows artifacts | |
| for arch in amd64 arm64; do | |
| if [ ! -f "bin/netwatcher-${VERSION}-windows-${arch}.zip" ]; then | |
| echo "ERROR: Missing Windows ${arch} artifact: netwatcher-${VERSION}-windows-${arch}.zip" | |
| exit 1 | |
| fi | |
| echo " [OK] Windows ${arch}" | |
| done | |
| # Verify macOS artifacts | |
| for arch in amd64 arm64; do | |
| if [ ! -f "bin/netwatcher-${VERSION}-darwin-${arch}.zip" ]; then | |
| echo "ERROR: Missing macOS ${arch} artifact: netwatcher-${VERSION}-darwin-${arch}.zip" | |
| exit 1 | |
| fi | |
| echo " [OK] macOS ${arch}" | |
| done | |
| echo "All platform artifacts verified successfully!" | |
| - name: Generate checksums | |
| run: | | |
| cd bin | |
| sha256sum *.tar.gz *.zip > netwatcher-${{ needs.build-linux-windows.outputs.version }}-checksums.txt | |
| - name: Create Release and Upload Files | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: bin/* | |
| tag: ${{ needs.build-linux-windows.outputs.version }} | |
| overwrite: true | |
| file_glob: true | |
| release_name: "Release ${{ needs.build-linux-windows.outputs.version }}" | |
| body: | | |
| ## NetWatcher Release ${{ needs.build-linux-windows.outputs.version }} | |
| **Build Date:** ${{ needs.build-linux-windows.outputs.date }} | |
| **Commit:** ${{ github.sha }} (${{ needs.build-linux-windows.outputs.hash }}) | |
| **Branch:** master | |
| ### Platforms | |
| - **Linux:** amd64, arm64, arm, mips, mipsle, mips64, mips64le | |
| - **Windows:** amd64, arm64 | |
| - **macOS:** amd64, arm64 | |
| ### Installation | |
| #### Linux | |
| ```bash | |
| curl -fsSL https://raw.githubusercontent.com/netwatcherio/agent/master/install.sh | sudo bash -s -- \ | |
| --workspace YOUR_WORKSPACE_ID \ | |
| --id YOUR_AGENT_ID \ | |
| --pin YOUR_AGENT_PIN | |
| ``` | |
| #### macOS | |
| ```bash | |
| # User-level (no sudo) | |
| curl -fsSL https://raw.githubusercontent.com/netwatcherio/agent/master/install-macos.sh | bash -s -- \ | |
| --workspace YOUR_WORKSPACE_ID \ | |
| --id YOUR_AGENT_ID \ | |
| --pin YOUR_AGENT_PIN | |
| # System-level (requires sudo, runs at boot) | |
| curl -fsSL https://raw.githubusercontent.com/netwatcherio/agent/master/install-macos.sh | sudo bash -s -- \ | |
| --workspace YOUR_WORKSPACE_ID \ | |
| --id YOUR_AGENT_ID \ | |
| --pin YOUR_AGENT_PIN \ | |
| --system | |
| ``` | |
| #### Windows | |
| ```powershell | |
| Invoke-WebRequest -Uri "https://raw.githubusercontent.com/netwatcherio/agent/master/install.ps1" -OutFile "install.ps1" | |
| .\install.ps1 -Workspace YOUR_WORKSPACE_ID -Id YOUR_AGENT_ID -Pin "YOUR_AGENT_PIN" | |
| ``` | |
| ### Checksums | |
| See `netwatcher-${{ needs.build-linux-windows.outputs.version }}-checksums.txt` for file checksums. | |
| - name: Upload checksums | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: bin/netwatcher-${{ needs.build-linux-windows.outputs.version }}-checksums.txt | |
| tag: ${{ needs.build-linux-windows.outputs.version }} | |
| overwrite: true |