Skip to content

Fix Windows build configuration #5

Fix Windows build configuration

Fix Windows build configuration #5

Workflow file for this run

name: Create Release
on:
push:
tags:
- 'v*'
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Get version from tag
id: get_version
run: |
# Convert v1.0.3 to 1.0.3
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
build:
needs: prepare
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
include:
- os: windows-latest
artifact_name: Sudoku-windows.zip
- os: ubuntu-latest
artifact_name: Sudoku-linux.zip
- os: macos-latest
artifact_name: Sudoku-mac.zip
runs-on: ${{ matrix.os }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '23'
distribution: 'oracle'
cache: maven
- name: Update version in pom.xml
run: |
mvn versions:set -DnewVersion=${{ needs.prepare.outputs.version }}
mvn versions:commit
- name: Build with Maven
run: mvn clean package -Pnative-image
# Windows-specific steps
- name: Build Windows Package
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
jpackage --input target/ `
--main-jar Sudoku.jar `
--main-class App `
--type exe `
--name Sudoku `
--app-version ${{ needs.prepare.outputs.version }} `
--win-dir-chooser `
--win-menu `
--win-shortcut
if (Test-Path "Sudoku.exe") {
Compress-Archive -Path "Sudoku.exe" -DestinationPath ${{ matrix.artifact_name }}
} else {
Write-Error "Sudoku.exe not found!"
exit 1
}
# Linux-specific steps
- name: Build Linux Package
if: matrix.os == 'ubuntu-latest'
run: |
jpackage --input target/ \
--main-jar Sudoku.jar \
--main-class App \
--type deb \
--name Sudoku \
--app-version ${{ needs.prepare.outputs.version }}
zip -r ${{ matrix.artifact_name }} *.deb
# macOS-specific steps
- name: Build macOS Package
if: matrix.os == 'macos-latest'
run: |
jpackage --input target/ \
--main-jar Sudoku.jar \
--main-class App \
--type dmg \
--name Sudoku \
--app-version ${{ needs.prepare.outputs.version }} \
--mac-package-name Sudoku
zip -r ${{ matrix.artifact_name }} *.dmg
- name: Upload Release Assets
uses: softprops/action-gh-release@v1
with:
files: |
${{ matrix.artifact_name }}
target/Sudoku.jar
name: Release ${{ needs.prepare.outputs.version }}
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}