@@ -8,21 +8,106 @@ permissions:
88
99jobs :
1010 package :
11- runs-on : ubuntu-latest
11+ name : Package on ${{ matrix.os }}
12+ strategy :
13+ matrix :
14+ os : [ ubuntu-latest, windows-latest, macos-latest ]
15+ runs-on : ${{ matrix.os }}
1216
1317 steps :
14- - uses : actions/checkout@v6
15- - name : Set up JDK 17
16- uses : actions/setup-java@v5
17- with :
18- java-version : ' 17'
19- distribution : ' temurin'
20- cache : maven
21- - name : Build with Maven
22- run : mvn -B package --file pom.xml '-Dmaven.test.skip=true'
23- - name : Upload artifact
24- uses : actions/upload-artifact@v4
25- with :
26- name : genCode
27- path : target/genCode.jar
28- retention-days : 1
18+ - name : Checkout
19+ uses : actions/checkout@v6
20+
21+ - name : Setup JDK
22+ uses : actions/setup-java@v5
23+ with :
24+ distribution : temurin
25+ java-version : 17
26+
27+ - name : Cache Maven packages
28+ uses : actions/cache@v5
29+ with :
30+ path : ~/.m2/repository
31+ key : ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
32+ restore-keys : |
33+ ${{ runner.os }}-maven-
34+
35+ - name : Build with Maven
36+ shell : bash
37+ run : mvn -B clean package --no-transfer-progress -DskipTests
38+
39+ - name : Resolve version & stage files (Windows)
40+ if : runner.os == 'Windows'
41+ shell : pwsh
42+ run : |
43+ $versionOutput = & mvn -q -DforceStdout 'help:evaluate' -Dexpression='project.version' 2>$null
44+ $version = $versionOutput.Trim()
45+ if (-not $version) { throw 'Failed to extract version from Maven' }
46+ Add-Content -Path $env:GITHUB_ENV -Value "APP_VERSION=$version" -Encoding utf8
47+
48+ $stagingDir = 'staging'
49+ if (-not (Test-Path $stagingDir)) { New-Item -ItemType Directory -Path $stagingDir | Out-Null }
50+
51+ Copy-Item -Path 'target\genCode.jar' -Destination $stagingDir
52+ Copy-Item -Path 'README.md' -Destination $stagingDir
53+ Copy-Item -Path 'LICENSE' -Destination $stagingDir
54+ Copy-Item -Path 'scripts\win\*' -Destination $stagingDir -Recurse
55+
56+ - name : Download JRE (Windows)
57+ if : runner.os == 'Windows'
58+ shell : pwsh
59+ run : |
60+ Push-Location staging
61+ & ..\scripts\jre.ps1
62+ Pop-Location
63+
64+ - name : Resolve version & stage files (Linux)
65+ if : runner.os == 'Linux'
66+ shell : bash
67+ run : |
68+ version=$(mvn -q -DforceStdout 'help:evaluate' -Dexpression=project.version 2>/dev/null)
69+ version=$(echo "$version" | tr -d '\r')
70+ if [ -z "$version" ]; then echo "Failed to extract version from Maven" >&2; exit 1; fi
71+ echo "APP_VERSION=$version" >> $GITHUB_ENV
72+
73+ mkdir -p staging
74+ cp target/genCode.jar staging/
75+ cp README.md LICENSE staging/
76+ cp scripts/linux/* staging/
77+
78+ - name : Download JRE (Linux)
79+ if : runner.os == 'Linux'
80+ shell : bash
81+ run : |
82+ cd staging
83+ bash ../scripts/jre.sh
84+ cd ..
85+
86+ - name : Resolve version & stage files (macOS)
87+ if : runner.os == 'macOS'
88+ shell : bash
89+ run : |
90+ version=$(mvn -q -DforceStdout 'help:evaluate' -Dexpression=project.version 2>/dev/null)
91+ version=$(echo "$version" | tr -d '\r')
92+ if [ -z "$version" ]; then echo "Failed to extract version from Maven" >&2; exit 1; fi
93+ echo "APP_VERSION=$version" >> $GITHUB_ENV
94+
95+ mkdir -p staging
96+ cp target/genCode.jar staging/
97+ cp README.md LICENSE staging/
98+ cp scripts/mac/* staging/
99+
100+ - name : Download JRE (macOS)
101+ if : runner.os == 'macOS'
102+ shell : bash
103+ run : |
104+ cd staging
105+ bash ../scripts/jre_mac.sh
106+ cd ..
107+
108+ - name : Upload packaged artifact
109+ uses : actions/upload-artifact@v4
110+ with :
111+ name : genCode-${{ matrix.os }}
112+ path : staging/
113+ retention-days : 7
0 commit comments