Skip to content

Commit d4e6317

Browse files
authored
Merge pull request #68 from cryptomator/feature/revamp
Feature: Refactor CLI
2 parents 8cf9bdd + c35d317 commit d4e6317

30 files changed

+1546
-753
lines changed

.github/workflows/build-binary.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
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+

.github/workflows/build.yml

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,66 +9,33 @@ jobs:
99
build:
1010
name: Build and Test
1111
runs-on: ubuntu-latest
12-
#This check is case insensitive
13-
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
1412
outputs:
1513
artifactVersion: ${{ steps.setversion.outputs.version }}
1614
steps:
17-
- uses: actions/checkout@v2
18-
- uses: actions/setup-java@v1
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-java@v4
1917
with:
20-
java-version: 17
21-
- uses: actions/cache@v1
22-
with:
23-
path: ~/.m2/repository
24-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
25-
restore-keys: |
26-
${{ runner.os }}-maven-
18+
java-version: '22'
19+
distribution: 'temurin'
2720
- name: Ensure to use tagged version
2821
run: mvn versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/} # use shell parameter expansion to strip of 'refs/tags'
2922
if: startsWith(github.ref, 'refs/tags/')
3023
- name: Output project version
3124
id: setversion
3225
run: |
3326
BUILD_VERSION=$(mvn help:evaluate "-Dexpression=project.version" -q -DforceStdout)
34-
echo "::set-output name=version::${BUILD_VERSION}"
27+
echo "version=${BUILD_VERSION}" >> "$GITHUB_OUTPUT"
3528
- name: Build and Test
3629
run: mvn -B install
3730
- name: Upload artifact cryptomator-cli-${{ steps.setversion.outputs.version }}.jar
38-
uses: actions/upload-artifact@v2
31+
uses: actions/upload-artifact@v4
3932
with:
4033
name: cryptomator-cli-${{ steps.setversion.outputs.version }}.jar
4134
path: target/cryptomator-cli-*.jar
42-
43-
release:
44-
name: Draft a Release on GitHub Releases and uploads the build artifacts to it
45-
runs-on: ubuntu-latest
46-
needs: build
47-
if: startsWith(github.ref, 'refs/tags/')
48-
steps:
49-
- name: Download cryptomator-cli.jar
50-
uses: actions/download-artifact@v1
51-
with:
52-
name: cryptomator-cli-${{ needs.build.outputs.artifactVersion }}.jar
53-
path: .
54-
- name: Create Release
55-
id: create_release
56-
uses: actions/create-release@v1
57-
env:
58-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59-
with:
60-
tag_name: ${{ github.ref }}
61-
release_name: ${{ github.ref }}
62-
body: |
63-
:construction: Work in Progress
64-
draft: true
65-
prerelease: false
66-
- name: Upload cryptomator-cli-${{ needs.build.outputs.artifactVersion }}.jar to GitHub Releases
67-
uses: actions/[email protected]
68-
env:
69-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
- name: Create release
36+
if: startsWith(github.ref, 'refs/tags/')
37+
uses: softprops/action-gh-release@v2
7038
with:
71-
upload_url: ${{ steps.create_release.outputs.upload_url }}
72-
asset_path: cryptomator-cli-${{ needs.build.outputs.artifactVersion }}.jar
73-
asset_name: cryptomator-cli-${{ needs.build.outputs.artifactVersion }}.jar
74-
asset_content_type: application/jar
39+
token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}
40+
generate_release_notes: true
41+
draft: true

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@ out/
1818
.idea_modules/
1919
*.iws
2020

21-
*.iml
21+
*.iml
22+
23+
#mvn shade plugin artifact
24+
dependency-reduced-pom.xml
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
wrapperVersion=3.3.2
18+
distributionType=only-script
19+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip

Dockerfile

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)