Skip to content

Commit

Permalink
Ship monitoring plugin attempt 1
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Mar 25, 2024
1 parent f98fd85 commit cb9e67d
Showing 1 changed file with 91 additions and 15 deletions.
106 changes: 91 additions & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ env:
DOTNET_NOLOGO: true
DOTNET_SDK_VERSION: 8.0
NODE_JS_VERSION: 'lts/*'
PLUGINS: ArchiSteamFarm.OfficialPlugins.ItemsMatcher ArchiSteamFarm.OfficialPlugins.MobileAuthenticator ArchiSteamFarm.OfficialPlugins.SteamTokenDumper
PLUGINS_BUNDLED: ArchiSteamFarm.OfficialPlugins.ItemsMatcher ArchiSteamFarm.OfficialPlugins.MobileAuthenticator ArchiSteamFarm.OfficialPlugins.SteamTokenDumper
PLUGINS_INCLUDED: ArchiSteamFarm.OfficialPlugins.Monitoring # Apart from declaring them here, there is certain amount of hardcoding needed below for uploading

permissions: {}

Expand Down Expand Up @@ -191,14 +192,49 @@ jobs:
publish() {
dotnet publish "$1" -c "$CONFIGURATION" -o "out/${1}" -p:ContinuousIntegrationBuild=true -p:TargetLatestRuntimePatch=false -p:UseAppHost=false --no-restore --nologo
if [ "$2" -eq 0 ]; then
return
fi
# By default use fastest compression
seven_zip_args="-mx=1"
zip_args="-1"
# Include extra logic for builds marked for release
case "$GITHUB_REF" in
"refs/tags/"*)
# Tweak compression args for release publishing
seven_zip_args="-mx=9 -mfb=258 -mpass=15"
zip_args="-9"
;;
esac
# Create the final zip file
if command -v 7z >/dev/null; then
7z a -bd -slp -tzip -mm=Deflate $seven_zip_args "out/${1}.zip" "${GITHUB_WORKSPACE}/out/${1}/*"
else
(
cd "${GITHUB_WORKSPACE}/out/${1}"
zip -q -r $zip_args "../${1}.zip" .
)
fi
}
for plugin in $PLUGINS; do
for plugin in $PLUGINS_BUNDLED; do
while [ "$(jobs -p | wc -l)" -ge "$MAX_JOBS" ]; do
sleep 1
done
publish "$plugin" &
publish "$plugin" 0 &
done
for plugin in $PLUGINS_INCLUDED; do
while [ "$(jobs -p | wc -l)" -ge "$MAX_JOBS" ]; do
sleep 1
done
publish "$plugin" 1 &
done
wait
Expand All @@ -215,6 +251,7 @@ jobs:
$PublishBlock = {
param($plugin)
param($bundled)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
Expand All @@ -227,9 +264,29 @@ jobs:
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
if ($bundled) {
return
}
# By default use fastest compression
$compressionArgs = '-mx=1'
# Include extra logic for builds marked for release
if ($env:GITHUB_REF -like 'refs/tags/*') {
# Tweak compression args for release publishing
$compressionArgs = '-mx=9', '-mfb=258', '-mpass=15'
}
# Create the final zip file
7z a -bd -slp -tzip -mm=Deflate $compressionArgs "out\$plugin.zip" "$env:GITHUB_WORKSPACE\out\$plugin\*"
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
}
foreach ($plugin in $env:PLUGINS.Split([char[]] $null, [System.StringSplitOptions]::RemoveEmptyEntries)) {
foreach ($plugin in $env:PLUGINS_BUNDLED.Split([char[]] $null, [System.StringSplitOptions]::RemoveEmptyEntries)) {
# Limit active jobs in parallel to help with memory usage
$jobs = $(Get-Job -State Running)
Expand All @@ -239,11 +296,30 @@ jobs:
$jobs = $(Get-Job -State Running)
}
Start-Job -Name "$plugin" $PublishBlock -ArgumentList "$plugin"
Start-Job -Name "$plugin" $PublishBlock -ArgumentList "$plugin", true
}
foreach ($plugin in $env:PLUGINS_INCLUDED.Split([char[]] $null, [System.StringSplitOptions]::RemoveEmptyEntries)) {
# Limit active jobs in parallel to help with memory usage
$jobs = $(Get-Job -State Running)
while (@($jobs).Count -ge $env:MAX_JOBS) {
Wait-Job -Job $jobs -Any | Out-Null
$jobs = $(Get-Job -State Running)
}
Start-Job -Name "$plugin" $PublishBlock -ArgumentList "$plugin", false
}
Get-Job | Receive-Job -Wait
- name: Upload ArchiSteamFarm.OfficialPlugins.Monitoring
uses: actions/[email protected]
with:
name: ${{ matrix.os }}_ArchiSteamFarm.OfficialPlugins.Monitoring
path: out/ArchiSteamFarm.OfficialPlugins.Monitoring.zip

- name: Publish ASF-${{ matrix.variant }} on Unix
if: startsWith(matrix.os, 'macos-') || startsWith(matrix.os, 'ubuntu-')
env:
Expand All @@ -261,7 +337,7 @@ jobs:
dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -o "out/${VARIANT}" "-p:ASFVariant=${VARIANT}" -p:ContinuousIntegrationBuild=true --nologo $variantArgs
# If we're including official plugins for this framework, copy them to output directory
for plugin in $PLUGINS; do
for plugin in $PLUGINS_BUNDLED; do
if [ -d "out/${plugin}" ]; then
mkdir -p "out/${VARIANT}/plugins/${plugin}"
cp -pR "out/${plugin}/"* "out/${VARIANT}/plugins/${plugin}"
Expand Down Expand Up @@ -301,24 +377,18 @@ jobs:
cd "${GITHUB_WORKSPACE}/out/${VARIANT}"
zip -q -r $zip_args "../ASF-${VARIANT}.zip" .
)
elif command -v 7z >/dev/null; then
7z a -bd -slp -tzip -mm=Deflate $seven_zip_args "out/ASF-${VARIANT}.zip" "${GITHUB_WORKSPACE}/out/${VARIANT}/*"
else
echo "ERROR: No supported zip tool!"
return 1
7z a -bd -slp -tzip -mm=Deflate $seven_zip_args "out/ASF-${VARIANT}.zip" "${GITHUB_WORKSPACE}/out/${VARIANT}/*"
fi
;;
*)
if command -v 7z >/dev/null; then
7z a -bd -slp -tzip -mm=Deflate $seven_zip_args "out/ASF-${VARIANT}.zip" "${GITHUB_WORKSPACE}/out/${VARIANT}/*"
elif command -v zip >/dev/null; then
else
(
cd "${GITHUB_WORKSPACE}/out/${VARIANT}"
zip -q -r $zip_args "../ASF-${VARIANT}.zip" .
)
else
echo "ERROR: No supported zip tool!"
return 1
fi
;;
esac
Expand Down Expand Up @@ -346,7 +416,7 @@ jobs:
}
# If we're including official plugins for this framework, copy them to output directory
foreach ($plugin in $env:PLUGINS.Split([char[]] $null, [System.StringSplitOptions]::RemoveEmptyEntries)) {
foreach ($plugin in $env:PLUGINS_BUNDLED.Split([char[]] $null, [System.StringSplitOptions]::RemoveEmptyEntries)) {
if (Test-Path "out\$plugin" -PathType Container) {
if (!(Test-Path "out\$env:VARIANT\plugins\$plugin" -PathType Container)) {
New-Item -ItemType Directory -Path "out\$env:VARIANT\plugins\$plugin" > $null
Expand Down Expand Up @@ -424,6 +494,12 @@ jobs:
with:
show-progress: false

- name: Download ArchiSteamFarm.OfficialPlugins.Monitoring artifact from ubuntu-latest
uses: actions/[email protected]
with:
name: ubuntu-latest_ArchiSteamFarm.OfficialPlugins.Monitoring
path: out

- name: Download ASF-generic artifact from ubuntu-latest
uses: actions/[email protected]
with:
Expand Down

0 comments on commit cb9e67d

Please sign in to comment.