forked from eripong/ENdoSnipe-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
51 lines (38 loc) · 1.19 KB
/
build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function global:Replace-Content
{
Param([string]$filepath, [string]$rep1, [string]$rep2)
if ( $(test-path $filepath) -ne $True )
{
Write-Error "存在しないパスです"
return
}
$file_contents = $(Get-Content $filepath -encoding String) -replace $rep1, $rep2
$file_contents | Out-File $filepath -encoding default
}
#タグ名称を設定する。
$tags = "6.0.1-release"
$WorkDir="build"
#tagを作成する。
git tag -a $tags -m 'build tag'
git push --tags
#作業ディレクトリを作成する。
Remove-Item -path $WorkDir -recurse
mkdir $WorkDir
#tagからファイルをエクスポートする。
git archive --format zip -o $WorkDir\export.zip $tags
#エクスポートしたファイルを展開する。
cd $WorkDir
$file=Convert-Path(".\export.zip")
$shell = New-Object -ComObject shell.application
$zip = $shell.NameSpace($file)
$dest = $shell.NameSpace((Split-Path $file -Parent))
$dest.CopyHere($zip.Items())
# バージョンを更新する。
$tag_array = $tags -split "-"
$ver = $tag_array[0]
$build = $tag_array[1]
Replace-Content ENdoSnipe\build.bat "set VER=.+" "set VER=$ver"
Replace-Content ENdoSnipe\build.bat "set BUILD=.+" "set BUILD=$build"
# ビルドを実行する。
cd ENdoSnipe
.\build.bat