Skip to content

Commit 4deb4b9

Browse files
committed
Шаг сборки инсталлятора
1 parent 4c8d305 commit 4deb4b9

2 files changed

Lines changed: 162 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,26 @@ jobs:
2727
- name: Build ovm.exe
2828
run: oscript -make src/cmd/ovm.os ovm.exe
2929

30-
- name: Upload ovm.exe to release assets
30+
- name: Extract version from packagedef
31+
id: get_version
32+
run: |
33+
VERSION=$(grep -oP '\.Версия\("\K[^"]+' packagedef)
34+
echo "version=$VERSION" >> $GITHUB_OUTPUT
35+
echo "Extracted version: $VERSION"
36+
37+
- name: Create dist directory
38+
run: mkdir -p dist
39+
40+
- name: Build Windows installer with Inno Setup
41+
run: |
42+
docker run --rm -i -v "$GITHUB_WORKSPACE:/work" -w /work amake/innosetup \
43+
/DMyAppVersion="${{ steps.get_version.outputs.version }}" \
44+
install/ovm.iss
45+
46+
- name: Upload release assets
3147
uses: AButler/upload-release-assets@v2.0.2
3248
with:
33-
files: ovm.exe
49+
files: |
50+
ovm.exe
51+
dist/ovm-setup.exe
3452
repo-token: ${{ secrets.GITHUB_TOKEN }}

install/ovm.iss

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
; Inno Setup script for OVM (OneScript Version Manager)
2+
; Installs ovm.exe to %LOCALAPPDATA%\ovm and adds it to user PATH
3+
4+
#define MyAppName "OneScript Version Manager"
5+
; MyAppVersion is passed from GitHub Actions via /D flag, extracting from packagedef
6+
; Default value is used for local builds
7+
#ifndef MyAppVersion
8+
#define MyAppVersion "1.0.0"
9+
#endif
10+
#define MyAppPublisher "oscript-library"
11+
#define MyAppURL "https://github.com/oscript-library/ovm"
12+
#define MyAppExeName "ovm.exe"
13+
14+
[Setup]
15+
; NOTE: The value of AppId uniquely identifies this application.
16+
AppId={{8E5F4A2B-9C3D-4F1E-A6B8-2D7C9E4F1A3B}
17+
AppName={#MyAppName}
18+
AppVersion={#MyAppVersion}
19+
AppPublisher={#MyAppPublisher}
20+
AppPublisherURL={#MyAppURL}
21+
AppSupportURL={#MyAppURL}
22+
AppUpdatesURL={#MyAppURL}
23+
DefaultDirName={localappdata}\ovm
24+
DisableProgramGroupPage=yes
25+
OutputDir=..\dist
26+
OutputBaseFilename=ovm-setup
27+
Compression=lzma
28+
SolidCompression=yes
29+
; Per-user installation (no admin rights required)
30+
PrivilegesRequired=lowest
31+
PrivilegesRequiredOverridesAllowed=dialog
32+
; Notify Windows about environment changes
33+
ChangesEnvironment=yes
34+
ArchitecturesInstallIn64BitMode=x64
35+
UninstallDisplayIcon={app}\{#MyAppExeName}
36+
37+
[Languages]
38+
Name: "english"; MessagesFile: "compiler:Default.isl"
39+
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
40+
41+
[Files]
42+
Source: "..\ovm.exe"; DestDir: "{app}"; Flags: ignoreversion
43+
44+
[Code]
45+
const
46+
EnvironmentKey = 'Environment';
47+
48+
function NeedsAddPath(Param: string): boolean;
49+
var
50+
OrigPath: string;
51+
ParamExpanded: string;
52+
begin
53+
ParamExpanded := ExpandConstant(Param);
54+
if not RegQueryStringValue(HKEY_CURRENT_USER, EnvironmentKey, 'Path', OrigPath) then
55+
begin
56+
Result := True;
57+
exit;
58+
end;
59+
// Check if our path already exists in PATH (case insensitive)
60+
// Check without trailing backslash
61+
Result := Pos(';' + Uppercase(ParamExpanded) + ';', ';' + Uppercase(OrigPath) + ';') = 0;
62+
// Also check with trailing backslash variant
63+
if Result = True then
64+
Result := Pos(';' + Uppercase(ParamExpanded) + '\' + ';', ';' + Uppercase(OrigPath) + ';') = 0;
65+
end;
66+
67+
procedure CurStepChanged(CurStep: TSetupStep);
68+
var
69+
OrigPath: string;
70+
NewPath: string;
71+
AppPath: string;
72+
begin
73+
if CurStep = ssPostInstall then
74+
begin
75+
AppPath := ExpandConstant('{app}');
76+
if NeedsAddPath(AppPath) then
77+
begin
78+
if RegQueryStringValue(HKEY_CURRENT_USER, EnvironmentKey, 'Path', OrigPath) then
79+
begin
80+
// Remove trailing backslash if present
81+
if (Length(OrigPath) > 0) and (OrigPath[Length(OrigPath)] = ';') then
82+
NewPath := OrigPath + AppPath
83+
else
84+
NewPath := OrigPath + ';' + AppPath;
85+
86+
if RegWriteStringValue(HKEY_CURRENT_USER, EnvironmentKey, 'Path', NewPath) then
87+
Log('Added to PATH: ' + AppPath)
88+
else
89+
Log('Failed to add to PATH');
90+
end
91+
else
92+
begin
93+
// PATH doesn't exist, create it
94+
if RegWriteStringValue(HKEY_CURRENT_USER, EnvironmentKey, 'Path', AppPath) then
95+
Log('Created PATH with: ' + AppPath)
96+
else
97+
Log('Failed to create PATH');
98+
end;
99+
end
100+
else
101+
Log('Path already in PATH, skipping');
102+
end;
103+
end;
104+
105+
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
106+
var
107+
OrigPath: string;
108+
NewPath: string;
109+
AppPath: string;
110+
PathList: TStringList;
111+
i: Integer;
112+
begin
113+
if CurUninstallStep = usPostUninstall then
114+
begin
115+
AppPath := ExpandConstant('{app}');
116+
if RegQueryStringValue(HKEY_CURRENT_USER, EnvironmentKey, 'Path', OrigPath) then
117+
begin
118+
PathList := TStringList.Create;
119+
try
120+
PathList.Delimiter := ';';
121+
PathList.StrictDelimiter := True;
122+
PathList.DelimitedText := OrigPath;
123+
124+
// Remove our path from the list
125+
for i := PathList.Count - 1 downto 0 do
126+
begin
127+
if Uppercase(PathList[i]) = Uppercase(AppPath) then
128+
begin
129+
PathList.Delete(i);
130+
Log('Removed from PATH: ' + AppPath);
131+
end;
132+
end;
133+
134+
NewPath := PathList.DelimitedText;
135+
RegWriteStringValue(HKEY_CURRENT_USER, EnvironmentKey, 'Path', NewPath);
136+
finally
137+
PathList.Free;
138+
end;
139+
end;
140+
end;
141+
end;
142+

0 commit comments

Comments
 (0)