-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.ps1
50 lines (41 loc) · 1.88 KB
/
update.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
# タグ名を引数から取得
$tagName = $args[0]
# Extract version (vを取り除く)
$version = $tagName -replace '^v', ''
# Update package.version in tauri.conf.json
$tauriConfPath = "src-tauri\tauri.conf.json"
$tauriConf = Get-Content -Path $tauriConfPath | ConvertFrom-Json
$tauriConf.package.version = $version
$tauriConf | ConvertTo-Json -Depth 100 | Set-Content -Path $tauriConfPath
# Set Tauri Environment Variables
$env:TAURI_PRIVATE_KEY = Get-Content -Path "~\.tauri\launcherg-actions.key"
$env:TAURI_KEY_PASSWORD = Get-Content -Path "~\.tauri\launcherg-actions-pass.key"
# Install dependencies and build
Invoke-Expression "npm i"
Invoke-Expression "npm run tauri build"
# Update .tauri-updater.json
$env:TEMP_SIGNATURE = Get-Content -Path ".\src-tauri\target\release\bundle\msi\Launcherg_${version}_x64_ja-JP.msi.zip.sig"
$updaterData = @{
version = $version
notes = "See the assets to download this version and install."
pub_date = (Get-Date -Format s) + "Z"
signature = $env:TEMP_SIGNATURE
url = "https://github.com/ryoha000/launcherg/releases/download/${tagName}/Launcherg_${version}_x64_ja-JP.msi.zip"
}
$updaterData | ConvertTo-Json | Set-Content -Path ".tauri-updater.json"
# Format files (Prettier のCLIを使ってファイルをフォーマット)
Invoke-Expression "npx -y prettier $tauriConfPath .tauri-updater.json --write"
# Push updated files to main
git add $tauriConfPath .tauri-updater.json
git commit -m "Update for release $version"
git push origin main
git tag $tagName
git push origin $tagName
# orphan なブランチを作って、そこにビルド結果をコミットする
$artifactBranchName = "${tagName}-artifacts"
git checkout --orphan $artifactBranchName
git rm -rf .
git add -f src-tauri/target/release/bundle/msi/Launcherg_${version}_x64_ja-JP.msi.zip
git commit -m "Release $version"
git push origin $artifactBranchName --force
git switch main