Nucleus
Packaging & distribution

Test updatesNew

Try the update UI, a real download and a full install against your next build, without publishing a release.

View as Markdown

You can test auto-update end to end without publishing a release. Pick the level that matches what you want to check:

You want toUseWhat runs for real
Build the update UISimulationNothing leaves the machine
Check and download your next buildFeed redirect from ./gradlew runManifest, download, checksum
Update an installed copyFeed redirect of the installed appEverything, install and restart included
updater-testingmacOSWindowsLinuxGradle plugin: Not neededWindow runtime: Not needed

Simulate an update

./gradlew run -Pnucleus.updater.simulate=update
./gradlew run -Pnucleus.updater.simulate=download-error
./gradlew run -Pnucleus.updater.simulate.justUpdatedFrom=1.2.0

Every NucleusUpdater in the app then plays a scripted update: checkForUpdates() offers the next version, downloadUpdate() reports progress, and installAndRestart() logs what it would install and returns. Scenarios: update, up-to-date, check-error, download-error, checksum-error. Failures surface as the real exceptions.

To script it in code, for example from a debug menu:

NucleusUpdater {
    provider = GitHubProvider("myorg", "myapp")
    simulation = UpdateSimulation(UpdateSimulation.Scenario.DOWNLOAD_ERROR, downloadDuration = 3.seconds)
}

updater.simulation is non-null while a simulation plays.

Point the app at a local build

Bump packageVersion, package, and point the app at the packaging output:

./gradlew packageNsis
./gradlew run -Pnucleus.updater.feedUrl=build/compose/binaries/main/nsis

The packaging output of every auto-updatable format is a complete feed: the plugin writes the latest*.yml manifest even without a publish block. ./gradlew run checks and downloads for real, and skips the install: an unpackaged run never installs anything.

feedUrl also takes a file: URL, an https server, or http to 127.0.0.1.

Update an installed app

An installed app ignores these switches unless you allow them, since whoever sets the variable would choose what the app installs:

NucleusUpdater {
    provider = GitHubProvider("myorg", "myapp")
    allowLaunchOverrides = BuildConfig.isInternal
}

Then install the current version, bump packageVersion, and serve the next build:

./gradlew serveUpdateFeed
NUCLEUS_UPDATER_FEED_URL=http://127.0.0.1:8421 "C:\Users\me\AppData\Local\Programs\MyApp\MyApp.exe"

serveUpdateFeed packages the auto-updatable formats of the current OS and serves them with byte ranges, so differential downloads work as in production. Slow it down with -Pnucleus.updater.serve.throttle=2m or -Pnucleus.updater.serve.latency=500, and move it with -Pnucleus.updater.serve.port.

Every switch has a system property and an environment variable: nucleus.updater.feedUrl is NUCLEUS_UPDATER_FEED_URL, nucleus.updater.simulate is NUCLEUS_UPDATER_SIMULATE. The updater logs each switch it applies or ignores.

Write automated tests

updater-testing runs a local release host that serves your artifacts and fails on demand:

build.gradle.kts
testImplementation("dev.nucleusframework:nucleus.updater-testing:3.0.0")
UpdateFeedServer().use { feed ->
    feed.publish("2.0.0", File("build/compose/binaries/main/nsis/myapp-2.0.0-win-x64-nsis.exe"))
    feed.fault(FeedFault.Truncate(afterBytes = 4096), path = "*.exe", times = 1)

    val updater = NucleusUpdater {
        currentVersion = "1.0.0"
        executableType = "nsis"
        provider = GenericProvider(feed.baseUrl)
    }
    // drive checkForUpdates() / downloadUpdate() and assert on feed.requests
}

Faults: Status, Delay, Throttle, Truncate, Corrupt, IgnoreRange.

What's next

  • Auto-update: the updater API and supported formats.
  • Publishing: ship the release for real.
  • CI/CD: build every format on each OS.
Was this page helpful?
Edit on GitHub

Last updated on