-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
126 lines (100 loc) · 3.82 KB
/
Copy pathbuild.ps1
File metadata and controls
126 lines (100 loc) · 3.82 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# wingetパッケージ用ビルドスクリプト
$ErrorActionPreference = "Stop"
$appname = "coe"
$version = "0.1.9"
function Invoke-CoeBuild {
param(
[Parameter(Mandatory = $true)]
[string]$OutputFile
)
go build -o $OutputFile -ldflags "-s -w" main.go
if ($LASTEXITCODE -ne 0) {
throw "go build failed: $OutputFile (exit $LASTEXITCODE)"
}
}
# リリースディレクトリを作成
$releaseDir = "release"
if (!(Test-Path $releaseDir)) {
New-Item -ItemType Directory -Path $releaseDir -Force | Out-Null
}
# Windows用のビルド
@("amd64", "arm64") | ForEach-Object {
$env:GOOS = "windows"
$env:GOARCH = $_
$target = "windows_$env:GOARCH"
$buildDir = "build/$appname" + "_$target"
$outputFile = "$buildDir/$appname.exe"
Write-Host "Building for $target..." -ForegroundColor Green
# ビルドディレクトリを作成
if (Test-Path $buildDir) {
Remove-Item $buildDir -Recurse -Force
}
New-Item -ItemType Directory -Path $buildDir -Force | Out-Null
# Goアプリケーションをビルド
Invoke-CoeBuild -OutputFile $outputFile
# インストーラースクリプトをコピー
Copy-Item "installer.ps1" "$buildDir/"
# ZIP化
$zipPath = "$releaseDir/$appname" + "_$version" + "_$target.zip"
if (Test-Path $zipPath) {
Remove-Item $zipPath -Force
}
Write-Host "Creating ZIP: $zipPath" -ForegroundColor Yellow
Compress-Archive -Path (Get-ChildItem -Path $buildDir) -DestinationPath $zipPath
# SHA256ハッシュを計算
$hash = Get-FileHash -Path $zipPath -Algorithm SHA256
Write-Host "SHA256 for $target`: $($hash.Hash)" -ForegroundColor Cyan
}
# Linux用のビルド
@("amd64", "arm64") | ForEach-Object {
$env:GOOS = "linux"
$env:GOARCH = $_
$target = "linux_$env:GOARCH"
$buildDir = "build/$appname" + "_$target"
$outputFile = "$buildDir/$appname"
Write-Host "Building for $target..." -ForegroundColor Green
# ビルドディレクトリを作成
if (Test-Path $buildDir) {
Remove-Item $buildDir -Recurse -Force
}
New-Item -ItemType Directory -Path $buildDir -Force | Out-Null
# Goアプリケーションをビルド
Invoke-CoeBuild -OutputFile $outputFile
# ZIP化
$zipPath = "$releaseDir/$appname" + "_$version" + "_$target.zip"
if (Test-Path $zipPath) {
Remove-Item $zipPath -Force
}
Write-Host "Creating ZIP: $zipPath" -ForegroundColor Yellow
Compress-Archive -Path (Get-ChildItem -Path $buildDir) -DestinationPath $zipPath
# SHA256ハッシュを計算
$hash = Get-FileHash -Path $zipPath -Algorithm SHA256
Write-Host "SHA256 for $target`: $($hash.Hash)" -ForegroundColor Cyan
}
# macOS用のビルド
@("amd64", "arm64") | ForEach-Object {
$env:GOOS = "darwin"
$env:GOARCH = $_
$target = "darwin_$env:GOARCH"
$buildDir = "build/$appname" + "_$target"
$outputFile = "$buildDir/$appname"
Write-Host "Building for $target..." -ForegroundColor Green
# ビルドディレクトリを作成
if (Test-Path $buildDir) {
Remove-Item $buildDir -Recurse -Force
}
New-Item -ItemType Directory -Path $buildDir -Force | Out-Null
# Goアプリケーションをビルド
Invoke-CoeBuild -OutputFile $outputFile
# ZIP化
$zipPath = "$releaseDir/$appname" + "_$version" + "_$target.zip"
if (Test-Path $zipPath) {
Remove-Item $zipPath -Force
}
Write-Host "Creating ZIP: $zipPath" -ForegroundColor Yellow
Compress-Archive -Path (Get-ChildItem -Path $buildDir) -DestinationPath $zipPath
# SHA256ハッシュを計算
$hash = Get-FileHash -Path $zipPath -Algorithm SHA256
Write-Host "SHA256 for $target`: $($hash.Hash)" -ForegroundColor Cyan
}
Write-Host "Build completed! Files are in the $releaseDir directory." -ForegroundColor Green