|
| 1 | +name: Build ACT.Hojoring |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "master", "feature/*", "topic/*" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "master" ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + runs-on: windows-latest |
| 13 | + |
| 14 | + env: |
| 15 | + Solution_Path: source/ACT.Hojoring.sln |
| 16 | + Test_Project_Path: source/ACT.Hojoring.Tests/ACT.Hojoring.Tests.csproj |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Add MSBuild to PATH |
| 25 | + uses: microsoft/setup-msbuild@v2 |
| 26 | + |
| 27 | + - name: Checkout Secrets |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + repository: wbonbon/ACT.Hojoring.Secrets |
| 31 | + token: ${{ secrets.HOJORING_SECRETS_PAT }} |
| 32 | + path: dep-secrets |
| 33 | + |
| 34 | + - name: Copy Dependencies |
| 35 | + run: | |
| 36 | + Copy-Item -Recurse -Force dep-secrets/ThirdParty/* source/ThirdParty |
| 37 | + Copy-Item -Recurse -Force dep-secrets/costura-win-x64 source/ACT.TTSYukkuri/ACT.TTSYukkuri/ |
| 38 | + Copy-Item -Recurse -Force dep-secrets/costura-win-x86 source/ACT.TTSYukkuri/ACT.TTSYukkuri/ |
| 39 | + Copy-Item -Recurse -Force dep-secrets/ACT.TTSYukkuri/Thirdparty source/ACT.TTSYukkuri/ |
| 40 | + Copy-Item -Force dep-secrets/fflogs_debug.db source/FFLogsRankingDonwloader/resources/ |
| 41 | + shell: pwsh |
| 42 | + |
| 43 | + - name: Configure NuGet Access |
| 44 | + run: | |
| 45 | + if ("${{ secrets.DISCORD_NET_PAT }}" -ne "") { |
| 46 | + nuget sources update -Name "discord-net-nightly" -UserName "${{ secrets.DISCORD_NET_USER }}" -Password "${{ secrets.DISCORD_NET_PAT }}" -ConfigFile source/NuGet.Config |
| 47 | + } |
| 48 | + shell: pwsh |
| 49 | + |
| 50 | + - name: Restore NuGet packages |
| 51 | + run: nuget restore ${{ env.Solution_Path }} |
| 52 | + |
| 53 | + - name: Restore Signing Key |
| 54 | + id: restore_key |
| 55 | + run: | |
| 56 | + if ("${{ secrets.HOJORING_SNK_BASE64 }}" -ne "") { |
| 57 | + $bytes = [Convert]::FromBase64String("${{ secrets.HOJORING_SNK_BASE64 }}") |
| 58 | + [IO.File]::WriteAllBytes("source/ACT.Hojoring.Common/Hojoring.snk", $bytes) |
| 59 | + [IO.File]::WriteAllBytes("source/ACT.Hojoring.Activator/Hojoring.snk", $bytes) |
| 60 | + } else { |
| 61 | + Write-Host "HOJORING_SNK_BASE64 is not set. Skipping signing key restoration." |
| 62 | + } |
| 63 | + shell: pwsh |
| 64 | + |
| 65 | + - name: Build Solution |
| 66 | + run: msbuild ${{ env.Solution_Path }} /p:Configuration=Release /p:Platform=x64 |
| 67 | + |
| 68 | + - name: Package Artifacts |
| 69 | + id: package |
| 70 | + run: | |
| 71 | + $ErrorActionPreference = "Stop" |
| 72 | + $startdir = Get-Location |
| 73 | + $binDir = Join-Path $startdir "source/ACT.Hojoring/bin/x64/Release" |
| 74 | + |
| 75 | + if (-not (Test-Path $binDir)) { Write-Error "Build output directory not found: $binDir"; exit 1 } |
| 76 | +
|
| 77 | + Set-Location $binDir |
| 78 | +
|
| 79 | + Write-Host "Cleaning up locales..." |
| 80 | + $locales = @("cs", "cs-CZ", "de", "es", "fr", "hu", "it", "ja", "ja-JP", "ko", "pl", "pt-BR", "ro", "ru", "sv", "tr", "zh-Hans", "zh-Hant") |
| 81 | + foreach ($locale in $locales) { if (Test-Path $locale) { Remove-Item -Force -Recurse $locale } } |
| 82 | +
|
| 83 | + Write-Host "Reorganizing into 'bin' directory..." |
| 84 | + if (-not (Test-Path "bin")) { New-Item -ItemType Directory "bin" | Out-Null } |
| 85 | + $targets = @("yukkuri", "openJTalk", "lib", "tools") |
| 86 | + foreach ($t in $targets) { |
| 87 | + if (Test-Path $t) { |
| 88 | + $dest = Join-Path "bin" $t |
| 89 | + if (Test-Path $dest) { Get-ChildItem -Path $dest -Recurse | ForEach-Object { if ($_.Attributes -ne 'Directory') { $_.Attributes = 'Normal' } }; Remove-Item -Path $dest -Recurse -Force } |
| 90 | + Copy-Item -Path $t -Destination $dest -Recurse -Force |
| 91 | + if (Test-Path $dest) { Remove-Item -Path $t -Recurse -Force } |
| 92 | + } |
| 93 | + } |
| 94 | +
|
| 95 | + Write-Host "Removing garbage files..." |
| 96 | + $garbage = @("*.pdb", "*.xml", "*.exe.config", "libgrpc_csharp_ext.*.so", "libgrpc_csharp_ext.*.dylib") |
| 97 | + foreach ($g in $garbage) { Remove-Item -Force $g -ErrorAction SilentlyContinue } |
| 98 | + Remove-Item -Force -Recurse x86 -ErrorAction SilentlyContinue; Remove-Item -Force -Recurse x64 -ErrorAction SilentlyContinue |
| 99 | +
|
| 100 | + Write-Host "Removing specific resources..." |
| 101 | + Remove-Item bin\openJTalk\dic\sys.dic -ErrorAction SilentlyContinue |
| 102 | + Remove-Item bin\openJTalk\voice\* -ErrorAction SilentlyContinue |
| 103 | + Remove-Item bin\yukkuri\aq_dic\aqdic.bin -ErrorAction SilentlyContinue |
| 104 | + Remove-Item bin\lib\*.dll -ErrorAction SilentlyContinue |
| 105 | + Remove-Item resources\icon\Common\*.png -ErrorAction SilentlyContinue |
| 106 | + Remove-Item resources\icon\Job\*.png -ErrorAction SilentlyContinue |
| 107 | + Remove-Item resources\icon\Role\*.png -ErrorAction SilentlyContinue |
| 108 | + Remove-Item resources\xivdb\*.csv -ErrorAction SilentlyContinue |
| 109 | + Remove-Item resources\timeline\wallpaper\* -ErrorAction SilentlyContinue |
| 110 | + Remove-Item resources\wav\* -Exclude _asterisk.wav,_beep.wav,_wipeout.wav -ErrorAction SilentlyContinue |
| 111 | + Remove-Item resources\icon\Timeline_EN\* -ErrorAction SilentlyContinue |
| 112 | + Remove-Item resources\icon\Timeline_JP\* -ErrorAction SilentlyContinue |
| 113 | +
|
| 114 | + # Get Version |
| 115 | + $versionFile = Join-Path $startdir "source/@MasterVersion.txt" |
| 116 | + $versionShort = if (Test-Path $versionFile) { (Get-Content $versionFile).Trim().Trim("`r","`n") } else { "0.0.0" } |
| 117 | + Write-Host "Packaging Version: $versionShort" |
| 118 | + |
| 119 | + # Get Commit Hash |
| 120 | + $hash = git rev-parse --short=7 HEAD |
| 121 | + Write-Host "Commit Hash: $hash" |
| 122 | +
|
| 123 | + # Export Version and Hash |
| 124 | + echo "VERSION=$versionShort" >> $env:GITHUB_OUTPUT |
| 125 | + echo "HASH=$hash" >> $env:GITHUB_OUTPUT |
| 126 | + shell: pwsh |
| 127 | + |
| 128 | + - name: Upload Build Artifacts |
| 129 | + uses: actions/upload-artifact@v4 |
| 130 | + with: |
| 131 | + name: ACT.Hojoring-${{ steps.package.outputs.VERSION }}-${{ steps.package.outputs.HASH }} |
| 132 | + path: source/ACT.Hojoring/bin/x64/Release |
| 133 | + |
| 134 | + # Uncomment if tests are available and runnable |
| 135 | + # - name: Run Tests |
| 136 | + # run: dotnet test ${{ env.Test_Project_Path }} --no-build --verbosity normal |
0 commit comments