Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Commit

Permalink
actions: build native images (#112)
Browse files Browse the repository at this point in the history
* actions: build native images

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
  • Loading branch information
miurahr authored Feb 13, 2022
1 parent dffacba commit 529a4c9
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 3 deletions.
37 changes: 34 additions & 3 deletions .github/workflows/build-release-and-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
distribution: 'temurin'
java-version: '11'
- uses: kiancross/checkstyle-annotations-action@v1
- uses: eskatos/gradle-command-action@v2
- uses: gradle/gradle-build-action@v2
with:
arguments: build
- name: Upload artifact
Expand All @@ -23,10 +23,41 @@ jobs:
name: release-files
path: build/distributions/

nativeImage:
name: ${{ matrix.version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
version: ['22.0.0.2']
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: install dependencies
run: |
sudo apt update
sudo apt install -y upx-ucl libxi-dev libxt-dev libgles-dev libgl-dev
- uses: graalvm/setup-graalvm@v1
with:
version: ${{ matrix.version }}
java-version: '11'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: gradle/gradle-build-action@v2
- name: Build native image
run: |
./gradlew nativeImage
upx build/bin/ebviewer
./gradlew zipExecutable
- name: Upload java dist asset
uses: actions/upload-artifact@v2
with:
name: release-files
path: build/distributions/

release:
name: publish to github release
runs-on: ubuntu-latest
needs: [build]
needs: [build, nativeImage]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: checkout code
Expand All @@ -35,7 +66,7 @@ jobs:
id: get_version
run: |
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}
- name: Download artifact
- name: Download distributions artifact
uses: actions/download-artifact@v2
with:
name: release-files
Expand Down
25 changes: 25 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import java.io.File
import java.io.FileInputStream
import java.util.Properties
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform

plugins {
groovy
Expand Down Expand Up @@ -186,3 +187,27 @@ distributions {
}
}
}

// generate native command distribution zip file for each supported platform.
tasks.register<Zip>("zipExecutable") {
dependsOn(tasks.nativeImage)

// distribution contents
from("$buildDir/bin")
from("README.md")
from("COPYING")

// output zip file path and name
destinationDirectory.set(file("$buildDir/distributions"))
val osname = DefaultNativePlatform.getCurrentOperatingSystem().name
val archname = DefaultNativePlatform.getCurrentArchitecture().name
if (osname.startsWith("Windows")) {
archiveFileName.set("ebviewer-win32-${archname}-${project.version}.zip")
} else if (osname.startsWith("Mac")) {
archiveFileName.set("ebviewer-mac-${archname}-${project.version}.zip")
} else if (osname.startsWith("Linux")) {
archiveFileName.set("ebviewer-linux-${archname}-${project.version}.zip")
} else {
archiveFileName.set("ebviewer-other-${archname}-${project.version}.zip")
}
}

0 comments on commit 529a4c9

Please sign in to comment.