Skip to content

Commit

Permalink
bkp - Backported build system improvements
Browse files Browse the repository at this point in the history
---

We've backported a series of build system improvements from Aptivestigate
as it has the most up-to-date files.

---

The following commits or tags are used for this backport:
  - Aptivi/Aptivestigate@93569e6
  - Aptivi/Aptivestigate@6ffb18b
  - Aptivi/Aptivestigate@a0a12ea
  - Aptivi/Aptivestigate@054d8b1
  - Aptivi/Aptivestigate@bac13b7
  - Aptivi/Aptivestigate@a7e3771
  - Aptivi/Aptivestigate@a1d33fe
  - Aptivi/Aptivestigate@835b3f1

---

Type: bkp
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Mar 8, 2025
1 parent d22f70e commit 7905a4c
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 125 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/build-rel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Setup Mono (Unix)
if: matrix.runs-on == 'ubuntu-latest'
run: sudo apt install mono-complete
- name: Solution Compilation (Windows)
if: matrix.runs-on == 'windows-latest'
run: cd tools ; ./build.cmd Release -p:ContinuousIntegrationBuild=true ; cd ..
- name: Solution Compilation (macOS)
if: matrix.runs-on == 'macos-latest'
run: make rel-ci
run: ./tools/build.cmd Release -p:ContinuousIntegrationBuild=true
- name: Solution Compilation (Unix)
if: matrix.runs-on == 'ubuntu-latest'
run: |
sudo apt install mono-complete
make rel-ci
if: matrix.runs-on != 'windows-latest'
run: make rel-ci
- name: Testing
run: dotnet test --no-build --configuration Release

14 changes: 6 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Setup Mono (Unix)
if: matrix.runs-on == 'ubuntu-latest'
run: sudo apt install mono-complete
- name: Solution Compilation (Windows)
if: matrix.runs-on == 'windows-latest'
run: cd tools ; ./build.cmd Debug -p:ContinuousIntegrationBuild=true ; cd ..
- name: Solution Compilation (macOS)
if: matrix.runs-on == 'macos-latest'
run: make dbg-ci
run: ./tools/build.cmd Debug -p:ContinuousIntegrationBuild=true
- name: Solution Compilation (Unix)
if: matrix.runs-on == 'ubuntu-latest'
run: |
sudo apt install mono-complete
make dbg-ci
if: matrix.runs-on != 'windows-latest'
run: make dbg-ci
- name: Testing
run: dotnet test --no-build --configuration Debug

4 changes: 1 addition & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ jobs:
with:
languages: ${{ matrix.language }}
- name: Build
run: |
chmod +x ./tools/build.sh
cd tools && ./build.sh && cd -
run: make rel-ci
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: dotnet tool install --global docfx
- name: Generating Documentation
run: |
make
make rel-ci
make doc
- name: Saving changes to gh-pages
uses: peaceiris/actions-gh-pages@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
run: |
dotnet nuget add source --username AptiviCEO --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Aptivi/index.json"
chmod +x tools/*.sh
cd tools ; NUGET_APIKEY=${{ secrets.GITHUB_TOKEN }} ./push.sh Debug github ; cd ..
NUGET_APIKEY=${{ secrets.GITHUB_TOKEN }} ./tools/push.sh Debug github
11 changes: 5 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
chmod +x tools/*.sh
make rel-ci
make doc
cd tools ; ./docgen-pack.sh ; cd ..
./tools/docgen-pack.sh
echo "SUBJECT=$(cat CHANGES.TITLE)" >> "$GITHUB_OUTPUT"
echo 'BODY<<EOF' >> "$GITHUB_OUTPUT"
cat CHANGES >> "$GITHUB_OUTPUT"
Expand All @@ -47,13 +47,12 @@ jobs:
name: ${{ steps.release-asset.outputs.SUBJECT }}
files: |
tools/*.zip
- name: Package Publication
run: |
chmod +x tools/*.sh
NUGET_APIKEY=${{ secrets.NUGET_APIKEY }} ./tools/push.sh
- name: Notify build
uses: tsickert/discord-webhook@v6.0.0
continue-on-error: true
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
content: "<:nettify:1268904841174843593> ${{ steps.release-asset.outputs.SUBJECT }} <:nettify:1268904841174843593>\n\n${{ steps.release-asset.outputs.BODY }}"
- name: Package Publication
run: |
chmod +x tools/*.sh
cd tools ; NUGET_APIKEY=${{ secrets.NUGET_APIKEY }} ./push.sh ; cd ..
12 changes: 7 additions & 5 deletions tools/build.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off

REM This script builds and packs the artifacts. Use when you have VS installed.
REM This script builds and packs the artifacts.
set releaseconfig=%1
if "%releaseconfig%" == "" set releaseconfig=Release

Expand All @@ -12,23 +12,25 @@ REM Turn off telemetry and logo
set DOTNET_CLI_TELEMETRY_OPTOUT=1
set DOTNET_NOLOGO=1

set ROOTDIR=%~dp0\..

:ispinfo
echo Downloading ISP info...
powershell "Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process ; ../public/Nettify/assets/IspInfo/getispinfo.ps1"
powershell "Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process ; %ROOTDIR%/public/Nettify/assets/IspInfo/getispinfo.ps1"
if %errorlevel% == 0 goto :download
echo There was an error trying to download ISP info (%errorlevel%).
goto :finished

:download
echo Downloading packages...
"%ProgramFiles%\dotnet\dotnet.exe" restore "..\Nettify.sln" -p:Configuration=%releaseconfig% %buildoptions%
"%ProgramFiles%\dotnet\dotnet.exe" restore "%ROOTDIR%\Nettify.sln" -p:Configuration=%releaseconfig% %buildoptions%
if %errorlevel% == 0 goto :build
echo There was an error trying to download packages (%errorlevel%).
goto :finished

:build
echo Building Nettify...
"%ProgramFiles%\dotnet\dotnet.exe" build "..\Nettify.sln" -p:Configuration=%releaseconfig% %buildoptions%
echo Building...
"%ProgramFiles%\dotnet\dotnet.exe" build "%ROOTDIR%\Nettify.sln" -p:Configuration=%releaseconfig% %buildoptions%
if %errorlevel% == 0 goto :success
echo There was an error trying to build (%errorlevel%).
goto :finished
Expand Down
28 changes: 7 additions & 21 deletions tools/build.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
#!/bin/bash

# Nettify Copyright (C) 2023-2024 Aptivi
#
# This file is part of Nettify
#
# Nettify is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Nettify is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Repository root
ROOTDIR=$( cd -- "$( dirname -- "$0" )/.." &> /dev/null && pwd )

# Convenience functions
checkerror() {
Expand All @@ -26,7 +12,7 @@ checkerror() {
fi
}

# This script builds. Use when you have dotnet installed.
# This script builds.
releaseconf=$1
if [ -z $releaseconf ]; then
releaseconf=Release
Expand All @@ -42,17 +28,17 @@ export DOTNET_NOLOGO=1

# Download ISP info
echo Downloading ISP info...
bash ../public/Nettify/assets/IspInfo/getispinfo.sh
bash $ROOTDIR/public/Nettify/assets/IspInfo/getispinfo.sh

# Download packages
echo Downloading packages...
"$dotnetpath" restore "../Nettify.sln" -p:Configuration=$releaseconf ${@:2}
"$dotnetpath" restore "$ROOTDIR/Nettify.sln" -p:Configuration=$releaseconf ${@:2}
checkerror $? "Failed to download packages"

# Build
echo Building...
"$dotnetpath" build "../Nettify.sln" -p:Configuration=$releaseconf ${@:2}
checkerror $? "Failed to build Nettify"
"$dotnetpath" build "$ROOTDIR/Nettify.sln" -p:Configuration=$releaseconf ${@:2}
checkerror $? "Failed to build"

# Inform success
echo Build successful.
18 changes: 10 additions & 8 deletions tools/docgen-pack.cmd
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
@echo off

REM This script builds KS documentation and packs the artifacts. Use when you have VS installed.
for /f "tokens=*" %%g in ('findstr "<Version>" ..\Directory.Build.props') do (set MIDVER=%%g)
for /f "tokens=1 delims=<" %%a in ("%MIDVER:~9%") do (set ksversion=%%a)
set ROOTDIR=%~dp0\..

REM This script builds the documentation and packs the artifacts.
for /f "tokens=*" %%g in ('findstr "<Version>" %ROOTDIR%\Directory.Build.props') do (set MIDVER=%%g)
for /f "tokens=1 delims=<" %%a in ("%MIDVER:~9%") do (set version=%%a)

:pack
echo Packing documentation...
"%ProgramFiles%\7-Zip\7z.exe" a -tzip %temp%/%ksversion%-doc.zip "..\docs\*"
"%ProgramFiles%\7-Zip\7z.exe" a -tzip %temp%/%version%-doc.zip "%ROOTDIR%\docs\*"
if %errorlevel% == 0 goto :finalize
echo There was an error trying to pack documentation (%errorlevel%).
goto :finished

:finalize
rmdir /S /Q "..\DocGen\api\"
rmdir /S /Q "..\DocGen\obj\"
rmdir /S /Q "..\docs\"
move %temp%\%ksversion%-doc.zip
rmdir /S /Q "%ROOTDIR%\DocGen\api\"
rmdir /S /Q "%ROOTDIR%\DocGen\obj\"
rmdir /S /Q "%ROOTDIR%\docs\"
move %temp%\%version%-doc.zip %ROOTDIR%\tools\
echo Build and pack successful.
goto :finished

Expand Down
32 changes: 9 additions & 23 deletions tools/docgen-pack.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
#!/bin/bash

# Nettify Copyright (C) 2023-2024 Aptivi
#
# This file is part of Nettify
#
# Nettify is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Nettify is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Repository root
ROOTDIR=$( cd -- "$( dirname -- "$0" )/.." &> /dev/null && pwd )

# Convenience functions
checkerror() {
Expand All @@ -26,8 +12,8 @@ checkerror() {
fi
}

# This script builds KS and packs the artifacts. Use when you have MSBuild installed.
ksversion=$(grep "<Version>" ../Directory.Build.props | cut -d "<" -f 2 | cut -d ">" -f 2)
# This script builds the documentation and packs the artifacts.
version=$(grep "<Version>" $ROOTDIR/Directory.Build.props | cut -d "<" -f 2 | cut -d ">" -f 2)
checkerror $? "Failed to get version. Check to make sure that the version is specified correctly in D.B.props"

# Check for dependencies
Expand All @@ -36,17 +22,17 @@ checkerror $? "zip is not found"

# Pack documentation
echo Packing documentation...
cd "../docs/" && "$zippath" -r /tmp/$ksversion-doc.zip . && cd -
cd "$ROOTDIR/docs/" && "$zippath" -r /tmp/$version-doc.zip . && cd -
checkerror $? "Failed to pack"

# Inform success
rm -rf "../DocGen/api"
rm -rf "$ROOTDIR/DocGen/api"
checkerror $? "Failed to remove api folder"
rm -rf "../DocGen/obj"
rm -rf "$ROOTDIR/DocGen/obj"
checkerror $? "Failed to remove obj folder"
rm -rf "../docs"
rm -rf "$ROOTDIR/docs"
checkerror $? "Failed to remove docs folder"
mv /tmp/$ksversion-doc.zip .
mv /tmp/$version-doc.zip "$ROOTDIR/tools"
checkerror $? "Failed to move archive from temporary folder"
echo Pack successful.
exit 0
5 changes: 2 additions & 3 deletions tools/docgen.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@echo off

REM This script builds the documentation and packs the artifacts. Use when you have VS installed.
for /f "tokens=* USEBACKQ" %%f in (`type version`) do set ksversion=%%f
set ROOTDIR=%~dp0\..

echo Finding DocFX...
if exist %USERPROFILE%\.dotnet\tools\docfx.exe goto :build
Expand All @@ -14,7 +13,7 @@ set DOTNET_CLI_TELEMETRY_OPTOUT=1
set DOTNET_NOLOGO=1

echo Building the documentation...
%USERPROFILE%\.dotnet\tools\docfx.exe "..\DocGen\docfx.json"
%USERPROFILE%\.dotnet\tools\docfx.exe "%ROOTDIR%\DocGen\docfx.json"
if %errorlevel% == 0 goto :success
echo There was an error trying to build documentation (%errorlevel%).
goto :finished
Expand Down
22 changes: 4 additions & 18 deletions tools/docgen.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
#!/bin/bash

# Nettify Copyright (C) 2023-2024 Aptivi
#
# This file is part of Nettify
#
# Nettify is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Nettify is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Repository root
ROOTDIR=$( cd -- "$( dirname -- "$0" )/.." &> /dev/null && pwd )

# Check for dependencies
msbuildpath=`which docfx`
Expand All @@ -28,9 +14,9 @@ fi
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_NOLOGO=1

# Build KS
# Build docs
echo Building documentation...
docfx ../DocGen/docfx.json
docfx $ROOTDIR/DocGen/docfx.json
if [ ! $? == 0 ]; then
echo Build failed.
exit 1
Expand Down
6 changes: 4 additions & 2 deletions tools/push.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ set apikey=%1
set source=%2
if "%source%" == "" set source=nuget.org

REM This script pushes. Use when you have VS installed.
set ROOTDIR=%~dp0..

REM This script pushes.
echo Pushing...
cmd /C "forfiles /s /m *.nupkg /p ..\ /C "cmd /c dotnet nuget push @path --api-key %apikey% --source %source%""
forfiles /s /m *.nupkg /p %ROOTDIR%\ /C "cmd /c echo @path && dotnet nuget push @path --api-key %apikey% --source %source%"
if %errorlevel% == 0 goto :success
echo There was an error trying to push (%errorlevel%).
goto :finished
Expand Down
22 changes: 4 additions & 18 deletions tools/push.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
#!/bin/bash

# Nettify Copyright (C) 2023-2024 Aptivi
#
# This file is part of Nettify
#
# Nettify is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Nettify is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Repository root
ROOTDIR=$( cd -- "$( dirname -- "$0" )/.." &> /dev/null && pwd )

# Convenience functions
checkerror() {
Expand All @@ -26,7 +12,7 @@ checkerror() {
fi
}

# This script pushes. Use when you have dotnet installed.
# This script pushes.
releaseconf=$1
if [ -z $releaseconf ]; then
releaseconf=Release
Expand All @@ -40,7 +26,7 @@ checkerror $? "dotnet is not found"

# Push packages
echo Pushing packages...
find .. -type f -path "**/bin/$releaseconf/*.nupkg" -exec dotnet nuget push {} --api-key $NUGET_APIKEY --source "$nugetsource" \;
find $ROOTDIR -type f -path "*/bin/$releaseconf/*.nupkg" -exec sh -c "echo {} ; dotnet nuget push {} --api-key $NUGET_APIKEY --source \"$nugetsource\"" \;
checkerror $? "Failed to push"

# Inform success
Expand Down

0 comments on commit 7905a4c

Please sign in to comment.