Skip to content

Commit

Permalink
build(macos): Build macOS dmg with GitHub Actions (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandmalfarbe committed Dec 28, 2023
1 parent 398c09b commit 025096f
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 67 deletions.
68 changes: 31 additions & 37 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,44 @@
name: Java CI with Maven

on: [push, pull_request]
on: [ push, pull_request ]

jobs:
build-linux:
build-non-macos:

runs-on: ubuntu-latest
strategy:
matrix:
java-version: [ 17, 21 ]
os: [ ubuntu-latest, windows-latest ]

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn clean package --batch-mode --threads 4

build-windows:

runs-on: windows-latest
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn clean package --batch-mode --threads 4

- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: temurin
cache: maven
- name: Build with Maven
run: mvn clean package --batch-mode --threads 4

build-macos:

runs-on: macos-latest
strategy:
matrix:
java-version: [ 17, 21 ]
os: [ macos-latest ]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn clean package --batch-mode --threads 4
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: temurin
cache: maven
- name: Build with Maven
run: mvn clean package --batch-mode --threads 4 -Pmacos
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ In order to build the runnable JAR file and all other artifacts, you have to run
mvn clean package
```
The macOS build is only possible on Macs and disabled during the normal build. You have to pass the profile `macos` to
Maven in order to build the `dmg` file:
```
mvn clean package -Pmacos
```
## Known Issues / Bugs
- The App is only translated in English and German.
Expand Down
70 changes: 40 additions & 30 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,46 @@
</repository>
</repositories>

<profiles>
<profile>
<id>macos</id>
<build>
<plugins>
<!-- create macOS app and disk image -->
<!-- This plugin can only be run on macOS, so it is disabled on a normal build.
Use -Pmacos to enable it. -->
<plugin>
<groupId>de.perdian.maven.plugins</groupId>
<artifactId>macosappbundler-maven-plugin</artifactId>
<version>1.19.0</version>
<configuration>
<plist>
<CFBundleIconFile>src/main/assembly/dist-macos/EPUBCheckFX.icns</CFBundleIconFile>
<NSHumanReadableCopyright>Copyright © 2023 Pascal Wagler. All rights reserved.
</NSHumanReadableCopyright>

<JVMMainClassName>de.pascalwagler.epubcheckfx.ui.Launcher</JVMMainClassName>
</plist>
<dmg>
<generate>true</generate>
<appendVersion>false</appendVersion>
<dmgFileName>${project.name}-${project.version}-macOS-x86_64</dmgFileName>
</dmg>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>bundle</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<dependencies>
<!-- build cross-platform fat JAR -->
<!-- see https://github.com/openjfx/javafx-maven-plugin/issues/58 and https://github.com/betanzos/cross-platform-app-fx -->
Expand Down Expand Up @@ -371,36 +411,6 @@
</executions>
</plugin>

<!-- create macOS app and disk image -->
<!-- This plugin can only be run on macOS, so it is disabled to enable a build on all platforms. -->
<!--<plugin>
<groupId>de.perdian.maven.plugins</groupId>
<artifactId>macosappbundler-maven-plugin</artifactId>
<version>1.19.0</version>
<configuration>
<plist>
<CFBundleIconFile>src/main/assembly/dist-macos/EPUBCheckFX.icns</CFBundleIconFile>
<NSHumanReadableCopyright>Copyright © 2023 Pascal Wagler. All rights reserved.
</NSHumanReadableCopyright>
<JVMMainClassName>de.pascalwagler.epubcheckfx.ui.Launcher</JVMMainClassName>
</plist>
<dmg>
<generate>true</generate>
<appendVersion>false</appendVersion>
<dmgFileName>${project.name}-${project.version}-macOS-x86_64</dmgFileName>
</dmg>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>bundle</goal>
</goals>
</execution>
</executions>
</plugin>-->

<!-- create packages (ZIP files) for Windows and Linux -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down

0 comments on commit 025096f

Please sign in to comment.