Ship updates
Check for a new version at launch, download it with progress, offer a restart, and test the whole flow locally before you publish.
The app checks GitHub Releases at launch, downloads a newer version in the background and asks the user to restart. The CI publishes each release with the metadata files the updater reads.
Add the modules
dependencies {
implementation("dev.nucleusframework:nucleus.updater-runtime:3.0.0")
implementation("dev.nucleusframework:nucleus.notification-common:3.0.0")
}Check, download, offer a restart
val updater = NucleusUpdater {
provider = GitHubProvider(owner = "myorg", repo = "myapp")
}
fun main(args: Array<String>) = nucleusApplication(args) {
LaunchedEffect(Unit) {
val result = updater.checkForUpdates()
if (result !is UpdateResult.Available) return@LaunchedEffect
var installer: File? = null
updater.downloadUpdate(result.info).collect { progress ->
progress.file?.let { installer = it }
}
val file = installer ?: return@LaunchedEffect
notification(title = "Update ready", message = "Restart to finish the update") {
button("Restart now") { updater.installAndRestart(file) }
}.send()
}
Window(onCloseRequest = ::exitApplication, title = "My App") { App() }
}checkForUpdates() returns NotAvailable for store-managed formats (App Store PKG, AppX/MSIX,
Snap, Flatpak): the store updates those. On a per-user NSIS install, installAndRestart installs
while the app stays on screen.
Ship a ZIP on macOS
The updater replaces the .app from the release's ZIP. Add TargetFormat.Zip next to
TargetFormat.Dmg or TargetFormat.Pkg.
Test before you publish
Simulate an update without a release:
./gradlew run -Pnucleus.updater.simulate=update
./gradlew run -Pnucleus.updater.simulate=download-errorThen point the app at a local build to run the real download and install:
./gradlew packageNsis
./gradlew run -Pnucleus.updater.feedUrl=build/compose/binaries/main/nsisPublish from CI
generate-update-yml writes the latest*.yml files the updater reads, and publish-release
uploads them with the installers:
- uses: NucleusFramework/Nucleus/.github/actions/generate-update-yml@main
with:
artifacts-path: artifacts
version: ${{ env.VERSION }}
channel: ${{ env.CHANNEL }} # latest, beta, or alpha
- uses: NucleusFramework/Nucleus/.github/actions/publish-release@main
with:
artifacts-path: artifacts
tag: ${{ env.TAG }}
release-type: ${{ env.RELEASE_TYPE }} # release, draft, or prereleaseWhat's next
- Auto-update: channels, differential downloads, failed installs.
- Test updates: an installed app, and automated tests with
UpdateFeedServer. - CI/CD: the full build, sign and release workflow.
- Code signing: sign the installers you ship.
Last updated on
Build a menu bar app
An app that lives in the tray or menu bar, opens its window on demand, starts at login and notifies the user.
Lock a screen with biometrics
Hide a screen until the device owner confirms with Touch ID, Face ID, Windows Hello, Android BiometricPrompt or polkit, from shared Kotlin code.