Skip to content

Commit 5434b3b

Browse files
committed
improve shell ui and release workflow
1 parent 3c86c96 commit 5434b3b

20 files changed

Lines changed: 344 additions & 144 deletions

File tree

.github/workflows/release-artifacts.yml

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,19 @@ permissions:
99
contents: write
1010

1111
jobs:
12-
build-jar:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- name: Checkout
16-
uses: actions/checkout@v4
17-
18-
- name: Set up Java 17
19-
uses: actions/setup-java@v4
20-
with:
21-
distribution: temurin
22-
java-version: "17"
23-
24-
- name: Make wrapper executable
25-
run: chmod +x ./mvnw
26-
27-
- name: Build shaded jar
28-
run: ./mvnw -B clean package
29-
30-
- name: Upload JAR artifact
31-
uses: actions/upload-artifact@v4
32-
with:
33-
name: mynosql-jar
34-
path: |
35-
target/mynosql-*.jar
36-
!target/original-*.jar
37-
38-
- name: Attach JAR to GitHub release
39-
if: github.event_name == 'release'
40-
uses: softprops/action-gh-release@v2
41-
with:
42-
files: |
43-
target/mynosql-*.jar
44-
!target/original-*.jar
45-
4612
build-windows-exe:
4713
runs-on: windows-latest
4814
steps:
4915
- name: Checkout
5016
uses: actions/checkout@v4
5117

18+
- name: Read app version
19+
id: app_version
20+
shell: powershell
21+
run: |
22+
[xml]$pom = Get-Content pom.xml
23+
"version=$($pom.project.version)" >> $env:GITHUB_OUTPUT
24+
5225
- name: Set up Java 17
5326
uses: actions/setup-java@v4
5427
with:
@@ -63,6 +36,37 @@ jobs:
6336
shell: cmd
6437
run: mvnw.cmd -B clean package
6538

39+
- name: Create Windows app-image
40+
shell: powershell
41+
run: |
42+
$jar = Get-ChildItem target -Filter 'mynosql-*.jar' |
43+
Where-Object { $_.Name -notlike 'original-*' } |
44+
Select-Object -First 1
45+
46+
if (-not $jar) {
47+
throw "Could not find packaged JAR in target/."
48+
}
49+
50+
New-Item -Path dist-app -ItemType Directory -Force | Out-Null
51+
52+
jpackage `
53+
--type app-image `
54+
--name MyNoSQL `
55+
--input target `
56+
--main-jar $jar.Name `
57+
--main-class com.mynosql.Main `
58+
--dest dist-app `
59+
--win-console
60+
61+
- name: Zip Windows app-image
62+
shell: powershell
63+
run: |
64+
New-Item -Path dist -ItemType Directory -Force | Out-Null
65+
Compress-Archive `
66+
-Path dist-app/MyNoSQL `
67+
-DestinationPath dist/MyNoSQL-${{ steps.app_version.outputs.version }}-windows-app.zip `
68+
-Force
69+
6670
- name: Create EXE with jpackage
6771
shell: powershell
6872
run: |
@@ -85,14 +89,28 @@ jobs:
8589
--dest dist `
8690
--win-console
8791
88-
- name: Upload EXE artifact
92+
$exe = Get-ChildItem dist -Filter '*.exe' | Select-Object -First 1
93+
if (-not $exe) {
94+
throw "Could not find generated EXE in dist/."
95+
}
96+
97+
Rename-Item `
98+
-Path $exe.FullName `
99+
-NewName ("MyNoSQL-{0}-setup.exe" -f "${{ steps.app_version.outputs.version }}") `
100+
-Force
101+
102+
- name: Upload Windows artifacts
89103
uses: actions/upload-artifact@v4
90104
with:
91-
name: mynosql-windows-exe
92-
path: dist/*.exe
105+
name: mynosql-windows-release
106+
path: |
107+
dist/*.exe
108+
dist/*.zip
93109
94-
- name: Attach EXE to GitHub release
110+
- name: Attach Windows artifacts to GitHub release
95111
if: github.event_name == 'release'
96112
uses: softprops/action-gh-release@v2
97113
with:
98-
files: dist/*.exe
114+
files: |
115+
dist/*.exe
116+
dist/*.zip

README.md

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -128,35 +128,9 @@ java -cp "out;lib/gson-2.10.1.jar" com.mynosql.Main --shell
128128
> java -cp "out:lib/gson-2.10.1.jar" com.mynosql.Main
129129
> ```
130130
131-
### Share with Others (JAR or EXE)
131+
### Share with Others (Windows ZIP or EXE)
132132
133-
#### Option 1: Portable JAR (works on any OS with Java installed)
134-
135-
Build:
136-
137-
```bash
138-
./mvnw clean package
139-
```
140-
141-
Share:
142-
143-
- `target/mynosql-1.0.0.jar`
144-
145-
Run on recipient machine:
146-
147-
```bash
148-
java -jar mynosql-1.0.0.jar
149-
# or shell only
150-
java -jar mynosql-1.0.0.jar --shell
151-
```
152-
153-
Windows helper script:
154-
155-
```bat
156-
scripts\build-portable.bat
157-
```
158-
159-
#### Option 2: Native Windows EXE installer
133+
#### Option 1: Native Windows EXE installer
160134
161135
If you want users to launch via an `.exe`, build with `jpackage` (included in modern JDKs):
162136
@@ -174,16 +148,35 @@ Notes:
174148
- The generated `.exe` is Windows-specific.
175149
- If you need macOS/Linux native packages too, run equivalent `jpackage` commands on those OSes.
176150

177-
#### Option 3: Automatic release artifacts via GitHub Actions
151+
#### Updating a Windows release
152+
153+
When you make changes and want to send an updated Windows build:
154+
155+
1. Rebuild the app with either `scripts\build-exe.bat` or `scripts\build-app-image.bat`.
156+
2. Increase the project version in `pom.xml` if you want users to see a new version number.
157+
3. Share the new installer or the new zipped app folder.
158+
4. If you are sharing the app-image folder, users should replace the whole folder, not just `MyNoSQL.exe`.
159+
160+
Recommended update flow:
161+
162+
- Small internal sharing: rebuild `dist-app/`, zip `dist-app/MyNoSQL/`, and send the zip.
163+
- Public release: create a GitHub Release so the workflow attaches the new JAR and Windows package automatically.
164+
165+
#### Option 2: Automatic release artifacts via GitHub Actions
178166

179167
This repository includes a workflow at `.github/workflows/release-artifacts.yml` that:
180168

181-
- Builds and uploads shaded JAR artifacts.
182-
- Builds and uploads Windows EXE artifacts.
183-
- Automatically attaches both to a GitHub Release when a release is published.
169+
- Builds and uploads a Windows ZIP app bundle containing `MyNoSQL.exe`.
170+
- Builds and uploads Windows EXE installer artifacts.
171+
- Automatically attaches both of them to a GitHub Release when a release is published.
184172

185173
You can also run it manually from the Actions tab using `workflow_dispatch`.
186174

175+
Recommended GitHub release assets for users:
176+
177+
- `MyNoSQL-<version>-windows-app.zip` for simple download and extract.
178+
- `MyNoSQL-<version>-setup.exe` for installer-style Windows setup.
179+
187180
---
188181

189182
## Usage

mynosql_data/myapp/users.ndjson

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{"name":"Alice","age":30,"email":"alice@example.com","role":"admin","scores":[90,85,92],"address":{"city":"New York","zip":"10001"},"_id":"69b2e708ec2e982cfbb4b0b4"}
2-
{"name":"Bob","age":25,"email":"bob@example.com","role":"user","scores":[75,80,88],"address":{"city":"Boston","zip":"02101"},"_id":"69b2e708ec2e982cfbb4b0b5"}
3-
{"name":"Charlie","age":35,"email":"charlie@example.com","role":"user","scores":[95,98,100],"address":{"city":"New York","zip":"10002"},"_id":"69b2e708ec2e982cfbb4b0b6"}
4-
{"name":"Diana","age":28,"email":"diana@example.com","role":"admin","scores":[88,91,87],"address":{"city":"Chicago","zip":"60601"},"_id":"69b2e708ec2e982cfbb4b0b7"}
5-
{"name":"Eve","age":22,"email":"eve@example.com","role":"user","scores":[70,65,72],"address":{"city":"Boston","zip":"02102"},"_id":"69b2e708ec2e982cfbb4b0b8"}
1+
{"name":"Alice","age":30,"email":"alice@example.com","role":"admin","scores":[90,85,92],"address":{"city":"New York","zip":"10001"},"_id":"69b64b97ec2e982cfbeb501e"}
2+
{"name":"Bob","age":25,"email":"bob@example.com","role":"user","scores":[75,80,88],"address":{"city":"Boston","zip":"02101"},"_id":"69b64b97ec2e982cfbeb501f"}
3+
{"name":"Charlie","age":35,"email":"charlie@example.com","role":"user","scores":[95,98,100],"address":{"city":"New York","zip":"10002"},"_id":"69b64b97ec2e982cfbeb5020"}
4+
{"name":"Diana","age":28,"email":"diana@example.com","role":"admin","scores":[88,91,87],"address":{"city":"Chicago","zip":"60601"},"_id":"69b64b97ec2e982cfbeb5021"}
5+
{"name":"Eve","age":22,"email":"eve@example.com","role":"user","scores":[70,65,72],"address":{"city":"Boston","zip":"02102"},"_id":"69b64b97ec2e982cfbeb5022"}

scripts/build-app-image.bat

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if not defined JPACKAGE_EXE (
2323
exit /b 1
2424
)
2525

26-
call mvnw.cmd -q clean package
26+
call mvnw.cmd -q package
2727
if errorlevel 1 (
2828
echo Maven build failed.
2929
exit /b 1
@@ -45,6 +45,11 @@ if "%MAIN_JAR%"=="" (
4545
)
4646

4747
if exist dist-app rmdir /s /q dist-app
48+
if exist dist-app (
49+
echo Could not remove dist-app\
50+
echo Close any running MyNoSQL app from dist-app and try again.
51+
exit /b 1
52+
)
4853
mkdir dist-app
4954

5055
"%JPACKAGE_EXE%" ^

scripts/build-exe.bat

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if errorlevel 1 (
4444
exit /b 1
4545
)
4646

47-
call mvnw.cmd -q clean package
47+
call mvnw.cmd -q package
4848
if errorlevel 1 (
4949
echo Maven build failed.
5050
exit /b 1
@@ -66,6 +66,11 @@ if "%MAIN_JAR%"=="" (
6666
)
6767

6868
if exist dist rmdir /s /q dist
69+
if exist dist (
70+
echo Could not remove dist\
71+
echo Close any installer or file explorer window using dist and try again.
72+
exit /b 1
73+
)
6974
mkdir dist
7075

7176
"%JPACKAGE_EXE%" ^

scripts/build-portable.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
setlocal
33

44
REM Build a self-contained runnable JAR with dependencies
5-
call mvnw.cmd -q clean package
5+
call mvnw.cmd -q package
66
if errorlevel 1 (
77
echo Maven build failed.
88
exit /b 1

0 commit comments

Comments
 (0)