Skip to content

Commit

Permalink
Add UPX to pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
ghokun committed Feb 13, 2023
1 parent c3510aa commit 821e4b1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ jobs:
- name: 'Native test'
run: ./gradlew nativeTest

- name: 'Native compile and generate package'
run: ./gradlew generatePackage
- name: 'Native compile'
run: ./gradlew nativeCompile
17 changes: 16 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
fail-fast: true
matrix:
os: [ ubuntu-latest, macOS-latest, windows-latest, macOS-arm64, linux-arm64 ]
include:
- os: windows-latest
suffix: .exe
steps:
- name: 'Check out repository'
uses: actions/checkout@v3
Expand All @@ -39,7 +42,19 @@ jobs:
- name: 'Check'
run: ./gradlew check -Pversion='${{ github.event.inputs.version }}'

- name: 'Build native executable and compress'
- name: 'Build native executable'
run: ./gradlew nativeCompile -Pversion='${{ github.event.inputs.version }}'

- name: 'Compress with UPX'
if: ${{ runner.os == 'Windows' || runner.os == 'Linux' }}
uses: crazy-max/ghaction-upx@v2
with:
version: latest
files: |
./build/native/nativeCompile/convert${{ matrix.suffix }}
args: --best

- name: 'Generate package'
run: ./gradlew generatePackage -Pversion='${{ github.event.inputs.version }}'

- name: 'Upload build artifact'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ sdk env
./gradlew -Pagent nativeTest

# Generate a distributable package with VERSION
./gradlew -Pversion=${VERSION} generatePackage
./gradlew -Pversion=${VERSION} nativeCompile generatePackage
```

## TODO list
Expand All @@ -146,5 +146,5 @@ sdk env
- [ ] Read data from `STDIN`
- [ ] Handle huge files
- [ ] Handle partial inputs (streaming json logs ?)
- [ ] Minify binary with UPX on supported platforms
- [x] Minify binary with UPX on supported platforms
- [ ] Have fun
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {
id "com.diffplug.spotless" version "${spotlessVersion}"
id "net.ltgt.errorprone" version "${errorPronePluginVersion}"
id "org.graalvm.buildtools.native" version "${graalvmBuildtoolsVersion}"
id "org.jetbrains.gradle.upx" version "${upxVersion}"
}

group = "dev.gokhun"
Expand Down Expand Up @@ -74,7 +73,7 @@ def archiveName = "${project.name}-${project.version}-${osName}-${arch == 'amd64

tasks.register("copyBinaries", Copy) {
group = taskGroup
dependsOn("nativeCompile")
mustRunAfter("nativeCompile")

def binDir = file("${buildDir}/native/${archiveName}/bin/")
binDir.parentFile.mkdirs()
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ spotlessVersion=6.15.0
errorPronePluginVersion=3.0.1
graalvmBuildtoolsVersion=0.9.19
testLoggerVersion=3.2.0
upxVersion=1.5.2

# dependencies
guavaVersion=31.1-jre
Expand Down

0 comments on commit 821e4b1

Please sign in to comment.