diff --git a/.github/workflows/buildbots.yml b/.github/workflows/buildbots.yml index e733d44..4805f8c 100644 --- a/.github/workflows/buildbots.yml +++ b/.github/workflows/buildbots.yml @@ -19,6 +19,14 @@ jobs: with: dotnet-version: '8.0' # Change to your desired .NET version + - name: Restore dependencies + run: dotnet restore + working-directory: Source + + - name: Build solution + run: dotnet build --no-restore --configuration Debug + working-directory: Source + - name: Restore & Build all .NET projects in Bots subfolders run: | find Bots -type f -name "*.csproj" | while read csproj; do diff --git a/.github/workflows/mainbuild.yml b/.github/workflows/mainbuild.yml index e066894..5b54218 100644 --- a/.github/workflows/mainbuild.yml +++ b/.github/workflows/mainbuild.yml @@ -8,7 +8,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: windows-latest steps: - name: Checkout repository @@ -25,5 +25,17 @@ jobs: working-directory: Source - name: Build solution - run: dotnet build --no-restore --configuration Release + run: dotnet build --no-restore --configuration Debug working-directory: Source + + - name: Exclude Results directory + run: Remove-Item -Recurse -Force Build\Results + shell: pwsh + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: build-artifact + path: | + Build/ + if-no-files-found: error diff --git a/.gitignore b/.gitignore index c4c704b..cb1a758 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,9 @@ x64/ [Bb]in/ [Oo]bj/ -[Bb]uild/[Bb]ots + +[Bb]uild/* +![Bbuild]/Results/ # MSTest test Results [Tt]est[Rr]esult*/ diff --git a/Build/Handlebars.dll b/Build/Handlebars.dll deleted file mode 100644 index 8466444..0000000 Binary files a/Build/Handlebars.dll and /dev/null differ diff --git a/Build/HarfBuzzSharp.dll b/Build/HarfBuzzSharp.dll deleted file mode 100644 index f4e2c2e..0000000 Binary files a/Build/HarfBuzzSharp.dll and /dev/null differ diff --git a/Build/NasdaqTrader.Bot.Core.dll b/Build/NasdaqTrader.Bot.Core.dll deleted file mode 100644 index 2174847..0000000 Binary files a/Build/NasdaqTrader.Bot.Core.dll and /dev/null differ diff --git a/Build/NasdaqTrader.CLI.deps.json b/Build/NasdaqTrader.CLI.deps.json deleted file mode 100644 index 0dd0bb5..0000000 --- a/Build/NasdaqTrader.CLI.deps.json +++ /dev/null @@ -1,319 +0,0 @@ -{ - "runtimeTarget": { - "name": ".NETCoreApp,Version=v8.0", - "signature": "" - }, - "compilationOptions": {}, - "targets": { - ".NETCoreApp,Version=v8.0": { - "NasdaqTrader.CLI/1.0.0": { - "dependencies": { - "NasdaqTraderSystem.Core": "1.0.0", - "NasdaqTraderSystem.Html": "1.0.0" - }, - "runtime": { - "NasdaqTrader.CLI.dll": {} - } - }, - "Handlebars.Net/2.1.6": { - "runtime": { - "lib/net6.0/Handlebars.dll": { - "assemblyVersion": "2.1.6.0", - "fileVersion": "2.1.6.0" - } - } - }, - "HarfBuzzSharp/7.3.0.3": { - "dependencies": { - "HarfBuzzSharp.NativeAssets.Win32": "7.3.0.3", - "HarfBuzzSharp.NativeAssets.macOS": "7.3.0.3" - }, - "runtime": { - "lib/net6.0/HarfBuzzSharp.dll": { - "assemblyVersion": "1.0.0.0", - "fileVersion": "7.3.0.3" - } - } - }, - "HarfBuzzSharp.NativeAssets.Linux/7.3.0.3": { - "dependencies": { - "HarfBuzzSharp": "7.3.0.3" - }, - "runtimeTargets": { - "runtimes/linux-arm/native/libHarfBuzzSharp.so": { - "rid": "linux-arm", - "assetType": "native", - "fileVersion": "0.0.0.0" - }, - "runtimes/linux-arm64/native/libHarfBuzzSharp.so": { - "rid": "linux-arm64", - "assetType": "native", - "fileVersion": "0.0.0.0" - }, - "runtimes/linux-musl-x64/native/libHarfBuzzSharp.so": { - "rid": "linux-musl-x64", - "assetType": "native", - "fileVersion": "0.0.0.0" - }, - "runtimes/linux-x64/native/libHarfBuzzSharp.so": { - "rid": "linux-x64", - "assetType": "native", - "fileVersion": "0.0.0.0" - } - } - }, - "HarfBuzzSharp.NativeAssets.macOS/7.3.0.3": { - "runtimeTargets": { - "runtimes/osx/native/libHarfBuzzSharp.dylib": { - "rid": "osx", - "assetType": "native", - "fileVersion": "0.0.0.0" - } - } - }, - "HarfBuzzSharp.NativeAssets.Win32/7.3.0.3": { - "runtimeTargets": { - "runtimes/win-arm64/native/libHarfBuzzSharp.dll": { - "rid": "win-arm64", - "assetType": "native", - "fileVersion": "0.0.0.0" - }, - "runtimes/win-x64/native/libHarfBuzzSharp.dll": { - "rid": "win-x64", - "assetType": "native", - "fileVersion": "0.0.0.0" - }, - "runtimes/win-x86/native/libHarfBuzzSharp.dll": { - "rid": "win-x86", - "assetType": "native", - "fileVersion": "0.0.0.0" - } - } - }, - "ScottPlot/5.0.55": { - "dependencies": { - "HarfBuzzSharp.NativeAssets.Linux": "7.3.0.3", - "SkiaSharp": "2.88.9", - "SkiaSharp.HarfBuzz": "2.88.9", - "SkiaSharp.NativeAssets.Linux.NoDependencies": "2.88.9" - }, - "runtime": { - "lib/net8.0/ScottPlot.dll": { - "assemblyVersion": "5.0.55.0", - "fileVersion": "5.0.55.0" - } - } - }, - "SkiaSharp/2.88.9": { - "dependencies": { - "SkiaSharp.NativeAssets.Win32": "2.88.9", - "SkiaSharp.NativeAssets.macOS": "2.88.9" - }, - "runtime": { - "lib/net6.0/SkiaSharp.dll": { - "assemblyVersion": "2.88.0.0", - "fileVersion": "2.88.9.0" - } - } - }, - "SkiaSharp.HarfBuzz/2.88.9": { - "dependencies": { - "HarfBuzzSharp": "7.3.0.3", - "SkiaSharp": "2.88.9" - }, - "runtime": { - "lib/net6.0/SkiaSharp.HarfBuzz.dll": { - "assemblyVersion": "2.88.0.0", - "fileVersion": "2.88.9.0" - } - } - }, - "SkiaSharp.NativeAssets.Linux.NoDependencies/2.88.9": { - "dependencies": { - "SkiaSharp": "2.88.9" - }, - "runtimeTargets": { - "runtimes/linux-arm/native/libSkiaSharp.so": { - "rid": "linux-arm", - "assetType": "native", - "fileVersion": "0.0.0.0" - }, - "runtimes/linux-arm64/native/libSkiaSharp.so": { - "rid": "linux-arm64", - "assetType": "native", - "fileVersion": "0.0.0.0" - }, - "runtimes/linux-musl-x64/native/libSkiaSharp.so": { - "rid": "linux-musl-x64", - "assetType": "native", - "fileVersion": "0.0.0.0" - }, - "runtimes/linux-x64/native/libSkiaSharp.so": { - "rid": "linux-x64", - "assetType": "native", - "fileVersion": "0.0.0.0" - } - } - }, - "SkiaSharp.NativeAssets.macOS/2.88.9": { - "runtimeTargets": { - "runtimes/osx/native/libSkiaSharp.dylib": { - "rid": "osx", - "assetType": "native", - "fileVersion": "0.0.0.0" - } - } - }, - "SkiaSharp.NativeAssets.Win32/2.88.9": { - "runtimeTargets": { - "runtimes/win-arm64/native/libSkiaSharp.dll": { - "rid": "win-arm64", - "assetType": "native", - "fileVersion": "0.0.0.0" - }, - "runtimes/win-x64/native/libSkiaSharp.dll": { - "rid": "win-x64", - "assetType": "native", - "fileVersion": "0.0.0.0" - }, - "runtimes/win-x86/native/libSkiaSharp.dll": { - "rid": "win-x86", - "assetType": "native", - "fileVersion": "0.0.0.0" - } - } - }, - "NasdaqTrader.Bot.Core/1.0.0": { - "runtime": { - "NasdaqTrader.Bot.Core.dll": { - "assemblyVersion": "1.0.0", - "fileVersion": "1.0.0.0" - } - } - }, - "NasdaqTraderSystem.Core/1.0.0": { - "dependencies": { - "NasdaqTrader.Bot.Core": "1.0.0" - }, - "runtime": { - "NasdaqTraderSystem.Core.dll": { - "assemblyVersion": "1.0.0", - "fileVersion": "1.0.0.0" - } - } - }, - "NasdaqTraderSystem.Html/1.0.0": { - "dependencies": { - "Handlebars.Net": "2.1.6", - "NasdaqTraderSystem.Core": "1.0.0", - "ScottPlot": "5.0.55" - }, - "runtime": { - "NasdaqTraderSystem.Html.dll": { - "assemblyVersion": "1.0.0", - "fileVersion": "1.0.0.0" - } - } - } - } - }, - "libraries": { - "NasdaqTrader.CLI/1.0.0": { - "type": "project", - "serviceable": false, - "sha512": "" - }, - "Handlebars.Net/2.1.6": { - "type": "package", - "serviceable": true, - "sha512": "sha512-WsYWCEXsIM6hEOSOSRHtIYLjC8BnbT5MVmqhNKRqUI7qiv0t8x3nJiBTEv0ZZfvUAMAFnadGIzSsS/U2anVG1Q==", - "path": "handlebars.net/2.1.6", - "hashPath": "handlebars.net.2.1.6.nupkg.sha512" - }, - "HarfBuzzSharp/7.3.0.3": { - "type": "package", - "serviceable": true, - "sha512": "sha512-Hq+5+gx10coOvuRgB13KBwiWxJq1QeYuhtVLbA01ZCWaugOnolUahF44KvrQTUUHDNk/C7HB6SMaebsZeOdhgg==", - "path": "harfbuzzsharp/7.3.0.3", - "hashPath": "harfbuzzsharp.7.3.0.3.nupkg.sha512" - }, - "HarfBuzzSharp.NativeAssets.Linux/7.3.0.3": { - "type": "package", - "serviceable": true, - "sha512": "sha512-hkcHeTfOyIeJuPtO/QfoqkDvV/MXebZYaA/Bn/S+nXsjH3Wt9oQ6okH2kklYO+1UUdBSJFd67bi9IrpQXI2mPw==", - "path": "harfbuzzsharp.nativeassets.linux/7.3.0.3", - "hashPath": "harfbuzzsharp.nativeassets.linux.7.3.0.3.nupkg.sha512" - }, - "HarfBuzzSharp.NativeAssets.macOS/7.3.0.3": { - "type": "package", - "serviceable": true, - "sha512": "sha512-UAwIYnkbBTzBJv1Id8FijY/i8QiIepRemSXufU8fyzwWhYJdx4+ajG8yQUie5HW/uusbVLFSr26muSlJOFDgSw==", - "path": "harfbuzzsharp.nativeassets.macos/7.3.0.3", - "hashPath": "harfbuzzsharp.nativeassets.macos.7.3.0.3.nupkg.sha512" - }, - "HarfBuzzSharp.NativeAssets.Win32/7.3.0.3": { - "type": "package", - "serviceable": true, - "sha512": "sha512-RPxRXD16KtSs8Yxr2RK9Qs7AwyN9MlpqZIYs0AvfaJwl7RAtVhC0+u2f2SKwX0uMYYd3O98Z+OBA1sj6aWVKQA==", - "path": "harfbuzzsharp.nativeassets.win32/7.3.0.3", - "hashPath": "harfbuzzsharp.nativeassets.win32.7.3.0.3.nupkg.sha512" - }, - "ScottPlot/5.0.55": { - "type": "package", - "serviceable": true, - "sha512": "sha512-afhqrtF/eZ08QWunp56tDGg8gKiSAnNfUaB9XTAp3xt7QlVPhEkNmJKImTDC+/j6EbWENiezHaOKt9bD/kLm0w==", - "path": "scottplot/5.0.55", - "hashPath": "scottplot.5.0.55.nupkg.sha512" - }, - "SkiaSharp/2.88.9": { - "type": "package", - "serviceable": true, - "sha512": "sha512-3MD5VHjXXieSHCleRLuaTXmL2pD0mB7CcOB1x2kA1I4bhptf4e3R27iM93264ZYuAq6mkUyX5XbcxnZvMJYc1Q==", - "path": "skiasharp/2.88.9", - "hashPath": "skiasharp.2.88.9.nupkg.sha512" - }, - "SkiaSharp.HarfBuzz/2.88.9": { - "type": "package", - "serviceable": true, - "sha512": "sha512-5lyjX04CSWTKFYMSNN6SMupV2qzYDr8W/u8S3ZEkr+Sg3kOi0YE06EOqG0tzn/YPBID89xam4L3rz3hUUKOGEQ==", - "path": "skiasharp.harfbuzz/2.88.9", - "hashPath": "skiasharp.harfbuzz.2.88.9.nupkg.sha512" - }, - "SkiaSharp.NativeAssets.Linux.NoDependencies/2.88.9": { - "type": "package", - "serviceable": true, - "sha512": "sha512-ZA9syMvIuoqxPhyFTgde/bNV6VMdeYT9gRdNQT5O+ZjPK+a/nVkKRrqBbn7EVA7XQiW+xIycyT4gW/sea9eh+w==", - "path": "skiasharp.nativeassets.linux.nodependencies/2.88.9", - "hashPath": "skiasharp.nativeassets.linux.nodependencies.2.88.9.nupkg.sha512" - }, - "SkiaSharp.NativeAssets.macOS/2.88.9": { - "type": "package", - "serviceable": true, - "sha512": "sha512-Nv5spmKc4505Ep7oUoJ5vp3KweFpeNqxpyGDWyeEPTX2uR6S6syXIm3gj75dM0YJz7NPvcix48mR5laqs8dPuA==", - "path": "skiasharp.nativeassets.macos/2.88.9", - "hashPath": "skiasharp.nativeassets.macos.2.88.9.nupkg.sha512" - }, - "SkiaSharp.NativeAssets.Win32/2.88.9": { - "type": "package", - "serviceable": true, - "sha512": "sha512-wb2kYgU7iy84nQLYZwMeJXixvK++GoIuECjU4ECaUKNuflyRlJKyiRhN1MAHswvlvzuvkrjRWlK0Za6+kYQK7w==", - "path": "skiasharp.nativeassets.win32/2.88.9", - "hashPath": "skiasharp.nativeassets.win32.2.88.9.nupkg.sha512" - }, - "NasdaqTrader.Bot.Core/1.0.0": { - "type": "project", - "serviceable": false, - "sha512": "" - }, - "NasdaqTraderSystem.Core/1.0.0": { - "type": "project", - "serviceable": false, - "sha512": "" - }, - "NasdaqTraderSystem.Html/1.0.0": { - "type": "project", - "serviceable": false, - "sha512": "" - } - } -} \ No newline at end of file diff --git a/Build/NasdaqTrader.CLI.dll b/Build/NasdaqTrader.CLI.dll deleted file mode 100644 index ed451e5..0000000 Binary files a/Build/NasdaqTrader.CLI.dll and /dev/null differ diff --git a/Build/NasdaqTrader.CLI.exe b/Build/NasdaqTrader.CLI.exe deleted file mode 100644 index 6aa2f44..0000000 Binary files a/Build/NasdaqTrader.CLI.exe and /dev/null differ diff --git a/Build/NasdaqTrader.CLI.runtimeconfig.json b/Build/NasdaqTrader.CLI.runtimeconfig.json deleted file mode 100644 index becfaea..0000000 --- a/Build/NasdaqTrader.CLI.runtimeconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "runtimeOptions": { - "tfm": "net8.0", - "framework": { - "name": "Microsoft.NETCore.App", - "version": "8.0.0" - }, - "configProperties": { - "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false - } - } -} \ No newline at end of file diff --git a/Build/NasdaqTraderSystem.Core.dll b/Build/NasdaqTraderSystem.Core.dll deleted file mode 100644 index 0730ab2..0000000 Binary files a/Build/NasdaqTraderSystem.Core.dll and /dev/null differ diff --git a/Build/NasdaqTraderSystem.Html.dll b/Build/NasdaqTraderSystem.Html.dll deleted file mode 100644 index c4b6d25..0000000 Binary files a/Build/NasdaqTraderSystem.Html.dll and /dev/null differ diff --git a/Build/ScottPlot.dll b/Build/ScottPlot.dll deleted file mode 100644 index 4aa1d47..0000000 Binary files a/Build/ScottPlot.dll and /dev/null differ diff --git a/Build/SkiaSharp.HarfBuzz.dll b/Build/SkiaSharp.HarfBuzz.dll deleted file mode 100644 index b611f3a..0000000 Binary files a/Build/SkiaSharp.HarfBuzz.dll and /dev/null differ diff --git a/Build/SkiaSharp.dll b/Build/SkiaSharp.dll deleted file mode 100644 index 5d7e9cd..0000000 Binary files a/Build/SkiaSharp.dll and /dev/null differ diff --git a/Build/quickstart.png b/Build/quickstart.png deleted file mode 100644 index 96cfd2d..0000000 Binary files a/Build/quickstart.png and /dev/null differ diff --git a/Build/runtimes/linux-arm/native/libHarfBuzzSharp.so b/Build/runtimes/linux-arm/native/libHarfBuzzSharp.so deleted file mode 100644 index 2c6fbe3..0000000 Binary files a/Build/runtimes/linux-arm/native/libHarfBuzzSharp.so and /dev/null differ diff --git a/Build/runtimes/linux-arm/native/libSkiaSharp.so b/Build/runtimes/linux-arm/native/libSkiaSharp.so deleted file mode 100644 index b2bf133..0000000 Binary files a/Build/runtimes/linux-arm/native/libSkiaSharp.so and /dev/null differ diff --git a/Build/runtimes/linux-arm64/native/libHarfBuzzSharp.so b/Build/runtimes/linux-arm64/native/libHarfBuzzSharp.so deleted file mode 100644 index 89e71b5..0000000 Binary files a/Build/runtimes/linux-arm64/native/libHarfBuzzSharp.so and /dev/null differ diff --git a/Build/runtimes/linux-arm64/native/libSkiaSharp.so b/Build/runtimes/linux-arm64/native/libSkiaSharp.so deleted file mode 100644 index c05e7d3..0000000 Binary files a/Build/runtimes/linux-arm64/native/libSkiaSharp.so and /dev/null differ diff --git a/Build/runtimes/linux-musl-x64/native/libHarfBuzzSharp.so b/Build/runtimes/linux-musl-x64/native/libHarfBuzzSharp.so deleted file mode 100644 index 43ea300..0000000 Binary files a/Build/runtimes/linux-musl-x64/native/libHarfBuzzSharp.so and /dev/null differ diff --git a/Build/runtimes/linux-musl-x64/native/libSkiaSharp.so b/Build/runtimes/linux-musl-x64/native/libSkiaSharp.so deleted file mode 100644 index cc7328d..0000000 Binary files a/Build/runtimes/linux-musl-x64/native/libSkiaSharp.so and /dev/null differ diff --git a/Build/runtimes/linux-x64/native/libHarfBuzzSharp.so b/Build/runtimes/linux-x64/native/libHarfBuzzSharp.so deleted file mode 100644 index d8548f3..0000000 Binary files a/Build/runtimes/linux-x64/native/libHarfBuzzSharp.so and /dev/null differ diff --git a/Build/runtimes/linux-x64/native/libSkiaSharp.so b/Build/runtimes/linux-x64/native/libSkiaSharp.so deleted file mode 100644 index 4950720..0000000 Binary files a/Build/runtimes/linux-x64/native/libSkiaSharp.so and /dev/null differ diff --git a/Build/runtimes/osx/native/libHarfBuzzSharp.dylib b/Build/runtimes/osx/native/libHarfBuzzSharp.dylib deleted file mode 100644 index c6b6888..0000000 Binary files a/Build/runtimes/osx/native/libHarfBuzzSharp.dylib and /dev/null differ diff --git a/Build/runtimes/osx/native/libSkiaSharp.dylib b/Build/runtimes/osx/native/libSkiaSharp.dylib deleted file mode 100644 index 9731583..0000000 Binary files a/Build/runtimes/osx/native/libSkiaSharp.dylib and /dev/null differ diff --git a/Build/runtimes/win-arm64/native/libHarfBuzzSharp.dll b/Build/runtimes/win-arm64/native/libHarfBuzzSharp.dll deleted file mode 100644 index ee36cd0..0000000 Binary files a/Build/runtimes/win-arm64/native/libHarfBuzzSharp.dll and /dev/null differ diff --git a/Build/runtimes/win-arm64/native/libSkiaSharp.dll b/Build/runtimes/win-arm64/native/libSkiaSharp.dll deleted file mode 100644 index 48404a0..0000000 Binary files a/Build/runtimes/win-arm64/native/libSkiaSharp.dll and /dev/null differ diff --git a/Build/runtimes/win-x64/native/libHarfBuzzSharp.dll b/Build/runtimes/win-x64/native/libHarfBuzzSharp.dll deleted file mode 100644 index 01deb29..0000000 Binary files a/Build/runtimes/win-x64/native/libHarfBuzzSharp.dll and /dev/null differ diff --git a/Build/runtimes/win-x64/native/libSkiaSharp.dll b/Build/runtimes/win-x64/native/libSkiaSharp.dll deleted file mode 100644 index 3f8c6f2..0000000 Binary files a/Build/runtimes/win-x64/native/libSkiaSharp.dll and /dev/null differ diff --git a/Build/runtimes/win-x86/native/libHarfBuzzSharp.dll b/Build/runtimes/win-x86/native/libHarfBuzzSharp.dll deleted file mode 100644 index ac87173..0000000 Binary files a/Build/runtimes/win-x86/native/libHarfBuzzSharp.dll and /dev/null differ diff --git a/Build/runtimes/win-x86/native/libSkiaSharp.dll b/Build/runtimes/win-x86/native/libSkiaSharp.dll deleted file mode 100644 index 655f773..0000000 Binary files a/Build/runtimes/win-x86/native/libSkiaSharp.dll and /dev/null differ diff --git a/Scripts/Get-LatestBinaries.ps1 b/Scripts/Get-LatestBinaries.ps1 new file mode 100644 index 0000000..71d9c75 --- /dev/null +++ b/Scripts/Get-LatestBinaries.ps1 @@ -0,0 +1,73 @@ +$ErrorActionPreference = "Stop" + +$OWNER = "xunafay" +$REPO = "NasdaqTradeSystem" +$ARTIFACT_NAME = "build-artifact" +$OUTPUT_DIR = "./Build" +$COMMIT_LOOKAHEAD = 3 + +if (-not (Get-Command "gh" -ErrorAction SilentlyContinue)) { + echo "GitHub CLI is not installed" + exit 1 +} + +$CURRENT_COMMIT = git rev-parse HEAD +$CURRENT_BRANCH = git rev-parse --abbrev-ref HEAD + +if ($CURRENT_BRANCH -ne "master") { + $BASE_COMMIT = git rev-parse origin/master +} else { + $BASE_COMMIT = $CURRENT_COMMIT +} + +echo "Starting from commit: $BASE_COMMIT" + +$COMMITS = git rev-list --reverse --topo-order "$BASE_COMMIT"..origin/master | Select-Object -First $COMMIT_LOOKAHEAD +$COMMITS = @($BASE_COMMIT) + $COMMITS + +echo "Querying GitHub API for workflow runs" + +foreach ($COMMIT in $COMMITS) { + echo "Looking for workflow run for commit $COMMIT" + + $RUN_ID = gh run list ` + --repo "$OWNER/$REPO" ` + --limit 100 ` + --json databaseId,headSha,name,status ` + --jq ".[] | select(.headSha == `"$COMMIT`" and .name == `"Build main solution`" and .status == `"completed`") | .databaseId" | + Select-Object -First 1 + + if ($RUN_ID) { + echo "Found run ID $RUN_ID for $COMMIT" + + $ARTIFACTS_JSON = gh api repos/$OWNER/$REPO/actions/runs/$RUN_ID/artifacts | ConvertFrom-Json + $ARTIFACT_ID = $ARTIFACTS_JSON.artifacts | + Where-Object { $_.name -eq $ARTIFACT_NAME } | + Select-Object -ExpandProperty id -First 1 + + if ($ARTIFACT_ID) { + echo "Found artifact ID $ARTIFACT_ID for $ARTIFACT_NAME" + + if (-not (Test-Path $OUTPUT_DIR)) { + New-Item -ItemType Directory -Path $OUTPUT_DIR | Out-Null + } + + Get-ChildItem -Path $OUTPUT_DIR -Force | + Where-Object { $_.Name -ne "Results" } | + Remove-Item -Recurse -Force + + gh run download $RUN_ID ` + --repo "$OWNER/$REPO" ` + --name "$ARTIFACT_NAME" ` + --dir $OUTPUT_DIR + + echo "Downloaded artifact to $OUTPUT_DIR" + echo "Extracted to $OUTPUT_DIR" + exit 0 + } + } +} + +echo "No artifact found for the last $COMMIT_LOOKAHEAD commits from $BASE_COMMIT" +exit 1 + diff --git a/Scripts/get-latest-binaries.sh b/Scripts/get-latest-binaries.sh new file mode 100755 index 0000000..041ced6 --- /dev/null +++ b/Scripts/get-latest-binaries.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +set -e + +OWNER="xunafay" +REPO="NasdaqTradeSystem" +BRANCH="master" +ARTIFACT_NAME="build-artifact" +OUTPUT_DIR="./Build" +COMMIT_LOOKAHEAD=3 # GitHub allows up to 60 unauthenticated requests/hour per IP, so we limit to 3 commits + +if ! command -v gh >/dev/null 2>&1; then + echo "GitHub CLI is not installed" + exit 1 +fi + +CURRENT_COMMIT=$(git rev-parse HEAD) +CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) + +if [ "$CURRENT_BRANCH" != "$BRANCH" ]; then + BASE_COMMIT=$(git rev-parse origin/$BRANCH) +else + BASE_COMMIT=$CURRENT_COMMIT +fi + +echo "Starting from commit: $BASE_COMMIT" + +COMMITS=$(git rev-list --reverse --topo-order "$BASE_COMMIT"..origin/$BRANCH | head -n "$COMMIT_LOOKAHEAD") +COMMITS="$BASE_COMMIT"$'\n'"$COMMITS" + +echo "Querying GitHub API for workflow runs" +RUNS_JSON=$(curl -s "https://api.github.com/repos/$OWNER/$REPO/actions/runs?per_page=100") + +for COMMIT in $COMMITS; do + echo "Looking for workflow run for commit $COMMIT" + + RUN_ID=$(gh run list \ + --repo "$OWNER/$REPO" \ + --limit 100 \ + --json databaseId,headSha,name,status \ + --jq ".[] | select(.headSha == \"$COMMIT\" and .name == \"Build main solution\" and .status == \"completed\") | .databaseId" | head -n 1) + + + if [ -n "$RUN_ID" ]; then + echo "Found run ID $RUN_ID for $COMMIT" + + ARTIFACTS_JSON=$(curl -s "https://api.github.com/repos/$OWNER/$REPO/actions/runs/$RUN_ID/artifacts") + ARTIFACT_ID=$(echo "$ARTIFACTS_JSON" | jq -r \ + --arg NAME "$ARTIFACT_NAME" \ + '.artifacts[] | select(.name == $NAME) | .id' | head -n 1) + + if [ -n "$ARTIFACT_ID" ]; then + echo "Found artifact ID $ARTIFACT_ID for $ARTIFACT_NAME" + + mkdir -p "$OUTPUT_DIR" + + find "$OUTPUT_DIR" -mindepth 1 -not -name "Results" -exec rm -rf {} + + + gh run download "$RUN_ID" \ + --repo "$OWNER/$REPO" \ + --name "$ARTIFACT_NAME" \ + --dir "$OUTPUT_DIR" + + echo "Downloaded artifact to $OUTPUT_DIR" + echo "Extracted to $OUTPUT_DIR" + exit 0 + fi + fi +done + +echo "No artifact found for the last $COMMIT_LOOKAHEAD commits from $BASE_COMMIT" +exit 1 +