diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index ee16919..ca85d8e 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -77,36 +77,17 @@ jobs: cp LICENSE.txt target cp target/cryptomator-*.jar target/mods - name: Run jlink - run: > - "${JAVA_HOME}/bin/jlink" - --verbose - --output target/runtime - --module-path "${JAVA_HOME}/jmods" - --add-modules java.base,java.compiler,java.naming,java.xml - --strip-native-commands - --no-header-files - --no-man-pages - --strip-debug - --compress zip-6 + run: | + envsubst < dist/jlink.args > target/jlink.args + "${JAVA_HOME}/bin/jlink" '@./target/jlink.args' - name: Run jpackage - run: > - "${JAVA_HOME}/bin/jpackage" - --verbose - --type app-image - --runtime-image target/runtime - --input target/libs - --module-path target/mods - --module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli - --dest target - --name cryptomator-cli - --vendor "Skymatic GmbH" - --copyright "(C) 2016 - 2024 Skymatic GmbH" - --app-version "${{ needs.prepare.outputs.semVerNum }}" - --java-options "-Dorg.cryptomator.cli.version=${{ needs.prepare.outputs.semVerStr }}" - --java-options "--enable-native-access=${{ matrix.native-access-lib }}" - --java-options "-Xss5m" - --java-options "-Xmx256m" - --java-options "-Dfile.encoding=\"utf-8\"" + run: | + envsubst < dist/jpackage.args > target/jpackage.args + "${JAVA_HOME}/bin/jpackage" '@./target/jpackage.args' + env: + JP_APP_VERSION: ${{ needs.prepare.outputs.semVerNum }} + APP_VERSION: ${{ needs.prepare.outputs.semVerStr }} + NATIVE_ACCESS_PACKAGE: ${{ matrix.native-access-lib }} - uses: actions/upload-artifact@v4 with: name: cryptomator-cli-linux-${{ matrix.architecture }} diff --git a/.github/workflows/build-mac.yml b/.github/workflows/build-mac.yml index c84a180..6de7644 100644 --- a/.github/workflows/build-mac.yml +++ b/.github/workflows/build-mac.yml @@ -82,36 +82,22 @@ jobs: cp LICENSE.txt target cp target/cryptomator-*.jar target/mods - name: Run jlink - run: > - "${JAVA_HOME}/bin/jlink" - --verbose - --output target/runtime - --module-path "${JAVA_HOME}/jmods" - --add-modules java.base,java.compiler,java.naming,java.xml - --strip-native-commands - --no-header-files - --no-man-pages - --strip-debug - --compress zip-6 + run: | + envsubst < dist/jlink.args > target/jlink.args + "${JAVA_HOME}/bin/jlink" '@./target/jlink.args' - name: Run jpackage - run: > - "${JAVA_HOME}/bin/jpackage" - --verbose - --type app-image - --runtime-image target/runtime - --input target/libs - --module-path target/mods - --module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli - --dest target - --name cryptomator-cli - --vendor "Skymatic GmbH" - --copyright "(C) 2016 - 2024 Skymatic GmbH" - --app-version "${{ needs.prepare.outputs.semVerNum }}" - --java-options "-Dorg.cryptomator.cli.version=${{ needs.prepare.outputs.semVerStr }}" - --java-options "--enable-native-access=org.cryptomator.jfuse.mac" - --java-options "-Xss5m" - --java-options "-Xmx256m" - --java-options "-Dfile.encoding=\"utf-8\"" + run: | + envsubst < dist/jpackage.args > target/jpackage.args + "${JAVA_HOME}/bin/jpackage" '@./target/jpackage.args' + env: + JP_APP_VERSION: ${{ needs.prepare.outputs.semVerNum }} + APP_VERSION: ${{ needs.prepare.outputs.semVerStr }} + NATIVE_ACCESS_PACKAGE: org.cryptomator.jfuse.mac + - uses: actions/upload-artifact@v4 + with: + name: cryptomator-cli-mac-${{ matrix.architecture }} + path: ./target/cryptomator-cli.app + if-no-files-found: error - name: Patch .app dir run: | sed -i '' "s|###BUNDLE_SHORT_VERSION_STRING###|${VERSION_NO}|g" ./target/cryptomator-cli.app/Contents/Info.plist @@ -234,5 +220,4 @@ jobs: token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }} files: | ${{ matrix.artifact-name }} - cryptomator-cli-*.asc - + cryptomator-cli-*.asc \ No newline at end of file diff --git a/.github/workflows/build-win.yml b/.github/workflows/build-win.yml index 7aa3c3a..23524be 100644 --- a/.github/workflows/build-win.yml +++ b/.github/workflows/build-win.yml @@ -67,37 +67,17 @@ jobs: cp LICENSE.txt target cp target/cryptomator-*.jar target/mods - name: Run jlink - run: > - "${JAVA_HOME}/bin/jlink" - --verbose - --output target/runtime - --module-path "${JAVA_HOME}/jmods" - --add-modules java.base,java.compiler,java.naming,java.xml - --strip-native-commands - --no-header-files - --no-man-pages - --strip-debug - --compress zip-6 + run: | + envsubst < dist/jlink.args > target/jlink.args + "${JAVA_HOME}/bin/jlink" '@./target/jlink.args' - name: Run jpackage - run: > - "${JAVA_HOME}/bin/jpackage" - --verbose - --type app-image - --runtime-image target/runtime - --input target/libs - --module-path target/mods - --module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli - --dest target - --name cryptomator-cli - --vendor "Skymatic GmbH" - --copyright "(C) 2016 - 2024 Skymatic GmbH" - --app-version "${{ needs.prepare.outputs.semVerNum }}" - --java-options "-Dorg.cryptomator.cli.version=${{ needs.prepare.outputs.semVerStr }}" - --java-options "--enable-native-access=org.cryptomator.jfuse.win" - --java-options "-Xss5m" - --java-options "-Xmx256m" - --java-options "-Dfile.encoding=\"utf-8\"" - --win-console + run: | + envsubst < dist/jpackage.args > target/jpackage.args + "${JAVA_HOME}/bin/jpackage" '@./target/jpackage.args' --win-console + env: + JP_APP_VERSION: ${{ needs.prepare.outputs.semVerNum }} + APP_VERSION: ${{ needs.prepare.outputs.semVerStr }} + NATIVE_ACCESS_PACKAGE: org.cryptomator.jfuse.win - name: Fix permissions run: attrib -r target/cryptomator-cli/cryptomator-cli.exe shell: pwsh diff --git a/README.md b/README.md index 401ee08..d534232 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,9 @@ Afterward, you can directly run Cryptomator-CLI by calling the binary, e.g. on L To unmount, send a SIGTERM signal to the process, e.g. by pressing CTRL+C (macOS: CMD+C) in the terminal. -For a complete list of options, use the`--help` option. +For a complete list of options, use the `--help` option. ```shell -cryptomator-cli --help` +cryptomator-cli --help ``` ## Filesystem Integration diff --git a/build_linux.sh b/build_linux.sh index da5dc5f..d1be9cc 100644 --- a/build_linux.sh +++ b/build_linux.sh @@ -3,6 +3,8 @@ set -euxo pipefail echo "Building cryptomator cli..." +export APP_VERSION='0.1.0-local' + # Check if Maven is installed if ! command -v mvn &> /dev/null; then echo "Maven is not installed. Please install Maven to proceed." @@ -29,23 +31,15 @@ cp ./LICENSE.txt ./target/ mv ./target/cryptomator-cli-*.jar ./target/mods echo "Creating JRE with jlink..." -"$JAVA_HOME/bin/jlink" \ - --verbose \ - --output target/runtime \ - --module-path "${JAVA_HOME}/jmods" \ - --add-modules java.base,java.compiler,java.naming,java.xml \ - --strip-native-commands \ - --no-header-files \ - --no-man-pages \ - --strip-debug \ - --compress zip-0 +envsubst < dist/jlink.args > target/jlink.args +"$JAVA_HOME/bin/jlink" '@./target/jlink.args' if [ $? -ne 0 ] || [ ! -d ./target/runtime ]; then echo "JRE creation with jlink failed." exit 1 fi -NATIVE_ACCESS_PACKAGE="no.native.access.available" +export NATIVE_ACCESS_PACKAGE="no.native.access.available" _OS=$(uname -s) if (echo "$_OS" | grep -q "Linux.*") ; then _ARCH=$(uname -m) @@ -59,25 +53,11 @@ if (echo "$_OS" | grep -q "Linux.*") ; then fi fi +export JP_APP_VERSION='99.9.9' +envsubst < dist/jpackage.args > target/jpackage.args + echo "Creating app binary with jpackage..." -"$JAVA_HOME/bin/jpackage" \ - --verbose \ - --type app-image \ - --runtime-image target/runtime \ - --input target/libs \ - --module-path target/mods \ - --module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli \ - --dest target \ - --name cryptomator-cli \ - --vendor "Skymatic GmbH" \ - --copyright "(C) 2016 - 2024 Skymatic GmbH" \ - --app-version "0.0.1.0" \ - --java-options "-Dorg.cryptomator.cli.version=0.0.1-local" \ - --java-options "--enable-preview" \ - --java-options "--enable-native-access=${NATIVE_ACCESS_PACKAGE}" \ - --java-options "-Xss5m" \ - --java-options "-Xmx256m" \ - --java-options "-Dfile.encoding=utf-8" \ +"$JAVA_HOME/bin/jpackage" '@./target/jpackage.args' if [ $? -ne 0 ] || [ ! -d ./target/cryptomator-cli ]; then echo "Binary creation with jpackage failed." diff --git a/build_mac.sh b/build_mac.sh index 7d8350b..a46b5c5 100644 --- a/build_mac.sh +++ b/build_mac.sh @@ -2,6 +2,8 @@ echo "Building cryptomator cli..." +export APP_VERSION='0.1.0-local' + # Check if Maven is installed if ! command -v mvn &> /dev/null; then echo "Maven is not installed. Please install Maven to proceed." @@ -28,41 +30,20 @@ cp ./LICENSE.txt ./target/ mv ./target/cryptomator-cli-*.jar ./target/mods echo "Creating JRE with jlink..." -"$JAVA_HOME/bin/jlink" \ - --verbose \ - --output target/runtime \ - --module-path "${JAVA_HOME}/jmods" \ - --add-modules java.base,java.compiler,java.naming,java.xml \ - --strip-native-commands \ - --no-header-files \ - --no-man-pages \ - --strip-debug \ - --compress zip-0 +envsubst < dist/jlink.args > target/jlink.args +"$JAVA_HOME/bin/jlink" '@./target/jlink.args' if [ $? -ne 0 ] || [ ! -d ./target/runtime ]; then echo "JRE creation with jlink failed." exit 1 fi +export JP_APP_VERSION='99.9.9' +export NATIVE_ACCESS_PACKAGE="org.cryptomator.jfuse.mac" +envsubst < dist/jpackage.args > target/jpackage.args + echo "Creating app binary with jpackage..." -"$JAVA_HOME/bin/jpackage" \ - --verbose \ - --type app-image \ - --runtime-image target/runtime \ - --input target/libs \ - --module-path target/mods \ - --module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli \ - --dest target \ - --name cryptomator-cli \ - --vendor "Skymatic GmbH" \ - --copyright "(C) 2016 - 2024 Skymatic GmbH" \ - --app-version "99.9.9" \ - --java-options "-Dorg.cryptomator.cli.version=0.0.1-local" \ - --java-options "--enable-preview" \ - --java-options "--enable-native-access=org.cryptomator.jfuse.mac" \ - --java-options "-Xss5m" \ - --java-options "-Xmx256m" \ - --java-options "-Dfile.encoding=utf-8" \ +"$JAVA_HOME/bin/jpackage" '@./target/jpackage.args' if [ $? -ne 0 ] || [ ! -d ./target/cryptomator-cli.app ]; then echo "Binary creation with jpackage failed." diff --git a/build_win.ps1 b/build_win.ps1 index 3cafd14..bfdc144 100644 --- a/build_win.ps1 +++ b/build_win.ps1 @@ -1,5 +1,7 @@ "Building cryptomator cli..." +$appVersion='0.1.0-local' + # Check if maven is installed $commands = 'mvn' foreach ($cmd in $commands) { @@ -12,9 +14,9 @@ if(-not $env:JAVA_HOME) { } # Check Java version -$minJavaVersion=$(mvn help:evaluate "-Dexpression=jdk.version" -q -DforceStdout) +$minJavaVersion=[int]$(mvn help:evaluate "-Dexpression=jdk.version" -q -DforceStdout) $javaVersion = $(& "$env:JAVA_HOME\bin\java" --version) -split ' ' | Select-Object -Index 1 -if( ($javaVersion -split '.' | Select-Object -First 1) -ne "22") { +if( ([int] ($javaVersion.Split('.') | Select-Object -First 1)) -lt $minJavaVersion) { throw "Java version $javaVersion is too old. Minimum required version is $minJavaVersion" } @@ -24,43 +26,24 @@ Copy-Item ./LICENSE.txt -Destination ./target -ErrorAction Stop Move-Item ./target/cryptomator-cli-*.jar ./target/mods -ErrorAction Stop Write-Host "Creating JRE with jlink..." -& $env:JAVA_HOME/bin/jlink ` ---verbose ` ---output target/runtime ` ---module-path "${env:JAVA_HOME}/jmods" ` ---add-modules java.base,java.compiler,java.naming,java.xml ` ---strip-native-commands ` ---no-header-files ` ---no-man-pages ` ---strip-debug ` ---compress zip-0 +Get-Content -Path './dist/jlink.args' | ForEach-Object { $_.Replace('${JAVA_HOME}', "$env:JAVA_HOME")} | Out-File -FilePath './target/jlink.args' +& $env:JAVA_HOME/bin/jlink `@./target/jlink.args if ( ($LASTEXITCODE -ne 0) -or (-not (Test-Path ./target/runtime))) { - throw "JRE creation with jLink failed with exit code $LASTEXITCODE." + throw "JRE creation with jLink failed with exit code $LASTEXITCODE." } +## powershell does not have envsubst +$jpAppVersion='99.9.9' +Get-Content -Path './dist/jpackage.args' | ForEach-Object { + $_.Replace('${APP_VERSION}', $appVersion). + Replace('${JP_APP_VERSION}', $jpAppVersion). + Replace('${NATIVE_ACCESS_PACKAGE}', 'org.cryptomator.jfuse.win') +} | Out-File -FilePath './target/jpackage.args' + # jpackage -# app-version is hard coded, since the script is only for local test builds Write-Host "Creating app binary with jpackage..." -& $env:JAVA_HOME/bin/jpackage ` - --verbose ` - --type app-image ` - --runtime-image target/runtime ` - --input target/libs ` - --module-path target/mods ` - --module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli ` - --dest target ` - --name cryptomator-cli ` - --vendor "Skymatic GmbH" ` - --copyright "(C) 2016 - 2024 Skymatic GmbH" ` - --app-version "0.0.1.0" ` - --java-options "-Dorg.cryptomator.cli.version=0.0.1-local" ` - --java-options "--enable-preview" ` - --java-options "--enable-native-access=org.cryptomator.jfuse.win" ` - --java-options "-Xss5m" ` - --java-options "-Xmx256m" ` - --java-options '-Dfile.encoding="utf-8"' ` - --win-console +& $env:JAVA_HOME/bin/jpackage `@./target/jpackage.args --win-console if ( ($LASTEXITCODE -ne 0) -or (-not (Test-Path ./target/cryptomator-cli))) { throw "Binary creation with jpackage failed with exit code $LASTEXITCODE." diff --git a/dist/jlink.args b/dist/jlink.args new file mode 100644 index 0000000..c42f03f --- /dev/null +++ b/dist/jlink.args @@ -0,0 +1,9 @@ +--verbose +--module-path "${JAVA_HOME}/jmods" +--output target/runtime +--add-modules java.base,java.compiler,java.naming,java.xml +--strip-native-commands +--no-header-files +--no-man-pages +--strip-debug +--compress zip-6 \ No newline at end of file diff --git a/dist/jpackage.args b/dist/jpackage.args new file mode 100644 index 0000000..599212f --- /dev/null +++ b/dist/jpackage.args @@ -0,0 +1,20 @@ +# Contains three env vars: +# JP_APP_VERSION: The version needed for jpackage. This version _must_ follow the scheme Y.X.X, where Y >= 1 and X >=0 +# APP_VERSION: The actual, semantic version displayed in the cli app +# NATIVE_ACCESS_PACKAGE: The java package containing the fuse bindings for the system +--verbose +--type app-image +--runtime-image target/runtime +--input target/libs +--module-path target/mods +--module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli +--dest target +--name cryptomator-cli +--vendor "Skymatic GmbH" +--copyright "(C) 2016 - 2024 Skymatic GmbH" +--app-version "${JP_APP_VERSION}" +--java-options "-Dorg.cryptomator.cli.version=${APP_VERSION}" +--java-options "--enable-native-access=${NATIVE_ACCESS_PACKAGE}" +--java-options "-Xss5m" +--java-options "-Xmx256m" +--java-options "-Dfile.encoding=\"utf-8\"" \ No newline at end of file