Skip to content

Commit

Permalink
Update to support native builds
Browse files Browse the repository at this point in the history
  • Loading branch information
EdgewareRoad committed Jun 19, 2024
1 parent 3640131 commit 37f4134
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 18 deletions.
90 changes: 72 additions & 18 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ jobs:
steps:
- uses: actions/[email protected]
- name: Set up JDK 21
uses: actions/setup-java@v4.2.1
uses: actions/setup-graalvm@v1.2.2
with:
java-version: 21
distribution: corretto
java-version: '21'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Read/Write Properties File
uses: kurt-code/[email protected]
id: read-properties
Expand All @@ -25,22 +26,75 @@ jobs:
run: |
echo "version: ${{ steps.read-properties.outputs.trivysummary_version }}"
echo "github.ref: ${{ github.ref }}"
- name: Build with Gradle
- name: Build and Test with Gradle
run: gradle test --warning-mode all
- name: Create distributable ZIP file with Gradle
run: gradle distZip --warning-mode all
publish:
build-native:
needs: build-java
name: Build TrivySummary natively on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
include:
- os: ubuntu-latest
executable: 'trivysummary'
output-variant: 'linux-amd64'
output-suffix: ''
- os: macos-latest
executable: 'trivysummary'
output-name: 'macos-amd64'
output-suffix: ''
- os: windows-latest
executable: 'trivysummary.exe'
output-name: 'windows-amd64'
output-suffix: '.exe'
steps:
- uses: actions/[email protected]
- name: Set up JDK 21
uses: actions/[email protected]
with:
java-version: '21'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'
- name: Read/Write Properties File
uses: kurt-code/[email protected]
id: read-properties
with:
operation: 'read'
file-path: 'src/main/resources/application.properties'
keys: 'trivysummary.version'
- name: Build natively with Gradle
run: gradle nativeCompile
- name: Copy native executable to output name
run: copy build/native/nativeCompile/${{ matrix.executable }} build/distributions/trivysummary-${{ matrix.output-variant }}-${{ steps.read-properties.outputs.trivysummary_version }}${{ matrix.output-suffix }}
publish:
needs: build-native
runs-on: ubuntu-latest
steps:
- name: Publish with Gradle
if: endsWith(steps.read-properties.outputs.trivysummary_version, '-SNAPSHOT') || (startsWith(github.ref, 'refs/tags/') && endsWith(github.ref, steps.read-properties.outputs.trivysummary_version))
run: gradle publish -Pmvnpub.user="${{ secrets.MAVENREPO_USER }}" -Pmvnpub.key="${{ secrets.MAVENREPO_TOKEN }}" --warning-mode all
- name: "Create Release"
id: create_release
uses: softprops/[email protected]
if: startsWith(github.ref, 'refs/tags/') && endsWith(github.ref, steps.read-properties.outputs.trivysummary_version)
with:
tag_name: ${{ steps.read-properties.outputs.trivysummary_version }}
name: Release ${{ steps.read-properties.outputs.trivysummary_version }}
body_path: CHANGELOG.txt
token: ${{ secrets.MAVENREPO_TOKEN }}
files: build/distributions/trivysummary-${{ steps.read-properties.outputs.trivysummary_version }}.zip
- name: Read/Write Properties File
uses: kurt-code/[email protected]
id: read-properties
with:
operation: 'read'
file-path: 'src/main/resources/application.properties'
keys: 'trivysummary.version'
- name: Publish with Gradle
if: endsWith(steps.read-properties.outputs.trivysummary_version, '-SNAPSHOT') || (startsWith(github.ref, 'refs/tags/') && endsWith(github.ref, steps.read-properties.outputs.trivysummary_version))
run: gradle publish -Pmvnpub.user="${{ secrets.MAVENREPO_USER }}" -Pmvnpub.key="${{ secrets.MAVENREPO_TOKEN }}" --warning-mode all
- name: "Create Release"
id: create_release
uses: softprops/[email protected]
if: startsWith(github.ref, 'refs/tags/') && endsWith(github.ref, steps.read-properties.outputs.trivysummary_version)
with:
tag_name: ${{ steps.read-properties.outputs.trivysummary_version }}
name: Release ${{ steps.read-properties.outputs.trivysummary_version }}
body_path: CHANGELOG.txt
token: ${{ secrets.MAVENREPO_TOKEN }}
files: |
build/distributions/trivysummary-${{ steps.read-properties.outputs.trivysummary_version }}.zip
build/distributions/trivysummary-windows-amd64-${{ steps.read-properties.outputs.trivysummary_version }}.exe
build/distributions/trivysummary-linux-amd64-${{ steps.read-properties.outputs.trivysummary_version }}
build/distributions/trivysummary-macos-amd64-${{ steps.read-properties.outputs.trivysummary_version }}
17 changes: 17 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id 'org.springframework.boot' version '3.2.5'
id 'io.spring.dependency-management' version '1.1.5'
id 'maven-publish'
id 'org.graalvm.buildtools.native' version '0.10.2'
}

group = 'com.fujitsu.edgewareroad'
Expand Down Expand Up @@ -102,6 +103,22 @@ testing {
}
}

graalvmNative {
binaries {
main {
imageName = 'trivysummary'
mainClass = 'com.fujitsu.edgewareroad.trivysummary.TrivySummaryApp'
buildArgs.add("-O4")
}
test {
buildArgs.add("-O0")
}
}
binaries.all {
buildArgs.add("--verbose")
}
}

// Publishing the output to GitHub (standard JAR, sources plus POM file, distribution ZIP)
publishing {
publications {
Expand Down

0 comments on commit 37f4134

Please sign in to comment.