-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (136 loc) · 4.92 KB
/
Copy pathrelease-windows.yaml
File metadata and controls
159 lines (136 loc) · 4.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Build and Release Windows EXE
on:
workflow_dispatch:
push:
tags:
- 'v*'
permissions:
contents: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
JAVA_VERSION: '25'
DOTNET_VERSION: '8.0.x'
WIX_VERSION: '5.0.2'
APP_NAME: 'FreeTPV'
APP_VENDOR: 'Mateo'
APP_DESCRIPTION: 'TPV de escritorio para hostelería'
MAIN_CLASS: 'com.mateo.freetpv.Launcher'
WIN_UPGRADE_UUID: '0606bb5d-a450-4e6d-8071-fd80911820f6'
jobs:
build-windows-exe:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up Java
uses: actions/setup-java@v5
with:
distribution: oracle
java-version: ${{ env.JAVA_VERSION }}
check-latest: true
cache: maven
- name: Set up .NET SDK
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install WiX 5
shell: pwsh
run: |
dotnet tool install --global wix --version $env:WIX_VERSION
"$env:USERPROFILE\.dotnet\tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install WiX extensions
shell: pwsh
run: |
wix extension add --global WixToolset.Util.wixext/$env:WIX_VERSION
wix extension add --global WixToolset.UI.wixext/$env:WIX_VERSION
- name: Verify toolchain
shell: pwsh
run: |
java -version
dotnet --version
wix --version
wix extension list --global
jpackage --version
gh --version
- name: Build with Maven Wrapper
shell: pwsh
run: |
.\mvnw.cmd -B -ntp clean package
- name: Resolve Maven metadata
id: meta
shell: pwsh
run: |
[xml]$pom = Get-Content "pom.xml"
$ns = New-Object System.Xml.XmlNamespaceManager($pom.NameTable)
$ns.AddNamespace("m", "http://maven.apache.org/POM/4.0.0")
$artifactId = $pom.SelectSingleNode("/m:project/m:artifactId", $ns).InnerText
$version = $pom.SelectSingleNode("/m:project/m:version", $ns).InnerText
$jarName = "$artifactId-$version.jar"
if (-not (Test-Path "target\$jarName")) {
Write-Host "Archivos JAR encontrados en target:"
Get-ChildItem "target\*.jar" | ForEach-Object { Write-Host $_.Name }
throw "No encuentro target\$jarName"
}
"artifactId=$artifactId" >> $env:GITHUB_OUTPUT
"version=$version" >> $env:GITHUB_OUTPUT
"jarName=$jarName" >> $env:GITHUB_OUTPUT
- name: Calculate app version
id: appver
shell: pwsh
run: |
$appVersion = "${{ steps.meta.outputs.version }}".Replace("-SNAPSHOT", "")
if ("${{ github.ref_type }}" -eq "tag") {
$appVersion = "${{ github.ref_name }}".TrimStart("v")
}
"appVersion=$appVersion" >> $env:GITHUB_OUTPUT
- name: Package EXE
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist | Out-Null
jpackage `
--type exe `
--name "${{ env.APP_NAME }}" `
--app-version "${{ steps.appver.outputs.appVersion }}" `
--vendor "${{ env.APP_VENDOR }}" `
--description "${{ env.APP_DESCRIPTION }}" `
--dest dist `
--input target `
--main-jar "${{ steps.meta.outputs.jarName }}" `
--main-class "${{ env.MAIN_CLASS }}" `
--icon "src/main/resources/com/mateo/freetpv/icon/freetpv_icon.ico" `
--java-options "--enable-native-access=org.xerial.sqlitejdbc" `
--java-options "--enable-native-access=javafx.graphics" `
--jlink-options "--strip-debug --no-header-files --no-man-pages --bind-services" `
--win-upgrade-uuid "${{ env.WIN_UPGRADE_UUID }}" `
--win-shortcut `
--win-menu `
--win-menu-group "${{ env.APP_NAME }}" `
--win-dir-chooser
- name: Upload workflow artifact
uses: actions/upload-artifact@v6
with:
name: FreeTPV-windows-exe
path: dist/*.exe
if-no-files-found: error
retention-days: 14
- name: Create or update GitHub Release
if: startsWith(github.ref, 'refs/tags/')
env:
GH_TOKEN: ${{ github.token }}
shell: pwsh
run: |
$tag = "${{ github.ref_name }}"
$exe = Get-ChildItem dist\*.exe | Select-Object -First 1
if (-not $exe) {
throw "No se generó ningún .exe en dist"
}
gh release view $tag *> $null
if ($LASTEXITCODE -eq 0) {
gh release upload $tag $exe.FullName --clobber
} else {
gh release create $tag $exe.FullName `
--title "${{ env.APP_NAME }} $tag" `
--generate-notes
}