Upload #3
Workflow file for this run
This file contains hidden or 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: Upload | |
| on: workflow_dispatch | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| name: Upload | |
| if: ${{ github.actor == 'luau-project' && github.triggering_actor == 'luau-project' && github.repository == 'luau-project/LuaInstaller' }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: windows-latest | |
| arch: x86 | |
| - os: windows-latest | |
| arch: x64 | |
| - os: windows-11-arm | |
| arch: arm64 | |
| steps: | |
| - name: Check arch input | |
| run: | | |
| $allowed_archs = "x86", "x64", "arm64"; | |
| if (-not ($allowed_archs -contains "${{ matrix.arch }}")) | |
| { | |
| Write-Host "Arch not found"; | |
| exit 1; | |
| } | |
| - name: Checkout LuaInstaller | |
| uses: actions/checkout@v4 | |
| with: | |
| path: LuaInstaller | |
| ref: ${{ github.ref }} | |
| - name: Retrieve LuaInstaller version and store it on environment variable | |
| run: | | |
| $pattern = "\<Version\>(.*?)\<\/Version\>"; | |
| $csproj = Join-Path -Path "LuaInstaller" -ChildPath "LuaInstaller" | | |
| Join-Path -ChildPath "LuaInstaller.csproj"; | |
| $version_line = (Get-Content $csproj) -match $pattern | Select-Object -First 1; | |
| if (-not ($version_line -match $pattern)) | |
| { | |
| Write-Host "LuaInstaller version not found"; | |
| exit 1; | |
| } | |
| $version = $Matches[1]; | |
| $version = $version.Trim(); | |
| Add-Content "${{ github.env }}" "LUAINSTALLER_VERSION=${version}"; | |
| - name: Set environment variables | |
| run: | | |
| $wpf_dir = Join-Path "${{ runner.temp }}" -ChildPath LuaInstaller.EndUsers; | |
| $console_dir = Join-Path "${{ runner.temp }}" -ChildPath LuaInstaller.Console; | |
| Add-Content "${{ github.env }}" "WPF_DIR=${wpf_dir}"; | |
| Add-Content "${{ github.env }}" "CONSOLE_DIR=${console_dir}"; | |
| - name: Setup dotnet | |
| run: | | |
| $dotnet_dir = Join-Path -Path "${{ runner.temp }}" -ChildPath "dotnet-dir"; | |
| New-Item $dotnet_dir -ItemType Directory; | |
| $dotnet_install_file = Join-Path -Path $dotnet_dir -ChildPath "dotnet-install.ps1"; | |
| $dotnet_runner = Join-Path -Path $dotnet_dir -ChildPath "dotnet"; | |
| Invoke-WebRequest -Uri 'https://dot.net/v1/dotnet-install.ps1' -UseBasicParsing -OutFile $dotnet_install_file; | |
| & $dotnet_install_file -Architecture "${{ matrix.arch }}" -Version "6.0.428" -InstallDir $dotnet_dir; | |
| Add-Content "${{ github.env }}" "DOTNET_RUNNER=${dotnet_runner}"; | |
| - name: Restore the solution | |
| run: | | |
| & "${{ env.DOTNET_RUNNER }}" ` | |
| restore LuaInstaller\LuaInstaller.sln | |
| - name: Build LuaInstaller.Console | |
| run: | | |
| & "${{ env.DOTNET_RUNNER }}" ` | |
| publish LuaInstaller\LuaInstaller.Console\LuaInstaller.Console.csproj ` | |
| -o "${{ env.CONSOLE_DIR }}" ` | |
| -c Release ` | |
| -r win-${{ matrix.arch }} ` | |
| --self-contained true | |
| - name: Build LuaInstaller | |
| run: | | |
| & "${{ env.DOTNET_RUNNER }}" ` | |
| publish LuaInstaller\LuaInstaller\LuaInstaller.csproj ` | |
| -o "${{ env.WPF_DIR }}" ` | |
| -c Release ` | |
| -r win-${{ matrix.arch }} ` | |
| --self-contained true | |
| - name: Prepare artifacts to upload | |
| run: | | |
| mkdir release; | |
| $dirs_to_archive = "${{ env.CONSOLE_DIR }}", "${{ env.WPF_DIR }}"; | |
| foreach ($dir in $dirs_to_archive) | |
| { | |
| $archive_name = (Get-Item $dir | Select-Object -ExpandProperty Name) + "-v${{ env.LUAINSTALLER_VERSION }}-${{ matrix.arch }}.zip"; | |
| $archive_path = Join-Path -Path "release" -ChildPath $archive_name; | |
| Compress-Archive -Path $dir -DestinationPath $archive_path; | |
| $current_file_sha256_hash = Get-FileHash $archive_path -Algorithm SHA256 | Select-Object -ExpandProperty Hash; | |
| $current_file_md5_hash = Get-FileHash $archive_path -Algorithm MD5 | Select-Object -ExpandProperty Hash; | |
| $current_file_sha256_file = Join-Path -Path "release" -ChildPath ($archive_name + "-SHA256.txt"); | |
| $current_file_md5_file = Join-Path -Path "release" -ChildPath ($archive_name + "-MD5.txt"); | |
| Set-Content -Path $current_file_sha256_file -Value $current_file_sha256_hash -NoNewline; | |
| Set-Content -Path $current_file_md5_file -Value $current_file_md5_hash -NoNewline; | |
| } | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-v${{ env.LUAINSTALLER_VERSION }}-${{ matrix.arch }} | |
| path: release | |
| retention-days: 1 | |
| if-no-files-found: error |