diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4decf0f31..91709666f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,11 +7,6 @@ env: DOTNET_CLI_TELEMETRY_OPTOUT: 1 DOTNET_NOLOGO: 1 DOTNET_SDK_VERSION: 5.0.x - NET_CORE_VERSION: net5.0 - NET_FRAMEWORK_VERSION: net48 - NODE_JS_VERSION: 14 # Periodically bumped to follow latest LTS | https://github.com/actions/setup-node/issues/26 - STEAM_TOKEN_DUMPER_NAME: ArchiSteamFarm.OfficialPlugins.SteamTokenDumper - STEAM_TOKEN_DUMPER_TOKEN: ${{ secrets.STEAM_TOKEN_DUMPER_TOKEN }} jobs: main: @@ -36,24 +31,6 @@ jobs: - name: Verify .NET Core run: dotnet --info - - name: Setup Node.js with npm - uses: actions/setup-node@v2 - with: - check-latest: true - node-version: ${{ env.NODE_JS_VERSION }} - - - name: Verify Node.js - run: node -v - - - name: Verify npm - run: npm -v - - - name: Install npm modules for ASF-ui - run: npm ci --no-progress --prefix ASF-ui - - - name: Build ASF-ui - run: npm run-script deploy --no-progress --prefix ASF-ui - - name: Build ArchiSteamFarm and other projects run: dotnet build -c "${{ env.CONFIGURATION }}" -p:ContinuousIntegrationBuild=true -p:UseAppHost=false --nologo @@ -69,316 +46,3 @@ jobs: config: '.github/crowdin.yml' project_id: ${{ secrets.ASF_CROWDIN_PROJECT_ID }} token: ${{ secrets.ASF_CROWDIN_API_TOKEN }} - - - name: Prepare ArchiSteamFarm.OfficialPlugins.SteamTokenDumper on Unix - if: startsWith(matrix.os, 'macos-') || startsWith(matrix.os, 'ubuntu-') - shell: sh - run: | - if [ -n "${STEAM_TOKEN_DUMPER_TOKEN-}" ] && [ -f "${STEAM_TOKEN_DUMPER_NAME}/SharedInfo.cs" ]; then - sed "s/STEAM_TOKEN_DUMPER_TOKEN/${STEAM_TOKEN_DUMPER_TOKEN}/g" "${STEAM_TOKEN_DUMPER_NAME}/SharedInfo.cs" > "${STEAM_TOKEN_DUMPER_NAME}/SharedInfo.cs.new" - mv "${STEAM_TOKEN_DUMPER_NAME}/SharedInfo.cs.new" "${STEAM_TOKEN_DUMPER_NAME}/SharedInfo.cs" - fi - - - name: Prepare ArchiSteamFarm.OfficialPlugins.SteamTokenDumper on Windows - if: startsWith(matrix.os, 'windows-') - shell: pwsh - run: | - Set-StrictMode -Version Latest - $ErrorActionPreference = 'Stop' - $ProgressPreference = 'SilentlyContinue' - - if ((Test-Path env:STEAM_TOKEN_DUMPER_TOKEN) -and (Test-Path "$env:STEAM_TOKEN_DUMPER_NAME\SharedInfo.cs" -PathType Leaf)) { - (Get-Content "$env:STEAM_TOKEN_DUMPER_NAME\SharedInfo.cs").Replace('STEAM_TOKEN_DUMPER_TOKEN', "$env:STEAM_TOKEN_DUMPER_TOKEN") | Set-Content "$env:STEAM_TOKEN_DUMPER_NAME\SharedInfo.cs" - } - - - name: Publish ArchiSteamFarm.OfficialPlugins.SteamTokenDumper for .NET Core - run: dotnet publish "${{ env.STEAM_TOKEN_DUMPER_NAME }}" -c "${{ env.CONFIGURATION }}" -f "${{ env.NET_CORE_VERSION }}" -o "out/${{ env.STEAM_TOKEN_DUMPER_NAME }}/${{ env.NET_CORE_VERSION }}" -p:ContinuousIntegrationBuild=true -p:TargetLatestRuntimePatch=false -p:UseAppHost=false --nologo - - - name: Publish ArchiSteamFarm.OfficialPlugins.SteamTokenDumper for .NET Framework - if: startsWith(matrix.os, 'windows-') - run: dotnet publish "${{ env.STEAM_TOKEN_DUMPER_NAME }}" -c "${{ env.CONFIGURATION }}" -f "${{ env.NET_FRAMEWORK_VERSION }}" -o "out/${{ env.STEAM_TOKEN_DUMPER_NAME }}/${{ env.NET_FRAMEWORK_VERSION }}" -p:ContinuousIntegrationBuild=true -p:TargetLatestRuntimePatch=false -p:UseAppHost=false --nologo - - - name: Perform cleanup of ArchiSteamFarm in preparation for publishing - run: dotnet clean ArchiSteamFarm -c "${{ env.CONFIGURATION }}" -p:ContinuousIntegrationBuild=true -p:UseAppHost=false --nologo - - - name: Restore packages in preparation for ArchiSteamFarm publishing - run: dotnet restore ArchiSteamFarm -p:ContinuousIntegrationBuild=true - - - name: Publish ArchiSteamFarm on Unix - if: startsWith(matrix.os, 'macos-') || startsWith(matrix.os, 'ubuntu-') - env: - VARIANTS: generic linux-arm linux-arm64 linux-x64 osx-x64 win-x64 # NOTE: When modifying variants, don't forget to update ASF_VARIANT definitions in SharedInfo.cs! - shell: sh - run: | - set -eu - - publish() { - if [ "$1" = 'generic' ]; then - local variantArgs="-p:TargetLatestRuntimePatch=false -p:UseAppHost=false" - else - local variantArgs="-p:PublishSingleFile=true -p:PublishTrimmed=true -r $1" - fi - - dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o "out/${1}" "-p:ASFVariant=$1" -p:ContinuousIntegrationBuild=true --no-restore --nologo $variantArgs - - # If we're including any overlay for this variant, copy it to output directory - if [ -d "ArchiSteamFarm/overlay/${1}" ]; then - cp -pR "ArchiSteamFarm/overlay/${1}/"* "out/${1}" - fi - - # If we're including SteamTokenDumper plugin for this framework, copy it to output directory - if [ -d "out/${STEAM_TOKEN_DUMPER_NAME}/${NET_CORE_VERSION}" ]; then - mkdir -p "out/${1}/plugins/${STEAM_TOKEN_DUMPER_NAME}" - cp -pR "out/${STEAM_TOKEN_DUMPER_NAME}/${NET_CORE_VERSION}/"* "out/${1}/plugins/${STEAM_TOKEN_DUMPER_NAME}" - fi - - # Include .ico file for all platforms, since only Windows script can bundle it inside the exe - cp "resources/ASF.ico" "out/${1}/ArchiSteamFarm.ico" - - if command -v 7z >/dev/null; then - 7z a -bd -slp -tzip -mm=Deflate -mx=1 "out/ASF-${1}.zip" "${GITHUB_WORKSPACE}/out/${1}/*" - elif command -v zip >/dev/null; then - ( - cd "${GITHUB_WORKSPACE}/out/${1}" - zip -1 -q -r "../ASF-${1}.zip" . - ) - else - echo "ERROR: No supported zip tool!" - return 1 - fi - } - - jobs="" - - for variant in $VARIANTS; do - publish "$variant" & - jobs="$jobs $!" - done - - for job in $jobs; do - wait "$job" - done - - - name: Publish ArchiSteamFarm on Windows - if: startsWith(matrix.os, 'windows-') - env: - VARIANTS: generic generic-netf linux-arm linux-arm64 linux-x64 osx-x64 win-x64 # NOTE: When modifying variants, don't forget to update ASF_VARIANT definitions in SharedInfo.cs! - shell: pwsh - run: | - Set-StrictMode -Version Latest - $ErrorActionPreference = 'Stop' - $ProgressPreference = 'SilentlyContinue' - - $PublishBlock = { - param($variant) - - Set-StrictMode -Version Latest - $ErrorActionPreference = 'Stop' - $ProgressPreference = 'SilentlyContinue' - - Set-Location "$env:GITHUB_WORKSPACE" - - if ($variant -like '*-netf') { - $targetFramework = $env:NET_FRAMEWORK_VERSION - } else { - $targetFramework = $env:NET_CORE_VERSION - } - - if ($variant -like 'generic*') { - $variantArgs = '-p:TargetLatestRuntimePatch=false', '-p:UseAppHost=false' - } else { - $variantArgs = '-p:PublishSingleFile=true', '-p:PublishTrimmed=true', '-r', "$variant" - } - - dotnet publish ArchiSteamFarm -c "$env:CONFIGURATION" -f "$targetFramework" -o "out\$variant" "-p:ASFVariant=$variant" -p:ContinuousIntegrationBuild=true --no-restore --nologo $variantArgs - - if ($LastExitCode -ne 0) { - throw "Last command failed." - } - - # If we're including any overlay for this variant, copy it to output directory - if (Test-Path "ArchiSteamFarm\overlay\$variant" -PathType Container) { - Copy-Item "ArchiSteamFarm\overlay\$variant\*" "out\$variant" -Recurse - } - - # If we're including SteamTokenDumper plugin for this framework, copy it to output directory - if (Test-Path "out\$env:STEAM_TOKEN_DUMPER_NAME\$targetFramework" -PathType Container) { - if (!(Test-Path "out\$variant\plugins\$env:STEAM_TOKEN_DUMPER_NAME" -PathType Container)) { - New-Item -ItemType Directory -Path "out\$variant\plugins\$env:STEAM_TOKEN_DUMPER_NAME" > $null - } - - Copy-Item "out\$env:STEAM_TOKEN_DUMPER_NAME\$targetFramework\*" "out\$variant\plugins\$env:STEAM_TOKEN_DUMPER_NAME" -Recurse - } - - # Icon is available only in .NET Framework and .NET Core Windows build, we'll bundle the .ico file for other flavours - if (($targetFramework -eq "$env:NET_CORE_VERSION") -and !(Test-Path "out\$variant\ArchiSteamFarm.exe" -PathType Leaf)) { - Copy-Item 'resources\ASF.ico' "out\$variant\ArchiSteamFarm.ico" - } - - # By default use fastest compression - $compressionArgs = '-mx=1' - - # Include extra logic for builds marked for release - if ($env:GITHUB_REF -like 'refs/tags/*') { - $tag = $env:GITHUB_REF.Substring(10) - - # Tweak compression args for release publishing - $compressionArgs = '-mx=9', '-mfb=258', '-mpass=15' - - # Update link in Changelog.html accordingly - if (Test-Path "out\$variant\Changelog.html" -PathType Leaf) { - (Get-Content "out\$variant\Changelog.html").Replace('ArchiSteamFarm/commits/main', "ArchiSteamFarm/releases/tag/$tag") | Set-Content "out\$variant\Changelog.html" - } - } - - 7z a -bd -slp -tzip -mm=Deflate $compressionArgs "out\ASF-$variant.zip" "$env:GITHUB_WORKSPACE\out\$variant\*" - - if ($LastExitCode -ne 0) { - throw "Last command failed." - } - } - - foreach ($variant in $env:VARIANTS.Split([char[]] $null, [System.StringSplitOptions]::RemoveEmptyEntries)) { - Start-Job -Name "$variant" $PublishBlock -ArgumentList "$variant" - } - - Get-Job | Receive-Job -Wait - - - name: Upload ASF-generic - continue-on-error: true - uses: actions/upload-artifact@v2 - with: - name: ${{ matrix.os }}_ASF-generic - path: out/ASF-generic.zip - - - name: Upload ASF-generic-netf - continue-on-error: true - if: startsWith(matrix.os, 'windows-') - uses: actions/upload-artifact@v2 - with: - name: ${{ matrix.os }}_ASF-generic-netf - path: out/ASF-generic-netf.zip - - - name: Upload ASF-linux-arm - continue-on-error: true - uses: actions/upload-artifact@v2 - with: - name: ${{ matrix.os }}_ASF-linux-arm - path: out/ASF-linux-arm.zip - - - name: Upload ASF-linux-arm64 - continue-on-error: true - uses: actions/upload-artifact@v2 - with: - name: ${{ matrix.os }}_ASF-linux-arm64 - path: out/ASF-linux-arm64.zip - - - name: Upload ASF-linux-x64 - continue-on-error: true - uses: actions/upload-artifact@v2 - with: - name: ${{ matrix.os }}_ASF-linux-x64 - path: out/ASF-linux-x64.zip - - - name: Upload ASF-osx-x64 - continue-on-error: true - uses: actions/upload-artifact@v2 - with: - name: ${{ matrix.os }}_ASF-osx-x64 - path: out/ASF-osx-x64.zip - - - name: Upload ASF-win-x64 - continue-on-error: true - uses: actions/upload-artifact@v2 - with: - name: ${{ matrix.os }}_ASF-win-x64 - path: out/ASF-win-x64.zip - - - name: Create ArchiSteamFarm GitHub release - id: github_release - if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'windows-') }} - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: ArchiSteamFarm V${{ github.ref }} - body_path: .github/RELEASE_TEMPLATE.md - prerelease: true - - - name: Upload ASF-generic to GitHub release - if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'windows-') }} - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.github_release.outputs.upload_url }} - asset_path: out/ASF-generic.zip - asset_name: ASF-generic.zip - asset_content_type: application/zip - - - name: Upload ASF-generic-netf to GitHub release - if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'windows-') }} - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.github_release.outputs.upload_url }} - asset_path: out/ASF-generic-netf.zip - asset_name: ASF-generic-netf.zip - asset_content_type: application/zip - - - name: Upload ASF-linux-arm to GitHub release - if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'windows-') }} - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.github_release.outputs.upload_url }} - asset_path: out/ASF-linux-arm.zip - asset_name: ASF-linux-arm.zip - asset_content_type: application/zip - - - name: Upload ASF-linux-arm64 to GitHub release - if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'windows-') }} - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.github_release.outputs.upload_url }} - asset_path: out/ASF-linux-arm64.zip - asset_name: ASF-linux-arm64.zip - asset_content_type: application/zip - - - name: Upload ASF-linux-x64 to GitHub release - if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'windows-') }} - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.github_release.outputs.upload_url }} - asset_path: out/ASF-linux-x64.zip - asset_name: ASF-linux-x64.zip - asset_content_type: application/zip - - - name: Upload ASF-osx-x64 to GitHub release - if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'windows-') }} - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.github_release.outputs.upload_url }} - asset_path: out/ASF-osx-x64.zip - asset_name: ASF-osx-x64.zip - asset_content_type: application/zip - - - name: Upload ASF-win-x64 to GitHub release - if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'windows-') }} - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.github_release.outputs.upload_url }} - asset_path: out/ASF-win-x64.zip - asset_name: ASF-win-x64.zip - asset_content_type: application/zip diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml new file mode 100644 index 000000000..9a241217b --- /dev/null +++ b/.github/workflows/docker-ci.yml @@ -0,0 +1,29 @@ +name: ASF-docker-ci + +on: [push, pull_request] + +jobs: + main: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build Docker image from Dockerfile + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/amd64,linux/arm,linux/arm64 + + - name: Build Docker image from Dockerfile.Service + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile.Service + platforms: linux/amd64,linux/arm,linux/arm64 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..6bfbbd233 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,365 @@ +name: ASF-publish + +on: [push, pull_request] + +env: + CONFIGURATION: Release + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_NOLOGO: 1 + DOTNET_SDK_VERSION: 5.0.x + NET_CORE_VERSION: net5.0 + NET_FRAMEWORK_VERSION: net48 + NODE_JS_VERSION: 14 # Periodically bumped to follow latest LTS | https://github.com/actions/setup-node/issues/26 + STEAM_TOKEN_DUMPER_NAME: ArchiSteamFarm.OfficialPlugins.SteamTokenDumper + STEAM_TOKEN_DUMPER_TOKEN: ${{ secrets.STEAM_TOKEN_DUMPER_TOKEN }} + +jobs: + main: + strategy: + fail-fast: false + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: ${{ env.DOTNET_SDK_VERSION }} + + - name: Verify .NET Core + run: dotnet --info + + - name: Setup Node.js with npm + uses: actions/setup-node@v2 + with: + check-latest: true + node-version: ${{ env.NODE_JS_VERSION }} + + - name: Verify Node.js + run: node -v + + - name: Verify npm + run: npm -v + + - name: Install npm modules for ASF-ui + run: npm ci --no-progress --prefix ASF-ui + + - name: Publish ASF-ui + run: npm run-script deploy --no-progress --prefix ASF-ui + + - name: Prepare ArchiSteamFarm.OfficialPlugins.SteamTokenDumper on Unix + if: startsWith(matrix.os, 'macos-') || startsWith(matrix.os, 'ubuntu-') + shell: sh + run: | + if [ -n "${STEAM_TOKEN_DUMPER_TOKEN-}" ] && [ -f "${STEAM_TOKEN_DUMPER_NAME}/SharedInfo.cs" ]; then + sed "s/STEAM_TOKEN_DUMPER_TOKEN/${STEAM_TOKEN_DUMPER_TOKEN}/g" "${STEAM_TOKEN_DUMPER_NAME}/SharedInfo.cs" > "${STEAM_TOKEN_DUMPER_NAME}/SharedInfo.cs.new" + mv "${STEAM_TOKEN_DUMPER_NAME}/SharedInfo.cs.new" "${STEAM_TOKEN_DUMPER_NAME}/SharedInfo.cs" + fi + + - name: Prepare ArchiSteamFarm.OfficialPlugins.SteamTokenDumper on Windows + if: startsWith(matrix.os, 'windows-') + shell: pwsh + run: | + Set-StrictMode -Version Latest + $ErrorActionPreference = 'Stop' + $ProgressPreference = 'SilentlyContinue' + + if ((Test-Path env:STEAM_TOKEN_DUMPER_TOKEN) -and (Test-Path "$env:STEAM_TOKEN_DUMPER_NAME\SharedInfo.cs" -PathType Leaf)) { + (Get-Content "$env:STEAM_TOKEN_DUMPER_NAME\SharedInfo.cs").Replace('STEAM_TOKEN_DUMPER_TOKEN', "$env:STEAM_TOKEN_DUMPER_TOKEN") | Set-Content "$env:STEAM_TOKEN_DUMPER_NAME\SharedInfo.cs" + } + + - name: Publish ArchiSteamFarm.OfficialPlugins.SteamTokenDumper for .NET Core + run: dotnet publish "${{ env.STEAM_TOKEN_DUMPER_NAME }}" -c "${{ env.CONFIGURATION }}" -f "${{ env.NET_CORE_VERSION }}" -o "out/${{ env.STEAM_TOKEN_DUMPER_NAME }}/${{ env.NET_CORE_VERSION }}" -p:ContinuousIntegrationBuild=true -p:TargetLatestRuntimePatch=false -p:UseAppHost=false --nologo + + - name: Publish ArchiSteamFarm.OfficialPlugins.SteamTokenDumper for .NET Framework + if: startsWith(matrix.os, 'windows-') + run: dotnet publish "${{ env.STEAM_TOKEN_DUMPER_NAME }}" -c "${{ env.CONFIGURATION }}" -f "${{ env.NET_FRAMEWORK_VERSION }}" -o "out/${{ env.STEAM_TOKEN_DUMPER_NAME }}/${{ env.NET_FRAMEWORK_VERSION }}" -p:ContinuousIntegrationBuild=true -p:TargetLatestRuntimePatch=false -p:UseAppHost=false --nologo + + - name: Restore packages in preparation for ArchiSteamFarm publishing + run: dotnet restore ArchiSteamFarm -p:ContinuousIntegrationBuild=true + + - name: Publish ArchiSteamFarm on Unix + if: startsWith(matrix.os, 'macos-') || startsWith(matrix.os, 'ubuntu-') + env: + VARIANTS: generic linux-arm linux-arm64 linux-x64 osx-x64 win-x64 # NOTE: When modifying variants, don't forget to update ASF_VARIANT definitions in SharedInfo.cs! + shell: sh + run: | + set -eu + + publish() { + if [ "$1" = 'generic' ]; then + local variantArgs="-p:TargetLatestRuntimePatch=false -p:UseAppHost=false" + else + local variantArgs="-p:PublishSingleFile=true -p:PublishTrimmed=true -r $1" + fi + + dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o "out/${1}" "-p:ASFVariant=$1" -p:ContinuousIntegrationBuild=true --no-restore --nologo $variantArgs + + # If we're including any overlay for this variant, copy it to output directory + if [ -d "ArchiSteamFarm/overlay/${1}" ]; then + cp -pR "ArchiSteamFarm/overlay/${1}/"* "out/${1}" + fi + + # If we're including SteamTokenDumper plugin for this framework, copy it to output directory + if [ -d "out/${STEAM_TOKEN_DUMPER_NAME}/${NET_CORE_VERSION}" ]; then + mkdir -p "out/${1}/plugins/${STEAM_TOKEN_DUMPER_NAME}" + cp -pR "out/${STEAM_TOKEN_DUMPER_NAME}/${NET_CORE_VERSION}/"* "out/${1}/plugins/${STEAM_TOKEN_DUMPER_NAME}" + fi + + # Include .ico file for all platforms, since only Windows script can bundle it inside the exe + cp "resources/ASF.ico" "out/${1}/ArchiSteamFarm.ico" + + if command -v 7z >/dev/null; then + 7z a -bd -slp -tzip -mm=Deflate -mx=1 "out/ASF-${1}.zip" "${GITHUB_WORKSPACE}/out/${1}/*" + elif command -v zip >/dev/null; then + ( + cd "${GITHUB_WORKSPACE}/out/${1}" + zip -1 -q -r "../ASF-${1}.zip" . + ) + else + echo "ERROR: No supported zip tool!" + return 1 + fi + } + + jobs="" + + for variant in $VARIANTS; do + publish "$variant" & + jobs="$jobs $!" + done + + for job in $jobs; do + wait "$job" + done + + - name: Publish ArchiSteamFarm on Windows + if: startsWith(matrix.os, 'windows-') + env: + VARIANTS: generic generic-netf linux-arm linux-arm64 linux-x64 osx-x64 win-x64 # NOTE: When modifying variants, don't forget to update ASF_VARIANT definitions in SharedInfo.cs! + shell: pwsh + run: | + Set-StrictMode -Version Latest + $ErrorActionPreference = 'Stop' + $ProgressPreference = 'SilentlyContinue' + + $PublishBlock = { + param($variant) + + Set-StrictMode -Version Latest + $ErrorActionPreference = 'Stop' + $ProgressPreference = 'SilentlyContinue' + + Set-Location "$env:GITHUB_WORKSPACE" + + if ($variant -like '*-netf') { + $targetFramework = $env:NET_FRAMEWORK_VERSION + } else { + $targetFramework = $env:NET_CORE_VERSION + } + + if ($variant -like 'generic*') { + $variantArgs = '-p:TargetLatestRuntimePatch=false', '-p:UseAppHost=false' + } else { + $variantArgs = '-p:PublishSingleFile=true', '-p:PublishTrimmed=true', '-r', "$variant" + } + + dotnet publish ArchiSteamFarm -c "$env:CONFIGURATION" -f "$targetFramework" -o "out\$variant" "-p:ASFVariant=$variant" -p:ContinuousIntegrationBuild=true --no-restore --nologo $variantArgs + + if ($LastExitCode -ne 0) { + throw "Last command failed." + } + + # If we're including any overlay for this variant, copy it to output directory + if (Test-Path "ArchiSteamFarm\overlay\$variant" -PathType Container) { + Copy-Item "ArchiSteamFarm\overlay\$variant\*" "out\$variant" -Recurse + } + + # If we're including SteamTokenDumper plugin for this framework, copy it to output directory + if (Test-Path "out\$env:STEAM_TOKEN_DUMPER_NAME\$targetFramework" -PathType Container) { + if (!(Test-Path "out\$variant\plugins\$env:STEAM_TOKEN_DUMPER_NAME" -PathType Container)) { + New-Item -ItemType Directory -Path "out\$variant\plugins\$env:STEAM_TOKEN_DUMPER_NAME" > $null + } + + Copy-Item "out\$env:STEAM_TOKEN_DUMPER_NAME\$targetFramework\*" "out\$variant\plugins\$env:STEAM_TOKEN_DUMPER_NAME" -Recurse + } + + # Icon is available only in .NET Framework and .NET Core Windows build, we'll bundle the .ico file for other flavours + if (($targetFramework -eq "$env:NET_CORE_VERSION") -and !(Test-Path "out\$variant\ArchiSteamFarm.exe" -PathType Leaf)) { + Copy-Item 'resources\ASF.ico' "out\$variant\ArchiSteamFarm.ico" + } + + # By default use fastest compression + $compressionArgs = '-mx=1' + + # Include extra logic for builds marked for release + if ($env:GITHUB_REF -like 'refs/tags/*') { + $tag = $env:GITHUB_REF.Substring(10) + + # Tweak compression args for release publishing + $compressionArgs = '-mx=9', '-mfb=258', '-mpass=15' + + # Update link in Changelog.html accordingly + if (Test-Path "out\$variant\Changelog.html" -PathType Leaf) { + (Get-Content "out\$variant\Changelog.html").Replace('ArchiSteamFarm/commits/main', "ArchiSteamFarm/releases/tag/$tag") | Set-Content "out\$variant\Changelog.html" + } + } + + 7z a -bd -slp -tzip -mm=Deflate $compressionArgs "out\ASF-$variant.zip" "$env:GITHUB_WORKSPACE\out\$variant\*" + + if ($LastExitCode -ne 0) { + throw "Last command failed." + } + } + + foreach ($variant in $env:VARIANTS.Split([char[]] $null, [System.StringSplitOptions]::RemoveEmptyEntries)) { + Start-Job -Name "$variant" $PublishBlock -ArgumentList "$variant" + } + + Get-Job | Receive-Job -Wait + + - name: Upload ASF-generic + continue-on-error: true + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.os }}_ASF-generic + path: out/ASF-generic.zip + + - name: Upload ASF-generic-netf + continue-on-error: true + if: startsWith(matrix.os, 'windows-') + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.os }}_ASF-generic-netf + path: out/ASF-generic-netf.zip + + - name: Upload ASF-linux-arm + continue-on-error: true + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.os }}_ASF-linux-arm + path: out/ASF-linux-arm.zip + + - name: Upload ASF-linux-arm64 + continue-on-error: true + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.os }}_ASF-linux-arm64 + path: out/ASF-linux-arm64.zip + + - name: Upload ASF-linux-x64 + continue-on-error: true + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.os }}_ASF-linux-x64 + path: out/ASF-linux-x64.zip + + - name: Upload ASF-osx-x64 + continue-on-error: true + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.os }}_ASF-osx-x64 + path: out/ASF-osx-x64.zip + + - name: Upload ASF-win-x64 + continue-on-error: true + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.os }}_ASF-win-x64 + path: out/ASF-win-x64.zip + + - name: Create ArchiSteamFarm GitHub release + id: github_release + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'windows-') }} + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ArchiSteamFarm V${{ github.ref }} + body_path: .github/RELEASE_TEMPLATE.md + prerelease: true + + - name: Upload ASF-generic to GitHub release + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'windows-') }} + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.github_release.outputs.upload_url }} + asset_path: out/ASF-generic.zip + asset_name: ASF-generic.zip + asset_content_type: application/zip + + - name: Upload ASF-generic-netf to GitHub release + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'windows-') }} + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.github_release.outputs.upload_url }} + asset_path: out/ASF-generic-netf.zip + asset_name: ASF-generic-netf.zip + asset_content_type: application/zip + + - name: Upload ASF-linux-arm to GitHub release + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'windows-') }} + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.github_release.outputs.upload_url }} + asset_path: out/ASF-linux-arm.zip + asset_name: ASF-linux-arm.zip + asset_content_type: application/zip + + - name: Upload ASF-linux-arm64 to GitHub release + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'windows-') }} + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.github_release.outputs.upload_url }} + asset_path: out/ASF-linux-arm64.zip + asset_name: ASF-linux-arm64.zip + asset_content_type: application/zip + + - name: Upload ASF-linux-x64 to GitHub release + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'windows-') }} + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.github_release.outputs.upload_url }} + asset_path: out/ASF-linux-x64.zip + asset_name: ASF-linux-x64.zip + asset_content_type: application/zip + + - name: Upload ASF-osx-x64 to GitHub release + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'windows-') }} + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.github_release.outputs.upload_url }} + asset_path: out/ASF-osx-x64.zip + asset_name: ASF-osx-x64.zip + asset_content_type: application/zip + + - name: Upload ASF-win-x64 to GitHub release + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'windows-') }} + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.github_release.outputs.upload_url }} + asset_path: out/ASF-win-x64.zip + asset_name: ASF-win-x64.zip + asset_content_type: application/zip