forked from Windows81/Roblox-Freedom-Distribution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReleaseNewVersion.ps1
87 lines (78 loc) · 2.39 KB
/
ReleaseNewVersion.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
$mode = (Read-Host "@
1. Build EXE
2. Build EXE and publish artefacts
3. Build EXE and ZIP, then publish artefects
")
$root = "$PSScriptRoot"
$files = New-Object System.Collections.Generic.List[System.Object]
function RetrieveInput() {
$script:release_name = (Read-Host "Version title?")
# Packs Rōblox executables into GitHub releases that can be downloaded.
$script:commit_name = $args[1] ?? (Get-Date -Format "yyyy-MM-ddTHHmmZ" `
(curl -I -s http://1.1.1.1 | grep "Date:" | cut -d " " -f 2-))
}
function UpdateAndPush() {
git add .
git commit -m $script:commit_name
git push
}
function CreateBinary() {
pyinstaller `
--name "RFD" `
--onefile "$root/Source/_main.py" `
-p "$root/Source/" `
--workpath "$root/PyInstallerWork" `
--distpath "$root/Binaries" `
--icon "$root/Source/Icon.ico" `
--specpath "$root/PyInstallerWork/Spec" `
--hidden-import requests # Allows functions in config to use the `requests` library (1 MiB addition)
foreach ($file in (Get-ChildItem "$root/Binaries/*")) {
$files.Add($file.FullName)
}
}
function UpdateZippedReleaseVersion($labels) {
$const_file = "$root/Source/util/const.py"
$const_text = (Get-Content $const_file)
foreach ($label in $labels) {
$const_txt = $const_text -replace "$label =.+", "$label = '''$script:release_name'''"
}
$const_txt | Set-Content $const_file
}
function CreateZippedDirs() {
foreach ($dir in (Get-ChildItem "$root/Roblox/*/*" -Directory)) {
$zip = "$root/Roblox/$($dir.Parent.Name).$($dir.Name).7z"
Remove-Item $zip -Force -Confirm
if (-not (Test-Path $zip)) {
# The `-xr` switches are for excluding specific file names (https://documentation.help/7-Zip-18.0/exclude.htm).
7z a $zip "$($dir.FullName)/*" `
"-xr!AppSettings.xml" `
"-xr!RFDStarterScript.lua" `
"-xr!dxgi.dll" "-xr!Reshade.ini" "-xr!ReShade.log" "-xr!ReShade_RobloxPlayerBeta.log" # ReShade stuff
}
$files.Add($zip)
}
}
function ReleaseToGitHub() {
gh release create "$release_name" --notes "" $files
}
switch ($mode) {
'1' {
CreateBinary
}
'2' {
RetrieveInput
UpdateZippedReleaseVersion @("GIT_RELEASE_VERSION")
UpdateAndPush
CreateBinary
ReleaseToGitHub
}
'3' {
RetrieveInput
UpdateZippedReleaseVersion @("GIT_RELEASE_VERSION", "ZIPPED_RELEASE_VERSION")
UpdateAndPush
CreateBinary
CreateZippedDirs
ReleaseToGitHub
}
Default {}
}