Skip to content

Commit 613dd63

Browse files
Native image
1 parent bdf55ad commit 613dd63

File tree

6 files changed

+192
-0
lines changed

6 files changed

+192
-0
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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+
build-native:
10+
name: Build on ${{ matrix.os }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [windows-latest, ubuntu-latest, macos-latest]
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up GraalVM
21+
uses: graalvm/setup-graalvm@v1
22+
with:
23+
java-version: "21"
24+
distribution: "graalvm"
25+
components: "native-image"
26+
27+
- name: Build native image
28+
run: mvn -B clean package -Pnative
29+
30+
- name: Locate built executable
31+
id: find_exe
32+
shell: bash
33+
run: |
34+
mkdir dist
35+
BIN_PATH=$(find target -type f \( -name "*.exe" -o -perm -111 \) | head -n 1)
36+
echo "Found binary: $BIN_PATH"
37+
cp "$BIN_PATH" dist/
38+
echo "bin_path=$BIN_PATH" >> $GITHUB_OUTPUT
39+
40+
- name: Zip executable
41+
id: zip_exe
42+
shell: bash
43+
run: |
44+
VERSION=${GITHUB_REF_NAME}
45+
OS_NAME=${{ matrix.os }}
46+
SAFE_OS_NAME=$(echo "$OS_NAME" | sed 's/-latest//')
47+
ZIP_NAME="jfiletreeprettyprinter-${VERSION}-${SAFE_OS_NAME}.zip"
48+
49+
cd dist
50+
zip "$ZIP_NAME" * > /dev/null
51+
echo "zip_path=$(pwd)/$ZIP_NAME" >> $GITHUB_OUTPUT
52+
cd ..
53+
54+
- name: Upload artifact
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: release-zips-${{ matrix.os }}
58+
path: ${{ steps.zip_exe.outputs.zip_path }}
59+
60+
release:
61+
name: Create GitHub Release
62+
runs-on: ubuntu-latest
63+
needs: build-native
64+
permissions:
65+
contents: write
66+
67+
steps:
68+
- name: Checkout repository
69+
uses: actions/checkout@v4
70+
71+
- name: Download build artifacts
72+
uses: actions/download-artifact@v4
73+
with:
74+
path: release_zips
75+
76+
- name: Extract changelog for current version
77+
id: changelog
78+
shell: bash
79+
run: |
80+
TAG="${GITHUB_REF_NAME#v}" # Remove leading "v" (e.g. vX.Y.Z → X.Y.Z)
81+
echo "Extracting changelog for version $TAG"
82+
83+
# Extract section for this version up to the next version header
84+
awk "/## \\[$TAG\\]/,/^---/" CHANGELOG.md > release_notes.tmp
85+
86+
# Clean up formatting (remove trailing ---)
87+
sed -i '/^---/d' release_notes.tmp
88+
89+
# Verify
90+
echo "==== Extracted release notes ===="
91+
cat release_notes.tmp
92+
echo "================================"
93+
94+
echo "body_path=release_notes.tmp" >> $GITHUB_OUTPUT
95+
96+
- name: Create GitHub Release
97+
uses: softprops/action-gh-release@v2
98+
with:
99+
name: "JFileTreePrettyPrinter v${{ github.ref_name }}"
100+
body_path: ${{ steps.changelog.outputs.body_path }}
101+
files: release_zips/**/*.zip
102+
draft: true
103+
prerelease: false
104+
env:
105+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
File renamed without changes.

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ 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.1.1] - 2025-10-17 - Native executable
10+
11+
### Added
12+
- Work in progress: run JFileTreePrettyPrinter using command line /!\ not yet fully functional /!\
13+
- Native executable attachment to the Github release
14+
815
---
916
## [0.1.0] - 2025-10-13 - First beta release
1017

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# How to build a native executable locally
2+
3+
## Windows
4+
1. Install `GraalVM`: https://www.graalvm.org/downloads/
5+
1. Configure environment variable:
6+
```
7+
GRAALVM_HOME=<graalvm home>
8+
GRAALVM_PATH=%GRAALVM_HOME%\bin
9+
```
10+
1. Install `Visual Studio Code`: https://visualstudio.microsoft.com/fr/downloads/
11+
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
12+
1. Configure Maven plugin: https://graalvm.github.io/native-build-tools/latest/end-to-end-maven-guide.html#add-plugin
13+
1. Use `native` profile
14+
1. Set `native.maven.plugin.version` property to latest version from https://mvnrepository.com/artifact/org.graalvm.buildtools/native-maven-plugin
15+
1. Set appropriate main class
16+
1. From the project root, run `mvn -Pnative package`
17+
1. After a few seconds, `jfiletreeprettyprinter.exe` has been generated inside `target/` folder
18+
19+
### UTF-8 console
20+
If printed tree format looks like `Ôöé` instead of `├─`, then your console is likely not configured to UTF-8 encoding.
21+
To configure your console to UTF-8 code page, run:
22+
```
23+
chcp 65001
24+
```
25+
More info on [chcp Windows command](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chcp).
26+
27+
## Linux
28+
No doc for now.
29+
30+
## MacOS
31+
No doc for now.

pom.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
5656
<maven-javadoc-plugin.version>3.11.2</maven-javadoc-plugin.version>
5757
<maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>
58+
<native.maven.plugin.version>0.11.1</native.maven.plugin.version>
5859

5960
</properties>
6061

@@ -290,6 +291,33 @@
290291
</plugins>
291292
</build>
292293
</profile>
294+
295+
<profile>
296+
<id>native</id>
297+
<build>
298+
<plugins>
299+
<plugin>
300+
<groupId>org.graalvm.buildtools</groupId>
301+
<artifactId>native-maven-plugin</artifactId>
302+
<version>${native.maven.plugin.version}</version>
303+
<extensions>true</extensions>
304+
<executions>
305+
<execution>
306+
<id>build-native</id>
307+
<goals>
308+
<goal>compile-no-fork</goal>
309+
</goals>
310+
<phase>package</phase>
311+
</execution>
312+
</executions>
313+
<configuration>
314+
<mainClass>io.github.computerdaddyguy.jfiletreeprettyprinter.cli.FileTreePrettyPrinterCommandLine</mainClass>
315+
</configuration>
316+
</plugin>
317+
</plugins>
318+
</build>
319+
</profile>
320+
293321
</profiles>
294322

295323

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package io.github.computerdaddyguy.jfiletreeprettyprinter.cli;
2+
3+
import io.github.computerdaddyguy.jfiletreeprettyprinter.FileTreePrettyPrinter;
4+
5+
public class FileTreePrettyPrinterCommandLine {
6+
7+
public static void main(String[] args) {
8+
String path = ".";
9+
if (args != null && args.length > 0) {
10+
path = args[0];
11+
}
12+
try {
13+
var printer = FileTreePrettyPrinter.createDefault();
14+
var result = printer.prettyPrint(path);
15+
System.out.println(result);
16+
} catch (Exception e) {
17+
System.err.print("Error while pretty printing: " + e.getMessage());
18+
}
19+
}
20+
21+
}

0 commit comments

Comments
 (0)