変愚蛮怒のメインリポジトリです
Revision | 841fd1b63589877ba6d25682735859082f7d0837 (tree) |
---|---|
Time | 2021-02-01 23:00:51 |
Author | Habu <habu@user...> |
Commiter | Habu |
[implement] Windows版バイナリパッケージを生成するスクリプト
Windows版のバイナリパッケージを準備するのを容易にするため、ビルドから
パッケージ生成までを自動的に行うPowerShellスクリプトを作成した。
リポジトリのトップディレクトリで Build-Windows-Release-Package.ps1 を
実行すると、リリースバージョンを聞かれ、入力したバージョンを付加した
Windows版バイナリパッケージが日本語版・英語版ともにトップディレクトリに生成される。
生成されるパッケージ名:
将来的には、Hengband.exe に --version オプションを付けて実行すると
バージョンを出力するようにし、自動的にパッケージに付与するバージョン名を
決定する機能なども考えたい。
また、GitHubに移行後はGitHub Actionsで自動的にバイナリパッケージを
生成・アップロードするWorkflowを作るとさらにリリース作業が楽になると思われる。
@@ -0,0 +1,47 @@ | ||
1 | +Param( | |
2 | + # パッケージに付加するバージョン | |
3 | + [parameter(Mandatory = $true)][string]$Version | |
4 | +) | |
5 | + | |
6 | +# とりあえず Visual Studio Community 2019 用の MSBuild.exe にパスを通す | |
7 | +# 他の環境でビルドを実行する方法は要調査・検討 | |
8 | +$msbuild_path = 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin' | |
9 | +$Env:Path = $msbuild_path + ";" + $Env:Path | |
10 | + | |
11 | + | |
12 | +function BuildPackage ($package_name, $package_unique_files, $build_conf) { | |
13 | + # バイナリをリビルド | |
14 | + MSBuild.exe .\Hengband\Hengband.sln /t:Rebuild /p:Configuration=$build_conf | |
15 | + | |
16 | + if ($LASTEXITCODE -ne 0) { | |
17 | + # ビルド失敗ならスクリプトを中断する | |
18 | + exit | |
19 | + } | |
20 | + | |
21 | + # 作業用テンポラリフォルダ | |
22 | + $tempDir = New-TemporaryFile | ForEach-Object { Remove-Item $_; New-Item $_ -ItemType Directory } | |
23 | + | |
24 | + $hengbandDir = Join-Path $tempDir $package_name | |
25 | + New-Item $hengbandDir -ItemType Directory | |
26 | + | |
27 | + # 必要なファイルをコピーして、その中で不要になりえるものを削除 | |
28 | + Copy-Item -Verbose -Path .\Hengband.exe, .\readme_angband -Destination $hengbandDir | |
29 | + Copy-Item -Verbose -Path $package_unique_files -Destination $hengbandDir | |
30 | + Copy-Item -Verbose -Recurse -Path .\lib -Destination $hengbandDir -Exclude Makefile.am, delete.me, *.raw, .gitattributes | |
31 | + Copy-Item -Verbose -Path .\lib\apex\h_scores.raw -Destination $hengbandDir\lib\apex | |
32 | + Remove-Item -Verbose -Path $hengbandDir\lib\save\*, $hengbandDir\lib\user\* | |
33 | + Remove-Item -Verbose -Exclude music.cfg -Path $hengbandDir\lib\xtra\music\* | |
34 | + | |
35 | + # zipアーカイブ作成 | |
36 | + $package_path = Join-Path $(Get-Location) "${package_name}.zip" | |
37 | + Push-Location $tempDir | |
38 | + Compress-Archive -Force -Verbose -Path $package_name -DestinationPath $package_path | |
39 | + Pop-Location | |
40 | + | |
41 | + # 作業用テンポラリフォルダ削除 | |
42 | + $tempDir | Where-Object { Test-Path $_ } | ForEach-Object { Get-ChildItem $_ -File -Recurse | Remove-Item; $_ } | Remove-Item -Recurse | |
43 | +} | |
44 | + | |
45 | +# 日本語版 | |
46 | +BuildPackage -package_name Hengband-$Version-jp -package_unique_files .\readme.txt, .\autopick.txt -build_conf Release | |
47 | +BuildPackage -package_name Hengband-$Version-en -package_unique_files .\readme_eng.txt, .\autopick_eng.txt -build_conf English-Release |