Skip to content

Commit

Permalink
ci: build exe package
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-bodnar committed Jun 18, 2024
1 parent 08209dd commit b71121f
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,26 @@ jobs:
- name: Test crowdin command
run: crowdin -V

build-exe:
runs-on: windows-latest
needs: build
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: artifacts

- name: Prepare distribution
run: mkdir dist && mv crowdin-cli-*.jar dist/crowdin-cli.jar

- name: Compile .ISS to .EXE Installer
uses: Minionguyjpro/Inno-Setup-Action@v1.2.4
with:
path: packages/exe/CrowdinCLIInstaller.iss

- uses: actions/upload-artifact@v4
with:
name: exe-package
path: crowdin.exe
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,32 @@ jobs:
docker build --pull -t "${{ secrets.DOCKER_HUB_REGISTRY_IMAGE }}:${{ github.ref_name }}" -t "${{ secrets.DOCKER_HUB_REGISTRY_IMAGE }}:latest" .
docker push "${{ secrets.DOCKER_HUB_REGISTRY_IMAGE }}:${{ github.ref_name }}"
docker push "${{ secrets.DOCKER_HUB_REGISTRY_IMAGE }}:latest"
exe:
runs-on: windows-latest
if: github.event_name == 'release'
needs: assets
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: 'gradle'

- name: Prepare distribution
run: |
./gradlew shadowJar
mkdir dist
mv build/libs/crowdin-cli-*.jar dist/crowdin-cli.jar
- name: Compile .ISS to .EXE Installer
uses: Minionguyjpro/Inno-Setup-Action@v1.2.2
with:
path: packages/exe/CrowdinCLIInstaller.iss

- name: Upload asset
uses: softprops/action-gh-release@v2
with:
files: crowdin.exe
154 changes: 154 additions & 0 deletions packages/exe/CrowdinCLIInstaller.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Crowdin"
#define MyAppVersion "4.0.0"
#define MyAppPublisher "OU Crowdin"
#define MyAppURL "https://crowdin.github.io/crowdin-cli"
#define MyAppExeName "crowdin-cli.jar"

[Registry]
Root: HKCU; Subkey: "Environment"; ValueType:string; ValueName:"PATH"; ValueData:"{olddata};{app}"; Flags: preservestringtype
Root: HKCU; Subkey: "Environment"; ValueType:string; ValueName:"CROWDIN_HOME"; ValueData:"{app}"; Flags: preservestringtype

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{52B80417-16B8-4EFE-B118-6FA64B25CC0F}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={commonpf}\CrowdinCLI
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
OutputDir=..\..\
OutputBaseFilename=crowdin
Compression=lzma
SolidCompression=yes
ChangesEnvironment=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]
Source: "..\..\dist\crowdin-cli.jar"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\zip\crowdin.bat"; DestDir: "{app}"; Flags: ignoreversion

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"

[Code]
function CutJavaVersionPart(var V: string): Integer;
var
S: string;
P: Integer;
begin
if Length(V) = 0 then
begin
Result := 0;
end
else
begin
P := Pos('.', V);
if P = 0 then P := Pos('_', V);
if P > 0 then
begin
S := Copy(V, 1, P - 1);
Delete(V, 1, P);
end
else
begin
S := V;
V := '';
end;
Result := StrToIntDef(S, 0);
end;
end;
function MaxJavaVersion(V1, V2: string): string;
var
Part1, Part2: Integer;
Buf1, Buf2: string;
begin
Buf1 := V1;
Buf2 := V2;
Result := '';
while (Result = '') and
((Buf1 <> '') or (Buf2 <> '')) do
begin
Part1 := CutJavaVersionPart(Buf1);
Part2 := CutJavaVersionPart(Buf2);
if Part1 > Part2 then Result := V1
else
if Part2 > Part1 then Result := V2;
end;
end;
function GetJavaVersion(): string;
var
TempFile: string;
ResultCode: Integer;
S: AnsiString;
P: Integer;
begin
TempFile := ExpandConstant('{tmp}\javaversion.txt');
if (not ExecAsOriginalUser(
ExpandConstant('{cmd}'), '/c java -version 2> "' + TempFile + '"', '',
SW_HIDE, ewWaitUntilTerminated, ResultCode)) or
(ResultCode <> 0) then
begin
Log('Failed to execute java -version');
end
else
if not LoadStringFromFile(TempFile, S) then
begin
Log(Format('Error reading file %s', [TempFile]));
end
else
if Copy(S, 1, 14) <> 'java version "' then
begin
Log('Output of the java -version not as expected');
end
else
begin
Delete(S, 1, 14);
P := Pos('"', S);
if P = 0 then
begin
Log('Output of the java -version not as expected');
end
else
begin
SetLength(S, P - 1);
Result := S;
end;
end;
DeleteFile(TempFile);
end;
function HasJava1Dot7OrNewer: Boolean;
begin
Result := (MaxJavaVersion('1.6.9', GetJavaVersion) <> '1.6.9');
end;
function InitializeSetup(): Boolean;
var
ErrorCode: Integer;
begin
Result := HasJava1Dot7OrNewer;
if not Result then
begin
Result := MsgBox(ExpandConstant('Your Java version needs to be updated. Download it from https://www.java.com?'), mbConfirmation, MB_YESNO) = idYes;
if Result then
begin
ShellExec(
'open', 'https://www.java.com/getjava/', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
end;
end;
16 changes: 16 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@ module.exports = {
}
],
"countMatches": true
},
{
"files": [
"packages/exe/CrowdinCLIInstaller.iss"
],
"from": "#define MyAppVersion \".*\"",
"to": "#define MyAppVersion \"${nextRelease.version}\"",
"results": [
{
"file": "packages/exe/CrowdinCLIInstaller.iss",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}
],
}
]
}
Expand All @@ -117,6 +132,7 @@ module.exports = {
"package-lock.json",
"packages/aur/pkgbuild/PKGBUILD",
"packages/chocolatey/*",
"packages/exe/*",
"CHANGELOG.md"
],
"message": "chore(release): version ${nextRelease.version} [skip ci]"
Expand Down

0 comments on commit b71121f

Please sign in to comment.