GitHub Actions

Build self-contained JVM binaries in your CI/CD pipeline.

Quick Start (Copy & Paste)

Copy this workflow to .github/workflows/build.yml:

name: Build Binary

on:
  push:
    branches: [main]
  pull_request:

jobs:
  build:
    runs-on: ubuntu-22.04

    steps:
      - uses: actions/checkout@v4

      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: 21

      - name: Cache jbundle
        uses: actions/cache@v4
        with:
          path: ~/.jbundle/cache
          key: jbundle-linux-x64

      - name: Install jbundle
        uses: baptiste0928/cargo-install@v3
        with:
          crate: jbundle
          git: https://github.com/avelino/jbundle
          branch: main

      - name: Build binary
        run: jbundle build --input . --output ./dist/myapp

      - name: Test binary
        run: ./dist/myapp --help

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: myapp-linux-x64
          path: ./dist/myapp

What to change:

  • myapp → your application name

  • java-version: 21 → your Java version


Installation

Install jbundle from source using cargo-install:

Note: jbundle will be published to crates.io soon, simplifying installation to just crate: jbundle.

Basic Usage

Complete Workflow Example

Gradle Multi-Project

For projects with multiple subprojects (like JabRef):

Cross-Platform Builds

Build for multiple platforms using a matrix:

Note: Cross-compilation (e.g., building linux-aarch64 on ubuntu-22.04) works for the jlink runtime but requires the target JDK to be available.

Caching

Speed up builds by caching the jbundle cache directory:

This caches downloaded JDKs and extracted runtimes.

Using jbundle.toml

Instead of passing flags, use a config file:

Then your workflow simplifies to:

Environment Variables

Enable debug logging for troubleshooting:

Release Workflow

Create releases with binaries for all platforms:

Troubleshooting

Build hangs at "Detecting build system"

This usually means Gradle is downloading dependencies. Add Gradle caching:

Out of memory

Increase JVM memory in your config:

Or via CLI:

Last updated

Was this helpful?