Skip to content

Commit f18b9a1

Browse files
Feature/cli (#13)
1 parent 3ee6de1 commit f18b9a1

File tree

356 files changed

+3825
-881
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

356 files changed

+3825
-881
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Create Github release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*" # triggers on tags like vX.Y.Z
7+
8+
jobs:
9+
10+
run-only-on-main-branch:
11+
name: Verify main branch
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Check if tag is on main
19+
run: |
20+
git fetch origin main
21+
if git merge-base --is-ancestor $GITHUB_SHA origin/main; then
22+
echo "Tag is on main"
23+
else
24+
echo "Tag is NOT on main, skipping"
25+
#exit 1
26+
fi
27+
28+
build-native:
29+
name: Build on ${{ matrix.os }}
30+
runs-on: ${{ matrix.os }}
31+
needs: run-only-on-main-branch
32+
strategy:
33+
matrix:
34+
os: [windows-latest, ubuntu-latest, macos-latest]
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
39+
40+
- name: Set up GraalVM
41+
uses: graalvm/setup-graalvm@eec48106e0bf45f2976c2ff0c3e22395cced8243
42+
with:
43+
java-version: "21"
44+
distribution: "graalvm"
45+
46+
- name: Build native image
47+
run: mvn -B clean package -Pnative
48+
49+
- name: Locate built executable
50+
id: find_exe
51+
shell: bash
52+
run: |
53+
mkdir dist
54+
55+
OS_NAME=${{ matrix.os }}
56+
if [[ "$OS_NAME" == "windows-latest" ]]; then
57+
BIN_PATH=$(find jfiletreeprettyprinter-cli/target -type f -name "jfiletreeprettyprinter.exe")
58+
else
59+
BIN_PATH=$(find jfiletreeprettyprinter-cli/target -type f -name "jfiletreeprettyprinter")
60+
fi
61+
62+
echo "Found binary: $BIN_PATH"
63+
cp "$BIN_PATH" dist/
64+
echo "bin_path=$BIN_PATH" >> $GITHUB_OUTPUT
65+
66+
- name: Zip executable
67+
id: zip_exe
68+
shell: bash
69+
run: |
70+
VERSION=${GITHUB_REF_NAME}
71+
OS_NAME=${{ matrix.os }}
72+
case "$OS_NAME" in
73+
ubuntu-latest) SAFE_OS_NAME="linux" ;;
74+
windows-latest) SAFE_OS_NAME="windows" ;;
75+
macos-latest) SAFE_OS_NAME="macos" ;;
76+
*) SAFE_OS_NAME="$OS_NAME" ;;
77+
esac
78+
ZIP_NAME="jfiletreeprettyprinter-${VERSION}-${SAFE_OS_NAME}.zip"
79+
echo "Zip to create: $ZIP_NAME"
80+
81+
cd dist
82+
if [[ "$SAFE_OS_NAME" == "windows" ]]; then
83+
powershell Compress-Archive -Path * -DestinationPath "$ZIP_NAME"
84+
else
85+
tar -a -c -f "$ZIP_NAME" *
86+
fi
87+
echo "zip_path=dist/$ZIP_NAME" >> $GITHUB_OUTPUT
88+
cd ..
89+
90+
- name: Upload artifact
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: release-zips-${{ matrix.os }}
94+
path: ${{ steps.zip_exe.outputs.zip_path }}
95+
96+
release:
97+
name: Create GitHub Release
98+
runs-on: ubuntu-latest
99+
needs: build-native
100+
permissions:
101+
contents: write
102+
103+
steps:
104+
- name: Checkout repository
105+
uses: actions/checkout@v4
106+
107+
- name: Download build artifacts
108+
uses: actions/download-artifact@v4
109+
with:
110+
path: release_zips
111+
112+
- name: Extract changelog for current version
113+
id: changelog
114+
shell: bash
115+
run: |
116+
TAG="${GITHUB_REF_NAME#v}" # Remove leading "v" (e.g. vX.Y.Z → X.Y.Z)
117+
echo "Extracting changelog for version $TAG"
118+
119+
# Extract section for this version up to the next version header
120+
awk "/## \\[$TAG\\]/,/^---/" CHANGELOG.md > release_notes.tmp
121+
122+
# Clean up formatting (remove trailing ---)
123+
sed -i '/^---/d' release_notes.tmp
124+
125+
# Verify
126+
echo "==== Extracted release notes ===="
127+
cat release_notes.tmp
128+
echo "================================"
129+
130+
echo "body_path=release_notes.tmp" >> $GITHUB_OUTPUT
131+
132+
- name: Create GitHub Release
133+
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090
134+
with:
135+
name: "JFileTreePrettyPrinter ${{ github.ref_name }}"
136+
body_path: ${{ steps.changelog.outputs.body_path }}
137+
files: release_zips/**/*.zip
138+
draft: true
139+
prerelease: false
140+
env:
141+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml renamed to .github/workflows/publish-maven-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
5151
- name: Update pom.xml to release version
5252
run: |
53-
mvn versions:set -DnewVersion=${{ env.RELEASE_VERSION }} -B -q
53+
mvn versions:set-property -Dproperty=revision -DnewVersion=${{ env.RELEASE_VERSION }} -B -q
5454
git commit -am "Set version to ${{ env.RELEASE_VERSION }}" || echo "No changes"
5555
git push origin HEAD:main
5656
env:
@@ -60,7 +60,7 @@ jobs:
6060
run: mvn clean verify -B
6161

6262
- name: Publish RELEASE to Maven Central
63-
run: mvn deploy -P release -B -DskipTests
63+
run: mvn deploy -pl jfiletreeprettyprinter-core -P release -B -DskipTests
6464
env:
6565
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
6666
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
@@ -73,6 +73,6 @@ jobs:
7373
NEXT_PATCH=$((PATCH+1))
7474
NEXT_VERSION="$MAJOR.$MINOR.$NEXT_PATCH-SNAPSHOT"
7575
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV
76-
mvn versions:set -DnewVersion=$NEXT_VERSION -B -q
76+
mvn versions:set-property -Dproperty=revision -DnewVersion=$NEXT_VERSION -B -q
7777
git commit -am "Set version to $NEXT_VERSION" || echo "No changes"
7878
git push origin HEAD:main

.github/workflows/snapshot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

3838
- name: Publish SNAPSHOT to Maven Central
3939
run: |
40-
mvn -P release --batch-mode deploy -am -DskipTests
40+
mvn -pl jfiletreeprettyprinter-core -P release --batch-mode deploy -am -DskipTests
4141
env:
4242
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
4343
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}

.github/workflows/sonarcloud.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,6 @@ jobs:
4444
- name: Build and analyze
4545
env:
4646
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
47-
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.host.url="https://sonarcloud.io" -Dsonar.organization=computerdaddyguy -Dsonar.projectKey=ComputerDaddyGuy_JFileTreePrettyPrinter
47+
run: |
48+
mvn clean install
49+
mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ target/failsafe-reports/
6161
.github/workflows/cache/
6262

6363
# Specific
64-
!/src/example/resources/emojis/**
64+
.flattened-pom.xml
65+
!**/src/*/resources/emojis/**

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
---
9+
## [0.2.0] - 2025-11-12 - Native executable
10+
11+
> [!IMPORTANT]
12+
> Maven artifactId of Java lib changed from `jfiletreeprettyprinter` to `jfiletreeprettyprinter-core`
13+
14+
### Added
15+
- Run JFileTreePrettyPrinter in command line, using native executable on Windows, Linux, MacOS (see Github release attachments):
16+
`$ jfiletreeprettyprinter myFolder`
17+
- Scanning and rendering options in external file:
18+
`$ jfiletreeprettyprinter myFolder --options myOptions.json`
19+
20+
### Changed
21+
- Split code into 3 sub-modules: cli, core and examples
22+
23+
---
24+
## [0.1.1] - 2025-11-08 - Native executable (POC)
25+
26+
> [!CAUTION]
27+
> Do not use this version (was for proof of concept only).
28+
829
---
930
## [0.1.0] - 2025-10-13 - First beta release
1031

0 commit comments

Comments
 (0)