Skip to content

Commit 3c86c96

Browse files
committed
chore: add wrapper and release packaging scripts
1 parent 59e3ca5 commit 3c86c96

9 files changed

Lines changed: 424 additions & 0 deletions

File tree

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Release Artifacts
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
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+
46+
build-windows-exe:
47+
runs-on: windows-latest
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v4
51+
52+
- name: Set up Java 17
53+
uses: actions/setup-java@v4
54+
with:
55+
distribution: temurin
56+
java-version: "17"
57+
58+
- name: Install WiX Toolset
59+
shell: powershell
60+
run: choco install wixtoolset --no-progress -y
61+
62+
- name: Build shaded jar
63+
shell: cmd
64+
run: mvnw.cmd -B clean package
65+
66+
- name: Create EXE with jpackage
67+
shell: powershell
68+
run: |
69+
$jar = Get-ChildItem target -Filter 'mynosql-*.jar' |
70+
Where-Object { $_.Name -notlike 'original-*' } |
71+
Select-Object -First 1
72+
73+
if (-not $jar) {
74+
throw "Could not find packaged JAR in target/."
75+
}
76+
77+
New-Item -Path dist -ItemType Directory -Force | Out-Null
78+
79+
jpackage `
80+
--type exe `
81+
--name MyNoSQL `
82+
--input target `
83+
--main-jar $jar.Name `
84+
--main-class com.mynosql.Main `
85+
--dest dist `
86+
--win-console
87+
88+
- name: Upload EXE artifact
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: mynosql-windows-exe
92+
path: dist/*.exe
93+
94+
- name: Attach EXE to GitHub release
95+
if: github.event_name == 'release'
96+
uses: softprops/action-gh-release@v2
97+
with:
98+
files: dist/*.exe

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.mvn/wrapper/apache-maven-*
2+
.mvn/wrapper/*.zip
3+
.mvn/wrapper/*.tar.gz
4+
dist/
5+
dist-app/
6+
dependency-reduced-pom.xml
7+
target/*.jar
8+
target/maven-archiver/
9+
target/maven-status/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ Or with Maven (if installed):
103103
mvn clean compile
104104
```
105105

106+
Or with the included Maven Wrapper (no global Maven install required):
107+
108+
```bash
109+
# Linux/macOS
110+
./mvnw clean compile
111+
112+
# Windows
113+
mvnw.cmd clean compile
114+
```
115+
106116
### Run
107117

108118
```bash
@@ -118,6 +128,62 @@ java -cp "out;lib/gson-2.10.1.jar" com.mynosql.Main --shell
118128
> java -cp "out:lib/gson-2.10.1.jar" com.mynosql.Main
119129
> ```
120130
131+
### Share with Others (JAR or EXE)
132+
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
160+
161+
If you want users to launch via an `.exe`, build with `jpackage` (included in modern JDKs):
162+
163+
```bat
164+
scripts\build-exe.bat
165+
```
166+
167+
Output:
168+
169+
- Installer and app files in `dist/`
170+
171+
Notes:
172+
173+
- `jpackage` requires JDK 17+ and must be on `PATH`.
174+
- The generated `.exe` is Windows-specific.
175+
- If you need macOS/Linux native packages too, run equivalent `jpackage` commands on those OSes.
176+
177+
#### Option 3: Automatic release artifacts via GitHub Actions
178+
179+
This repository includes a workflow at `.github/workflows/release-artifacts.yml` that:
180+
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.
184+
185+
You can also run it manually from the Actions tab using `workflow_dispatch`.
186+
121187
---
122188

123189
## Usage

mvnw

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mvnw.cmd

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/build-app-image.bat

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
@echo off
2+
setlocal
3+
4+
REM Resolve jpackage from PATH first, then fallback to JAVA_HOME\bin
5+
set "JPACKAGE_EXE="
6+
for /f "delims=" %%I in ('where jpackage 2^>nul') do (
7+
if not defined JPACKAGE_EXE set "JPACKAGE_EXE=%%I"
8+
)
9+
10+
if not defined JPACKAGE_EXE (
11+
if defined JAVA_HOME (
12+
for %%I in ("%JAVA_HOME%") do (
13+
if exist "%%~fI\bin\jpackage.exe" set "JPACKAGE_EXE=%%~fI\bin\jpackage.exe"
14+
)
15+
)
16+
)
17+
18+
if not defined JPACKAGE_EXE (
19+
echo jpackage was not found.
20+
echo Install JDK 17+ and ensure either:
21+
echo 1. jpackage is on PATH, or
22+
echo 2. JAVA_HOME points to a JDK root directory.
23+
exit /b 1
24+
)
25+
26+
call mvnw.cmd -q clean package
27+
if errorlevel 1 (
28+
echo Maven build failed.
29+
exit /b 1
30+
)
31+
32+
set "MAIN_JAR="
33+
for %%F in (target\mynosql-*.jar) do (
34+
echo %%~nxF | findstr /I /B "original-" >nul
35+
if errorlevel 1 (
36+
set "MAIN_JAR=%%~nxF"
37+
goto :jarFound
38+
)
39+
)
40+
41+
:jarFound
42+
if "%MAIN_JAR%"=="" (
43+
echo Could not find packaged JAR in target\
44+
exit /b 1
45+
)
46+
47+
if exist dist-app rmdir /s /q dist-app
48+
mkdir dist-app
49+
50+
"%JPACKAGE_EXE%" ^
51+
--type app-image ^
52+
--name MyNoSQL ^
53+
--input target ^
54+
--main-jar %MAIN_JAR% ^
55+
--main-class com.mynosql.Main ^
56+
--dest dist-app ^
57+
--win-console
58+
59+
if errorlevel 1 (
60+
echo App-image packaging failed.
61+
exit /b 1
62+
)
63+
64+
echo.
65+
echo App-image build complete.
66+
echo Run from:
67+
echo dist-app\MyNoSQL\MyNoSQL.exe
68+
69+
endlocal

0 commit comments

Comments
 (0)