Windows build guide, optimization flags and verbose exposure script #328
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 | |
on: | |
push: | |
branches: [master] | |
paths-ignore: ["**.md"] | |
pull_request: | |
branches: [master] | |
paths-ignore: ["**.md"] | |
env: | |
VCPKG_VERSION: "2023.02.24" | |
# read only permission if pull request | |
VCPKG_BINARY_SOURCES: "clear;nuget,GitHub,read${{ github.event_name == 'push' && 'write' || '' }}" | |
jobs: | |
build: | |
name: CMake Build | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [windows-latest, ubuntu-22.04] | |
include: | |
- os: "windows-latest" | |
mono: "" | |
- os: "ubuntu-22.04" | |
mono: "mono" | |
steps: | |
- name: Checkout project | |
uses: actions/checkout@v3 | |
- name: Install Dependencies (Linux) | |
if: runner.os == 'Linux' | |
run: > | |
sudo apt-get update -y && | |
sudo apt-get install -y libunwind-dev && | |
sudo apt-get install -y | |
build-essential tar curl zip unzip pkg-config autoconf ninja-build | |
libudev-dev freeglut3-dev libgtk-3-dev libsecret-1-dev libgcrypt20-dev libsystemd-dev nasm | |
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio | |
- name: Clone vcpkg | |
shell: bash | |
run: | | |
git clone --filter=tree:0 --branch ${VCPKG_VERSION} https://github.com/microsoft/vcpkg.git | |
- name: Bootstrap vcpkg (Linux) | |
if: runner.os == 'Linux' | |
shell: bash | |
run: | | |
./vcpkg/bootstrap-vcpkg.sh | |
- name: Bootstrap vcpkg (Windows) | |
if: runner.os == 'Windows' | |
shell: cmd | |
run: | | |
./vcpkg/bootstrap-vcpkg.bat | |
- name: Setup NuGet Credentials | |
shell: bash | |
run: | | |
NUGET_EXE="`./vcpkg/vcpkg fetch nuget | tail -n 1`" | |
NUGET_OWNER="${{ github.repository_owner }}" | |
NUGET_URL="https://nuget.pkg.github.com/${NUGET_OWNER}/index.json" | |
${{ matrix.mono }} "${NUGET_EXE}" sources add \ | |
-source "${NUGET_URL}" -storepasswordincleartext -name "GitHub" -username "${NUGET_OWNER}" -password "${{ secrets.GITHUB_TOKEN }}" | |
${{ matrix.mono }} "${NUGET_EXE}" setapikey "${{ secrets.GITHUB_TOKEN }}" -source "${NUGET_URL}" | |
- name: Developer Command Prompt (Windows) | |
if: runner.os == 'Windows' | |
uses: ilammy/msvc-dev-cmd@v1 | |
- name: CMake Configure Release | |
run: > | |
cmake -B build/release -G Ninja | |
-DCMAKE_BUILD_TYPE=Release | |
-DCMAKE_INSTALL_PREFIX="./install/release" | |
-DCMAKE_TOOLCHAIN_FILE="./vcpkg/scripts/buildsystems/vcpkg.cmake" | |
-DVCPKG_INSTALLED_DIR="./build/vcpkg_installed" | |
- name: CMake Configure Debug | |
run: > | |
cmake -B build/debug -G Ninja | |
-DCMAKE_BUILD_TYPE=Debug | |
-DCMAKE_INSTALL_PREFIX="./install/debug" | |
-DCMAKE_TOOLCHAIN_FILE="./vcpkg/scripts/buildsystems/vcpkg.cmake" | |
-DVCPKG_INSTALLED_DIR="./build/vcpkg_installed" | |
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON | |
-DATT_DEBUG=ON | |
- name: CMake Build Release | |
run: | | |
cmake --build build/release --config Release --target install | |
- name: CMake Build Debug | |
run: | | |
cmake --build build/debug --config Debug --target install | |
- name: Tar Artifacts (Linux) | |
if: runner.os == 'Linux' | |
run: | | |
cd install/release | |
tar -cvf ../../AprilTagTrackers-Linux.tar * | |
cd ../../install/debug | |
tar -cvf ../../AprilTagTrackers-Debug-Linux.tar * | |
- name: Upload Release (Linux) | |
if: runner.os == 'Linux' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: AprilTagTrackers-Linux.tar | |
path: AprilTagTrackers-Linux.tar | |
- name: Upload Debug (Linux) | |
if: runner.os == 'Linux' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: AprilTagTrackers-Debug-Linux.tar | |
path: AprilTagTrackers-Debug-Linux.tar | |
- name: Upload Release (Windows) | |
if: runner.os == 'Windows' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: AprilTagTrackers-Windows | |
path: | | |
install/release | |
!install/release/**.pdb | |
- name: Upload Release PDB (Windows) | |
if: runner.os == 'Windows' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: AprilTagTrackers.pdb | |
path: install/release/**.pdb | |
- name: Upload Debug (Windows) | |
if: runner.os == 'Windows' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: AprilTagTrackers-Debug-Windows | |
path: install/debug | |
- name: Upload Logs | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Logs-${{ runner.os }} | |
path: | | |
build/**/CMakeCache.txt | |
build/**.log | |
vcpkg/buildtrees/**.log | |
send_discord_nightly_webhook: | |
name: Send Discord Nightly Webhook | |
needs: build | |
runs-on: ubuntu-latest | |
if: always() && github.event_name == 'push' | |
steps: | |
- name: Install Deps | |
run: | | |
npm install node-fetch@2 | |
- name: Send Discord Nightly Webhook | |
uses: actions/github-script@v6 | |
env: | |
RUN_STATUS: ${{ needs.build.result }} | |
REPO_NAME: ${{ github.repository }} | |
REPO_URL: ${{ github.server_url }}/${{ github.repository }} | |
with: | |
script: | | |
const fetch = require("node-fetch"); | |
const NIGHTLY_ARTIFACTS = [ | |
"AprilTagTrackers-Windows", | |
"AprilTagTrackers-Linux" | |
]; | |
const MAX_COMMITS = 10; | |
const { RUN_STATUS, | |
REPO_NAME, REPO_URL } = process.env; | |
const RUN_URL = `${REPO_URL}/actions/runs/${context.runId}`; | |
const ARTIF_URL = `https://nightly.link/${REPO_NAME}/actions/runs/${context.runId}`; | |
const MSG_LEN = 100; | |
function cutStr(s) { | |
s = s.split("\n")[0].trim(); | |
if (s.length > MSG_LEN) | |
s = s.substring(0, MSG_LEN - 3) + "..."; | |
return s; | |
} | |
const SHA_LEN = 6; | |
const fmtSha = s => s.substring(0, 6); | |
let embed = { | |
type: "rich", | |
title: `[${REPO_NAME}] `, | |
description: "", | |
url: RUN_URL, | |
color: 0x00FF00, | |
fields: [], | |
}; | |
const buildStatus = RUN_STATUS; | |
if (buildStatus === "success") { | |
embed.color = 0x0DFF35; | |
embed.title += "Build Succeeded"; | |
} else if (buildStatus === "cancelled") { | |
embed.color = 0xE0C434; | |
embed.title += "Build Cancelled" | |
} else if (buildStatus === "failure") { | |
embed.color = 0xFF1717; | |
embed.title += "Build Failed"; | |
} else { // if build was skipped | |
embed.color = 0x808080; | |
embed.title += "Build Skipped"; | |
} | |
const commits = context.payload.commits; | |
if (commits && commits.length >= 1) { | |
let count = 0; | |
for (const cmt of commits) { | |
if (!cmt.distinct) continue; | |
if (count++ === MAX_COMMITS) { | |
embed.description += `*${commits.length - MAX_COMMITS} more* ...\n`; | |
break; | |
} | |
embed.description += `[\` ${fmtSha(cmt.id)} \`](<${cmt.url}>) **${cmt.author.name}:** *${cutStr(cmt.message)}*\n` | |
} | |
embed.description += `\nSee what's changed: [\`${fmtSha(context.payload.before)} -> ${fmtSha(context.payload.after)}\`](<${context.payload.compare}>)`; | |
} | |
if (buildStatus === "success") { | |
let field = { name: "Downloads", value: "" }; | |
for (const artif_name of NIGHTLY_ARTIFACTS) { | |
const [ artif_app, artif_os ] = artif_name.split("-"); | |
if (!artif_os) continue; | |
const artif_url = `${ARTIF_URL}/${artif_name}.zip` | |
field.value += `[**\` ${artif_os} \`**](<${artif_url}>) `; | |
} | |
embed.fields.push(field); | |
} | |
await fetch("${{ secrets.DISCORD_NIGHTLY_WEBHOOK }}", { | |
method: "POST", | |
headers: {"Content-Type": "application/json"}, | |
body: JSON.stringify({ | |
embeds: [embed], | |
allowed_mentions: { parse: [] } | |
}) | |
}); |