Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
613dd63
Native image
ComputerDaddyGuy Oct 17, 2025
676ea25
Merge branch 'develop' into feature/cli
ComputerDaddyGuy Oct 17, 2025
a61c7c9
Use tar instead of zip
ComputerDaddyGuy Oct 17, 2025
af2a6cb
Fix native executable github action
ComputerDaddyGuy Oct 17, 2025
3e99f29
Fix zip for Windows
ComputerDaddyGuy Oct 17, 2025
6b4a85a
Fix MacOS native build + doc
ComputerDaddyGuy Oct 17, 2025
bbf493e
Fix MacOS native build
ComputerDaddyGuy Oct 17, 2025
552e720
Fix Windows native build
ComputerDaddyGuy Oct 17, 2025
9e99471
Fix Windows native build
ComputerDaddyGuy Oct 17, 2025
11441eb
Fix Windows native build
ComputerDaddyGuy Oct 17, 2025
cfcc647
Run release only on main branch
ComputerDaddyGuy Oct 17, 2025
7162c3b
Fix control
ComputerDaddyGuy Oct 17, 2025
4cbdec6
Fix control
ComputerDaddyGuy Oct 17, 2025
3e5e0b6
Fix control
ComputerDaddyGuy Oct 17, 2025
7f0cd4d
Update doc
ComputerDaddyGuy Oct 17, 2025
3371861
CLI: Work in progress
ComputerDaddyGuy Oct 19, 2025
b193b5d
CLI: Work in progress
ComputerDaddyGuy Oct 21, 2025
152f1a5
Fix Sonar
ComputerDaddyGuy Oct 29, 2025
a0d46fc
Fix Sonar
ComputerDaddyGuy Oct 29, 2025
4e8610d
Map external child limit
ComputerDaddyGuy Oct 29, 2025
23cf113
Work in progress
ComputerDaddyGuy Nov 4, 2025
5f05047
Refactor & tests
ComputerDaddyGuy Nov 6, 2025
b63e1fb
More CLI external features
ComputerDaddyGuy Nov 7, 2025
ad033a2
Fix Sonar
ComputerDaddyGuy Nov 7, 2025
64813e0
Fix Sonar
ComputerDaddyGuy Nov 7, 2025
f77bbf0
Exclude java tests from sonar
ComputerDaddyGuy Nov 8, 2025
8609ad1
Exclude java tests from sonar
ComputerDaddyGuy Nov 8, 2025
3ed83d3
Split + mvn test OK
ComputerDaddyGuy Nov 8, 2025
9d3216c
mvn native compilation ok
ComputerDaddyGuy Nov 8, 2025
73034c0
Renamed "examples" module + project structure picture update
ComputerDaddyGuy Nov 8, 2025
1711c39
Fix GH actions for multi-module
ComputerDaddyGuy Nov 8, 2025
87dc5de
Adapt pom.xml for maven central
ComputerDaddyGuy Nov 8, 2025
d48c1d9
Update readme resource urls
ComputerDaddyGuy Nov 8, 2025
ec6fb64
GH: testing actions
ComputerDaddyGuy Nov 8, 2025
97f7924
Prepare for v0.1.1
ComputerDaddyGuy Nov 8, 2025
497c54a
Prepare for v0.1.1
ComputerDaddyGuy Nov 8, 2025
a85a421
Fix Maven release GH action
ComputerDaddyGuy Nov 8, 2025
c9b2266
Re-adapt sonar test exclusions
ComputerDaddyGuy Nov 8, 2025
dda07c0
Re-adapt sonar test exclusions
ComputerDaddyGuy Nov 8, 2025
1fa222f
Re-adapt sonar test exclusions
ComputerDaddyGuy Nov 8, 2025
e3539e4
Re-adapt sonar test exclusions
ComputerDaddyGuy Nov 8, 2025
9a17f8d
Re-adapt sonar test exclusions
ComputerDaddyGuy Nov 8, 2025
a48f4a8
Re-adapt sonar test exclusions
ComputerDaddyGuy Nov 8, 2025
1bdd56f
Re-adapt sonar test exclusions
ComputerDaddyGuy Nov 8, 2025
ccda21b
Re-adapt sonar test exclusions
ComputerDaddyGuy Nov 8, 2025
a43e0a6
Re-adapt sonar test exclusions
ComputerDaddyGuy Nov 8, 2025
3231372
Re-adapt sonar test exclusions
ComputerDaddyGuy Nov 8, 2025
c4e2edd
flatten maven plugin only when release
ComputerDaddyGuy Nov 8, 2025
c6c9490
Re-adapt sonar test exclusions
ComputerDaddyGuy Nov 8, 2025
fa85310
Re-adapt sonar test exclusions
ComputerDaddyGuy Nov 8, 2025
e7c5730
Re-adapt sonar test exclusions
ComputerDaddyGuy Nov 8, 2025
4df1aab
Re-adapt sonar test exclusions
ComputerDaddyGuy Nov 8, 2025
102e7a6
Rework unit tests
ComputerDaddyGuy Nov 10, 2025
8642174
Fix Sonar issue
ComputerDaddyGuy Nov 10, 2025
50fbd32
Fix Sonar issue
ComputerDaddyGuy Nov 10, 2025
29a7d33
Sonar config
ComputerDaddyGuy Nov 10, 2025
5706858
Fix Sonar issue
ComputerDaddyGuy Nov 10, 2025
b1a6c48
Docs
ComputerDaddyGuy Nov 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions .github/workflows/create-github-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Create Github release

on:
push:
tags:
- "v*.*.*" # triggers on tags like vX.Y.Z

jobs:

run-only-on-main-branch:
name: Verify main branch
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Check if tag is on main
run: |
git fetch origin main
if git merge-base --is-ancestor $GITHUB_SHA origin/main; then
echo "Tag is on main"
else
echo "Tag is NOT on main, skipping"
exit 1
fi

build-native:
Comment on lines +11 to +28

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 months ago

The fix is to explicitly add a permissions block for the run-only-on-main-branch job, constraining it to the minimum required privilege. Since this job only checks the ancestry of a tag (via git), it does not require write access—just read access to the repository contents. Therefore, you should add permissions: contents: read to the run-only-on-main-branch job (under jobs: run-only-on-main-branch: and above steps:). No other changes are required. Repeat this pattern for any other similar jobs lacking permission specification, but in this snippet, only the flagged job needs to be changed.


Suggested changeset 1
.github/workflows/create-github-release.yaml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/create-github-release.yaml b/.github/workflows/create-github-release.yaml
--- a/.github/workflows/create-github-release.yaml
+++ b/.github/workflows/create-github-release.yaml
@@ -10,6 +10,8 @@
   run-only-on-main-branch:
     name: Verify main branch
     runs-on: ubuntu-latest
+    permissions:
+      contents: read
 
     steps:
       - name: Checkout repository
EOF
@@ -10,6 +10,8 @@
run-only-on-main-branch:
name: Verify main branch
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout repository
Copilot is powered by AI and may make mistakes. Always verify output.
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: run-only-on-main-branch
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: "21"
distribution: "graalvm"

- name: Build native image
run: mvn -B clean package -Pnative

- name: Locate built executable
id: find_exe
shell: bash
run: |
mkdir dist

OS_NAME=${{ matrix.os }}
if [[ "$OS_NAME" == "windows-latest" ]]; then
BIN_PATH=$(find target -type f -name "jfiletreeprettyprinter.exe")
else
BIN_PATH=$(find target -type f -name "jfiletreeprettyprinter")
fi

echo "Found binary: $BIN_PATH"
cp "$BIN_PATH" dist/
echo "bin_path=$BIN_PATH" >> $GITHUB_OUTPUT

- name: Zip executable
id: zip_exe
shell: bash
run: |
VERSION=${GITHUB_REF_NAME}
OS_NAME=${{ matrix.os }}
case "$OS_NAME" in
ubuntu-latest) SAFE_OS_NAME="linux" ;;
windows-latest) SAFE_OS_NAME="windows" ;;
macos-latest) SAFE_OS_NAME="macos" ;;
*) SAFE_OS_NAME="$OS_NAME" ;;
esac
ZIP_NAME="jfiletreeprettyprinter-${VERSION}-${SAFE_OS_NAME}.zip"
echo "Zip to create: $ZIP_NAME"

cd dist
if [[ "$SAFE_OS_NAME" == "windows" ]]; then
powershell Compress-Archive -Path * -DestinationPath "$ZIP_NAME"
else
tar -a -c -f "$ZIP_NAME" *
fi
echo "zip_path=dist/$ZIP_NAME" >> $GITHUB_OUTPUT
cd ..

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: release-zips-${{ matrix.os }}
path: ${{ steps.zip_exe.outputs.zip_path }}

release:
Comment on lines +29 to +96

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 months ago

The best and most secure way to resolve this problem is to add a permissions: block to the build-native job in the workflow YAML file at .github/workflows/create-github-release.yaml. Since the build-native job only performs code checkout, builds code, and uploads artifacts (but does not push code, manage releases, or require administrative privileges), the minimal contents: read permission is appropriate here. This limits the token permissions and aligns with GitHub's least privilege recommendations. No functional change or additional methods/imports are required—simply add:

permissions:
  contents: read

under the build-native: job, at the same indentation level as name: ..., runs-on: ..., and strategy:.

Suggested changeset 1
.github/workflows/create-github-release.yaml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/create-github-release.yaml b/.github/workflows/create-github-release.yaml
--- a/.github/workflows/create-github-release.yaml
+++ b/.github/workflows/create-github-release.yaml
@@ -29,6 +29,8 @@
     name: Build on ${{ matrix.os }}
     runs-on: ${{ matrix.os }}
     needs: run-only-on-main-branch
+    permissions:
+      contents: read
     strategy:
       matrix:
         os: [windows-latest, ubuntu-latest, macos-latest]
EOF
@@ -29,6 +29,8 @@
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: run-only-on-main-branch
permissions:
contents: read
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
Copilot is powered by AI and may make mistakes. Always verify output.
name: Create GitHub Release
runs-on: ubuntu-latest
needs: build-native
permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: release_zips

- name: Extract changelog for current version
id: changelog
shell: bash
run: |
TAG="${GITHUB_REF_NAME#v}" # Remove leading "v" (e.g. vX.Y.Z → X.Y.Z)
echo "Extracting changelog for version $TAG"

# Extract section for this version up to the next version header
awk "/## \\[$TAG\\]/,/^---/" CHANGELOG.md > release_notes.tmp

# Clean up formatting (remove trailing ---)
sed -i '/^---/d' release_notes.tmp

# Verify
echo "==== Extracted release notes ===="
cat release_notes.tmp
echo "================================"

echo "body_path=release_notes.tmp" >> $GITHUB_OUTPUT

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: "JFileTreePrettyPrinter ${{ github.ref_name }}"
body_path: ${{ steps.changelog.outputs.body_path }}
files: release_zips/**/*.zip
draft: true
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

---
## [0.1.1] - 2025-10-17 - Native executable

### Added
- Work in progress: run JFileTreePrettyPrinter using command line /!\ not yet fully functional /!\
- Native executable attachment to the Github release

---
## [0.1.0] - 2025-10-13 - First beta release

Expand Down
8 changes: 4 additions & 4 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
- [x] SonarCloud integration
- [x] **Workflows & lifecycle**
- [x] Github actions
- [x] Publish `0.0.x` alpha on Maven Central!
- [x] Publish `0.x.0` beta on Maven Central!
- [x] Publish `0.0.x` **alpha** on Maven Central!
- [x] Publish `0.x.0` **beta** on Maven Central!

## To do
- [ ] Gather feedback
- [ ] Use as command line (options as arguments of provided in external file)
- [x] Executable file distributed with release files in Github

## Backlog / To analyze / To implement if requested
- [ ] Export options to/import options from external file
- [ ] Executable file distributed with release files in Github
- [ ] Rework/fix Github wiki to be up to date
- [ ] Refactor unit tests (custom assert?)
- [ ] Option: Follow symlink
Expand Down
31 changes: 31 additions & 0 deletions docs/How-to-build-a-native-executable-locally.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# How to build a native executable locally

## Windows
1. Install `GraalVM`: https://www.graalvm.org/downloads/
1. Configure environment variable:
```
GRAALVM_HOME=<graalvm home>
GRAALVM_PATH=%GRAALVM_HOME%\bin
```
1. Install `Visual Studio Code`: https://visualstudio.microsoft.com/fr/downloads/
1. IMPORTANT: Be sure to install `Desktop development with C++` to avoid `Failed to find a suitable version of Visual Studio with 'vswhere.exe'` error
1. Configure Maven plugin: https://graalvm.github.io/native-build-tools/latest/end-to-end-maven-guide.html#add-plugin
1. Use `native` profile
1. Set `native.maven.plugin.version` property to latest version from https://mvnrepository.com/artifact/org.graalvm.buildtools/native-maven-plugin
1. Set appropriate main class
1. From the project root, run `mvn -Pnative package`
1. After a few seconds, `jfiletreeprettyprinter.exe` has been generated inside `target/` folder

### UTF-8 console
If printed tree format looks like `Ôöé` instead of `├─`, then your console is likely not configured to UTF-8 encoding.
To configure your console to UTF-8 code page, run:
```
chcp 65001
```
More info on [chcp Windows command](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chcp).

## Linux
No doc for now.

## MacOS
No doc for now.
17 changes: 11 additions & 6 deletions release_process.md → docs/Release-process.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# JFileTreePrettyPrinter release flow
# JFileTreePrettyPrinter release process

- **In `develop` branch:**
- Run tests
Expand All @@ -10,17 +10,22 @@
- **In `main` branch:**
- Set project version in `pom.xml` to `X.Y.Z` (remove the `-SNAPSHOT`)
- Update `README.md` (with new `X.Y.Z` dependency version)
- Update `CHANGELOG.md` with changes
- Update `CHANGELOG.md` with changes **!IMPORTANT: Respect format!**
- Update `ROADMAP.md` if necessary
- Update `SECURITY.md` if necessary
- Commit locally
- Tag with appropriate `vX.Y.Z`
- Push code & tags
- Push code & tag

- **In Github:**
- Create new release based on `vX.Y.Z` tag: copy content of `CHANGELOG.md` for this version
- Github `release` workflow will run automatically
- Few minutes later, artifact is available on Maven Central 🎉
- Action `create-github-release` triggers automatically on tag push `vX.Y.Z` on `main` branch
- Builds native executables for Linux/Windows/MacOS
- Creates a **draft** Github release with:
- Executables as attached zipped files
- Appropriate section of `CHANGELOG.md` for this version
- Review the Github release and **publish it manually**
- Github `publish-maven-release` workflow will run automatically
- Few minutes later, artifact is available on Maven Central 🎉
- Update wiki if required

- **Merge `main` back into `develop` branch**
Expand Down
48 changes: 48 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- Dependencies versions -->
<jackson.version>3.0.0</jackson.version>
<hibernate-validator.version>9.0.1.Final</hibernate-validator.version>
<picocli.version>4.7.7</picocli.version>
<jspecify.version>1.0.0</jspecify.version>
<junit.version>5.13.4</junit.version>
<assertj.version>3.27.4</assertj.version>
Expand All @@ -55,10 +58,27 @@
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
<maven-javadoc-plugin.version>3.11.2</maven-javadoc-plugin.version>
<maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>
<native.maven.plugin.version>0.11.1</native.maven.plugin.version>

</properties>


<dependencies>
<dependency>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate-validator.version}</version>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>${picocli.version}</version>
</dependency>
<dependency>
<groupId>org.jspecify</groupId>
<artifactId>jspecify</artifactId>
Expand Down Expand Up @@ -133,6 +153,7 @@
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>

Expand Down Expand Up @@ -290,6 +311,33 @@
</plugins>
</build>
</profile>

<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>${native.maven.plugin.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<mainClass>io.github.computerdaddyguy.jfiletreeprettyprinter.cli.FileTreePrettyPrinterCommandLine</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</profile>

</profiles>


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.github.computerdaddyguy.jfiletreeprettyprinter.cli;

import picocli.CommandLine;

public class FileTreePrettyPrinterCommandLine {

public static void main(String[] args) {
int exitCode = new CommandLine(new PrettyPrintCommand()).execute(args);
System.exit(exitCode);
}

}
Loading
Loading