-
Notifications
You must be signed in to change notification settings - Fork 1
/
bump.ps1
71 lines (66 loc) · 3.49 KB
/
bump.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
try {
Import-Module PsIni
} catch {
Install-Module -Scope CurrentUser PsIni
Import-Module PsIni
}
$repoName = "zyedidia/micro"
$releasesUri = "https://api.github.com/repos/$repoName/releases/latest"
try { $tag = (Invoke-WebRequest $releasesUri | ConvertFrom-Json).tag_name }
catch {
Write-Host "Error while pulling API."
echo "SHOULD_COMMIT=no" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
break
}
$tag2 = $tag.replace('v','') #-Replace '-.*',''
Write-Host $tag2
if ($tag2 -match "alpha")
{
Write-Host "Found alpha."
echo "SHOULD_COMMIT=no" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
}
elseif ($tag2 -match "beta")
{
Write-Host "Found beta."
echo "SHOULD_COMMIT=no" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
}
elseif ($tag2 -match "RC")
{
Write-Host "Found Release Candidate."
echo "SHOULD_COMMIT=no" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
}
else{
echo "UPSTREAM_TAG=$tag2" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
$appinfo = Get-IniContent ".\microPortable\App\AppInfo\appinfo.ini"
if ($appinfo["Version"]["DisplayVersion"] -ne $tag2){
$appinfo["Version"]["PackageVersion"]=-join($tag2,".0")
$appinfo["Version"]["DisplayVersion"]=$tag2
$installer = Get-IniContent ".\microPortable\App\AppInfo\installer.ini"
$asset1Pattern = "*+win32*"
$asset1 = (Invoke-WebRequest $releasesUri | ConvertFrom-Json).assets | Where-Object name -like $asset1Pattern
$asset1Download = $asset1.browser_download_url.replace('%2B','+')
$installer["DownloadFiles"]["DownloadURL"]=$asset1Download
$installer["DownloadFiles"]["DownloadName"]=$asset1.name.replace('.zip','')
$installer["DownloadFiles"]["DownloadFilename"]=$asset1.name
$asset2Pattern = "*+win64*"
$asset2 = (Invoke-WebRequest $releasesUri | ConvertFrom-Json).assets | Where-Object name -like $asset2Pattern
$asset2Download = $asset2.browser_download_url.replace('%2B','+')
$installer["DownloadFiles"]["Download2URL"]=$asset2Download
$installer["DownloadFiles"]["Download2Name"]=$asset2.name.replace('.zip','')
$installer["DownloadFiles"]["Download2Filename"]=$asset2.name
$installer | Out-IniFile -Force -Encoding ASCII -Pretty -FilePath ".\microPortable\App\AppInfo\installer.ini"
$appinfo["Control"]["BaseAppID"]=-join("%BASELAUNCHERPATH%\App\micro-win32\",$asset1.name.replace('-win32.zip',''),"\micro.exe")
$appinfo["Control"]["BaseAppID64"]=-join("%BASELAUNCHERPATH%\App\micro-win64\",$asset2.name.replace('-win64.zip',''),"\micro.exe")
$appinfo | Out-IniFile -Force -Encoding ASCII -FilePath ".\microPortable\App\AppInfo\appinfo.ini"
$launcher = Get-IniContent ".\microPortable\App\AppInfo\Launcher\microPortable.ini"
$launcher["Launch"]["ProgramExecutable"]=-join("micro-win32\",$asset1.name.replace('-win32.zip',''),"\micro.exe")
$launcher["Launch"]["ProgramExecutable64"]=-join("micro-win64\",$asset2.name.replace('-win64.zip',''),"\micro.exe")
$launcher | Out-IniFile -Force -Encoding ASCII -FilePath ".\microPortable\App\AppInfo\Launcher\microPortable.ini"
Write-Host "Bumped to "+$tag2
echo "SHOULD_COMMIT=yes" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
}
else{
Write-Host "No changes."
echo "SHOULD_COMMIT=no" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
}
}