Skip to content

Build and Release Datadog Agent Binaries #65

Build and Release Datadog Agent Binaries

Build and Release Datadog Agent Binaries #65

Workflow file for this run

name: Build and Release Datadog Agent Binaries
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
datadog_version:
description: "Datadog Agent version to build"
required: false
env:
NODE_VERSION: "22"
GO_VERSION: "1.23"
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
# Linux builds
- os: ubuntu-latest
platform: linux-x86_64
- os: linux-arm-24-2
platform: linux-arm64
# macOS builds
- os: macos-13
platform: macos-x86_64
- os: macos-latest
platform: macos-arm64
# Windows builds
- os: windows-latest
platform: windows-x86_64
# Disable Windows ARM64 builds until Chocolatey supports it
# - os: windows-11-arm
# platform: windows-arm64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential python3.12-dev
- name: Install build dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install cmake
- name: Install build dependencies (Windows)
if: runner.os == 'Windows'
run: |
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
- name: Install dependencies
run: npm ci
- name: Build TypeScript
run: npm run build
- name: Extract version from tag (Unix)
if: runner.os != 'Windows'
id: extract_version_unix
run: |
if [ -n "${{ github.event.inputs.datadog_version }}" ]; then
echo "version=${{ github.event.inputs.datadog_version }}" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref }}" == refs/tags/v* ]]; then
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
else
echo "version=" >> $GITHUB_OUTPUT
fi
- name: Extract version from tag (Windows)
if: runner.os == 'Windows'
id: extract_version_windows
run: |
if ("${{ github.event.inputs.datadog_version }}" -ne "") {
echo "version=${{ github.event.inputs.datadog_version }}" >> $env:GITHUB_OUTPUT
} elseif ("${{ github.ref }}" -like "refs/tags/v*") {
$version = "${{ github.ref }}" -replace "refs/tags/v", ""
echo "version=$version" >> $env:GITHUB_OUTPUT
} else {
echo "version=" >> $env:GITHUB_OUTPUT
}
shell: pwsh
- name: Build ${{ matrix.platform }} (Unix)
if: runner.os != 'Windows'
env:
DEBUG: true
run: |
if [ -n "${{ steps.extract_version_unix.outputs.version }}" ]; then
node dist/cli.js build --datadog-version ${{ steps.extract_version_unix.outputs.version }}
ls -l build/${{ matrix.platform }}/bin/
else
node dist/cli.js build
fi
- name: Build ${{ matrix.platform }} (Windows)
if: runner.os == 'Windows'
env:
DEBUG: true
run: |
if ("${{ steps.extract_version_windows.outputs.version }}" -ne "") {
node dist/cli.js build --datadog-version ${{ steps.extract_version_windows.outputs.version }}
} else {
node dist/cli.js build
}
shell: pwsh
- name: Upload ${{ matrix.platform }} artifacts
uses: actions/upload-artifact@v4
with:
name: agent-${{ matrix.platform }}
path: build/${{ matrix.platform }}/bin/
retention-days: 90
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Prepare release assets
run: |
mkdir -p release-assets
# Create compressed archives for each platform
cd artifacts
echo "Recursively listing files in artifacts:"
ls -lR
# Linux platforms
for arch in x86_64 arm64; do
if [ -d "agent-linux-${arch}" ]; then
cd "agent-linux-${arch}"
tar -czf "../../release-assets/datadog-agent-${{ github.ref_name }}-linux-${arch}.tar.gz" *
cd ..
fi
done
echo "Listing files in release-assets:"
ls -l ../release-assets
# macOS platforms
for arch in x86_64 arm64; do
if [ -d "agent-macos-${arch}" ]; then
cd "agent-macos-${arch}"
tar -czf "../../release-assets/datadog-agent-${{ github.ref_name }}-macos-${arch}.tar.gz" *
cd ..
fi
done
echo "Listing files in release-assets:"
ls -l ../release-assets
# Windows platforms
for arch in x86_64 arm64; do
if [ -d "agent-windows-${arch}" ]; then
cd "agent-windows-${arch}"
zip -r "../../release-assets/datadog-agent-${{ github.ref_name }}-windows-${arch}.zip" *
cd ..
fi
done
echo "Listing files in release-assets:"
ls -l ../release-assets
- name: Generate checksums
run: |
echo "Listing current dir"
ls -l
echo "Listing release-assets dir"
ls -l release-assets/
cd release-assets
sha256sum * > checksums.txt
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Datadog Agent ${{ github.ref_name }}
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}
files: |
release-assets/*
body: |
# @harperdb/datadog-agent-binary ${{ github.ref_name }}
Pre-compiled Datadog Agent binaries for all supported platforms.
## Supported Platforms
- **Linux x86_64**: `datadog-agent-${{ github.ref_name }}-linux-x86_64.tar.gz`
- **Linux arm64**: `datadog-agent-${{ github.ref_name }}-linux-arm64.tar.gz`
- **macOS x86_64**: `datadog-agent-${{ github.ref_name }}-macos-x86_64.tar.gz`
- **macOS arm64**: `datadog-agent-${{ github.ref_name }}-macos-arm64.tar.gz`
- **Windows x86_64**: `datadog-agent-${{ github.ref_name }}-windows-x86_64.zip`
## NPM Package
```bash
npm install @harperdb/datadog-agent-binary
```
## Verification
```bash
sha256sum -c checksums.txt
```
publish:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download binaries
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: List binaries
run: |
echo "Listing artifacts dir"
ls -l artifacts/
echo "Listing artifacts subdirs"
ls -l artifacts/*
- name: Move binaries to build dirs
run: |
echo "Listing artifacts dir again"
ls -l artifacts/
pushd artifacts
for artifact in *
do
echo "Moving contents of $artifact into ../build/$platform/bin/"
echo "Listing contents of $artifact"
ls -l "$artifact"
platform=${artifact#agent-}
mkdir -p "../build/$platform/bin"
mv "$artifact"/* "../build/$platform/bin/"
done
popd
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm ci
- name: Build TypeScript
run: npm run build
- name: Prepare platform packages with binaries
run: |
node scripts/create-platform-packages.js --all
- name: Publish platform packages
run: |
for platform_dir in npm/*/; do
platform=$(basename "$platform_dir")
echo "Publishing platform package: $platform"
cd "$platform_dir"
# Check if binaries exist
if [ -d "bin" ] && [ "$(ls -A bin)" ]; then
npm publish --access public
echo "Published @harperdb/datadog-agent-binary-$platform"
else
echo "Skipping $platform - no binaries found"
fi
cd - > /dev/null
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish main package
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}