|
| 1 | +name: Build java app image |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + sem-version: |
| 9 | + description: 'Version' |
| 10 | + required: false |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + packages: write |
| 15 | + |
| 16 | +env: |
| 17 | + JAVA_DIST: 'zulu' |
| 18 | + JAVA_VERSION: '22.0.2+9' |
| 19 | + |
| 20 | +defaults: |
| 21 | + run: |
| 22 | + shell: bash |
| 23 | + |
| 24 | +jobs: |
| 25 | + prepare: |
| 26 | + name: Determines the versions strings for the binaries |
| 27 | + runs-on: [ubuntu-latest] |
| 28 | + outputs: |
| 29 | + semVerStr: ${{ steps.determine-version.outputs.version }} |
| 30 | + semVerNum: ${{steps.determine-number.outputs.number}} |
| 31 | + steps: |
| 32 | + - id: determine-version |
| 33 | + shell: pwsh |
| 34 | + run: | |
| 35 | + if ( ${{github.event_name}} -eq 'release') { |
| 36 | + echo "version=${{ github.event.release.tag_name}}" >> "$GITHUB_OUTPUT" |
| 37 | + exit 0 |
| 38 | + } else if (${{inputs.sem-version}}) { |
| 39 | + echo "version=${{ inputs.sem-version}}" >> "$GITHUB_OUTPUT" |
| 40 | + exit 0 |
| 41 | + } |
| 42 | + Write-Error "Version neither via input nor by tag specified. Aborting" |
| 43 | + exit 1 |
| 44 | + - id: determine-number |
| 45 | + run: | |
| 46 | + SEM_VER_NUM=$(echo "${{ steps.determine-version.outputs.version }}" | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+).*/\1/') |
| 47 | + echo "number=${SEM_VER_NUM}" >> "$GITHUB_OUTPUT" |
| 48 | +
|
| 49 | + build-binary: |
| 50 | + name: Build java app image |
| 51 | + needs: [prepare] |
| 52 | + strategy: |
| 53 | + fail-fast: false |
| 54 | + matrix: |
| 55 | + include: |
| 56 | + - os: ubuntu-latest |
| 57 | + architecture: x64 |
| 58 | + native-access-lib: 'org.cryptomator.jfuse.linux.amd64' |
| 59 | + binary-dir-suffix: "" |
| 60 | + - os: [self-hosted, Linux, ARM64] |
| 61 | + architecture: aarch64 |
| 62 | + native-access-lib: 'org.cryptomator.jfuse.linux.aarch64' |
| 63 | + binary-dir-suffix: "" |
| 64 | + - os: macos-latest-large |
| 65 | + architecture: x64 |
| 66 | + native-access-lib: 'org.cryptomator.jfuse.mac' |
| 67 | + binary-dir-suffix: ".app" |
| 68 | + - os: macos-latest |
| 69 | + architecture: aarch64 |
| 70 | + native-access-lib: 'org.cryptomator.jfuse.mac' |
| 71 | + binary-dir-suffix: ".app" |
| 72 | + - os: windows-latest |
| 73 | + architecture: x64 |
| 74 | + native-access-lib: 'org.cryptomator.jfuse.win' |
| 75 | + binary-dir-suffix: "" |
| 76 | + runs-on: ${{ matrix.os }} |
| 77 | + steps: |
| 78 | + - name: Preparations fpr windows runner |
| 79 | + if: startsWith(matrix.os, 'windows') |
| 80 | + run: echo "JPACKAGE_OS_OPTS=--win-console" >> "$GITHUB_ENV" |
| 81 | + - uses: actions/checkout@v4 |
| 82 | + - uses: actions/setup-java@v4 |
| 83 | + with: |
| 84 | + java-version: '22' |
| 85 | + distribution: 'zulu' |
| 86 | + - name: Set version |
| 87 | + run: mvn versions:set -DnewVersion=${{ needs.prepare.outputs.semVerStr }} |
| 88 | + - name: Run maven |
| 89 | + run: mvn -B clean package -Pwin -DskipTests |
| 90 | + - name: Patch target dir |
| 91 | + run: | |
| 92 | + cp LICENSE.txt target |
| 93 | + cp target/cryptomator-*.jar target/mods |
| 94 | + - name: Run jlink |
| 95 | + shell: pwsh |
| 96 | + run: > |
| 97 | + & $env:JAVA_HOME\bin\jlink |
| 98 | + --verbose |
| 99 | + --output target\runtime |
| 100 | + --module-path "${env:JAVA_HOME}\jmods" |
| 101 | + --add-modules java.base,java.compiler,java.naming,java.xml ` |
| 102 | + --strip-native-commands ` |
| 103 | + --no-header-files ` |
| 104 | + --no-man-pages ` |
| 105 | + --strip-debug ` |
| 106 | + --compress zip-6 |
| 107 | + - name: Run jpackage |
| 108 | + shell: pwsh |
| 109 | + run: > |
| 110 | + & $env:JAVA_HOME\bin\jpackage |
| 111 | + --verbose |
| 112 | + --type app-image |
| 113 | + --runtime-image target/runtime |
| 114 | + --input target/libs |
| 115 | + --module-path target/mods |
| 116 | + --module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli |
| 117 | + --dest target |
| 118 | + --name cryptomator-cli |
| 119 | + --vendor "Skymatic GmbH" |
| 120 | + --copyright "(C) 2016 - 2024 Skymatic GmbH" |
| 121 | + --app-version "${{ needs.prepare.outputs.semVerNum }}" |
| 122 | + --java-options "-Dorg.cryptomator.cli.version=${{ needs.prepare.outputs.semVerStr }}" |
| 123 | + --java-options "--enable-preview" |
| 124 | + --java-options "--enable-native-access=${{ matrix.native-access-lib }}" |
| 125 | + --java-options "-Xss5m" |
| 126 | + --java-options "-Xmx256m" |
| 127 | + --java-options '-Dfile.encoding="utf-8"' |
| 128 | + ${JPACKAGE_OS_OPTS} |
| 129 | + - uses: actions/upload-artifact@v4 |
| 130 | + with: |
| 131 | + path: ./target/cryptomator-cli${{ matrix.binary-dir-suffix }} |
| 132 | + if-no-files-found: error |
| 133 | + - name: Zip binary for release |
| 134 | + if: startsWith(github.ref, 'refs/tags/') && github.event.action == 'published' |
| 135 | + shell: pwsh |
| 136 | + run: Compress-Archive -Path .\target\cryptomator-cli${{ matrix.binary-dir-suffix }} -DestinationPath .\cryptomator-cli-${{ needs.prepare.outputs.semVerStr }}.zip |
| 137 | + - name: Create detached GPG signature with key 615D449FE6E6A235 |
| 138 | + run: | |
| 139 | + echo "${GPG_PRIVATE_KEY}" | gpg --batch --quiet --import |
| 140 | + echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 615D449FE6E6A235 --detach-sign -a ./cryptomator-cli-${{ needs.prepare.outputs.semVerStr }}.zip |
| 141 | + env: |
| 142 | + GPG_PRIVATE_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} |
| 143 | + GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }} |
| 144 | + - name: Publish artefact on GitHub Releases |
| 145 | + if: startsWith(github.ref, 'refs/tags/') && github.event.action == 'published' |
| 146 | + uses: softprops/action-gh-release@v2 |
| 147 | + with: |
| 148 | + fail_on_unmatched_files: true |
| 149 | + token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }} |
| 150 | + files: | |
| 151 | + cryptomator-cli-${{ needs.prepare.outputs.semVerStr }}.zip |
| 152 | + cryptomator-cli-*.asc |
| 153 | +
|
0 commit comments