Automatic Updates

Auto-updates ship by publishing a signed artifact and a matching latest.yml to a place the app knows to check. shinyelectron wires your project up to electron-updater, which does the checking, downloading, and swap-on-quit.

Three panels. A version 1.0.0 app on the left requests latest.yml from a publish host in the middle, which lists a manifest and signed installers. An arrow on the right shows the app updated to version 1.1.0.Three panels. A version 1.0.0 app on the left requests latest.yml from a publish host in the middle, which lists a manifest and signed installers. An arrow on the right shows the app updated to version 1.1.0.
Update flow: the installed app reads a manifest, fetches a signed artifact, then swaps in on the next quit.

Pick a publish host

GitHub Releases and Generic HTTP are supported. S3 is planned and not yet wired into the build.

Provider Status Best for Requirements
GitHub Releases Supported Open source projects Public or private GitHub repo
S3 Planned Enterprise deployments AWS S3 bucket
Generic HTTP Supported Custom infrastructure Any HTTP server

Quick start

Point the app at a GitHub repo and re-export. Everything else follows from configuration.

enable_auto_updates(
  "path/to/app",
  provider = "github",
  owner = "your-username",
  repo = "your-app-repo"
)

enable_auto_updates() writes the settings to _shinyelectron.yml. Verify them at any time with:

check_auto_update_status("path/to/app")

GitHub Releases

GitHub Releases is the default, and the right choice for most open-source projects.

Configure the app

Tell the app where to look, and choose whether it prompts the user before downloading.

enable_auto_updates(
  "path/to/app",
  provider = "github",
  owner = "myorg",
  repo = "my-shiny-dashboard",
  check_on_startup = TRUE,
  auto_download = FALSE   # Prompt user before downloading
)

Build the app

Build as usual.

export("path/to/app", destdir = "build")

Publish a release

  1. Go to your repo on GitHub.
  2. Click Releases, then Create a new release.
  3. Create a tag such as v1.0.0.
  4. Upload the built installers and update manifests. For an app whose slug is my-app:
  5. Publish the release.

Note

Upload the files under the names electron-builder gave them. electron-updater downloads the file that latest.yml, latest-mac.yml, or latest-linux.yml names. Those names are built from the app’s slug, version, and architecture (<slug>-<version>-<arch>.<ext>, with Setup in the Windows installer’s name), so they are safe to upload to GitHub Releases as they are.

What the user sees

On the next launch, a version higher than the installed one triggers the update cycle:

  1. The app checks on startup when check_on_startup = TRUE.
  2. A notification tells the user an update is available.
  3. The installer downloads, silently if auto_download = TRUE, otherwise on consent.
  4. The app prompts to restart and install.

Users can also check at any time from Help > About > Check for Updates on Windows and Linux, which reports the result in a dialog. The button is left out on macOS, where a build ships only a disk image and electron-updater needs a zip archive to update the app.

Try the update check locally

See what the app says when an update exists, without publishing a release. Export with updates on, then run the app against a local feed that offers a higher version.

export("path/to/app", destdir = "build")
run_electron_app("build/electron-app", update_version = "2.0.0")

Any provider works. For this run the app checks a feed served on 127.0.0.1 instead of the host in its configuration.

With a version above the app’s, the startup notice appears (with check_on_startup = TRUE, the default), and on Windows and Linux Help > About > Check for Updates answers “Version 2.0.0 is available” (with auto_download = TRUE, both say the version “is downloading” instead). With a version at or below the app’s, Check for Updates answers “You are up to date”. macOS shows only the startup notice, since the button is left out there.

Download in the Check for Updates dialog fails with “Could not download the update”, and a download started from the startup notice fails without a message and is only written to the log. That is expected: the feed offers a version but holds no installer. To try the download and the install as well, rehearse an update locally.

The run writes dev-app-update.yml into the app folder and removes it when the run ends, even after an error or Ctrl+C. If the folder already holds a dev-app-update.yml of your own, the run stops and leaves that file as it is.

Configuration

The full updates block in _shinyelectron.yml:

updates:
  enabled: true
  provider: "github"        # or "generic"
  check_on_startup: true    # Check when app starts
  auto_download: false      # Download without prompting
  auto_install: false       # Install on app quit

  github:                   # Read with provider: "github"
    owner: "your-username"
    repo: "your-repo"
    private: false          # Set true for private repos

  generic:                  # Read with provider: "generic"
    url: "https://updates.example.com/my-app/"

Three knobs, one pipeline

Three flags drive three stages. check_on_startup asks whether an update exists. auto_download fetches it. auto_install applies it on quit.

Setting Behavior
check_on_startup: true Checks for updates when app launches
auto_download: true Downloads updates silently in the background
auto_install: true Installs the update when the user quits the app

Sensible default: check automatically, but let the user choose when to download and restart.

updates:
  check_on_startup: true
  auto_download: false    # Let user decide
  auto_install: false     # Let user decide when to restart

Security patches and regressions benefit from the aggressive posture:

updates:
  check_on_startup: true
  auto_download: true     # Download immediately
  auto_install: true      # Install on next quit

Private repositories

Private repos require a token in the user’s environment.

updates:
  github:
    owner: "my-org"
    repo: "private-app"
    private: true

Export GH_TOKEN before launch.

# macOS/Linux
export GH_TOKEN=ghp_xxxxxxxxxxxx

# Windows
set GH_TOKEN=ghp_xxxxxxxxxxxx

Apps opened from Finder, the Dock, or the Start menu do not see a variable set this way in a terminal; see Secrets and per-user credentials for how environment variables reach a launched app.

S3

Important

S3 is planned but not yet supported. enable_auto_updates() accepts "github" and "generic" as the provider, and with updates on, provider: "s3" in _shinyelectron.yml stops the build with a message. This section documents the intended design for when S3 support is added.

Point at a bucket for enterprise distribution.

updates:
  enabled: true
  provider: "s3"
  s3:
    bucket: "my-app-updates"
    region: "us-east-1"
    path: "/releases"

The bucket should mirror the pattern GitHub Releases produces: per-platform manifests beside the installers.

my-app-updates/
└── releases/
    ├── latest.yml           # Update manifest
    ├── latest-mac.yml       # macOS manifest
    ├── latest-linux.yml     # Linux manifest
    ├── my-app-1.0.0-arm64.dmg
    ├── my-app-Setup-1.0.0-x64.exe
    └── my-app-1.0.0-x86_64.AppImage

AWS credentials come from the environment.

export AWS_ACCESS_KEY_ID=xxx
export AWS_SECRET_ACCESS_KEY=xxx

Generic HTTP

Anything that can serve static files works. Point the app at the folder that will hold the update files.

enable_auto_updates(
  "path/to/app",
  provider = "generic",
  url = "https://updates.example.com/my-app/"
)

Export as usual, then upload to that folder, side by side, the latest*.yml files from electron-app/dist/, the installers they name, and the .blockmap files when the build produced them. On each check the app reads one manifest from the address: latest.yml on Windows, latest-mac.yml on macOS, latest-linux.yml on Linux, or latest-linux-arm64.yml on 64-bit ARM Linux. On Windows and Linux it then downloads the installer that manifest names from the same folder; a Mac shows the notice but cannot install from a disk image (see What the user sees).

Use an https:// address. An http:// address warns unless the host is localhost or 127.0.0.1, because anyone on the network could change what the app downloads; see Security. The address must also hold no backslash or space, as Configuration explains.

The address is written into the app when you export, so export again after changing it.

Rehearse an update locally

On Windows and Linux you can try a whole update, download and install included, against a newer build served from your own machine. macOS is left out because a build ships only a disk image, as What the user sees explains. The rehearsal does not use the feed from Try the update check locally, which holds no installer.

Point the app at your machine and export it with app.version at "1.0.0", the default.

enable_auto_updates("path/to/app", provider = "generic", url = "http://127.0.0.1:8080/")
export("path/to/app", destdir = "build-1.0.0")

Install it from build-1.0.0/electron-app/dist/. On Linux, start the AppImage file itself, since the updater works only in an app started from its AppImage. An AppImage needs FUSE 2 to start, which recent Ubuntu releases do not install by default: if it stops with “AppImages require FUSE to run”, install the libfuse2t64 package (libfuse2 on Ubuntu 22.04) and start it again. Then set app.version to "1.1.0" in _shinyelectron.yml and export into another folder. Build both versions the same way, signed or not, since on Windows a signed 1.0.0 accepts only an update signed by the same publisher.

export("path/to/app", destdir = "build-1.1.0")

Serve that build’s electron-app/dist/ folder on 127.0.0.1 at port 8080 with a static file server. On a machine with Node.js, one way is npx, run from the folder that holds build-1.1.0; the command is the same in PowerShell and in a Unix shell. -a keeps the server to your own machine, -p sets the port, and -c-1 turns off caching.

npx --yes http-server build-1.1.0/electron-app/dist -a 127.0.0.1 -p 8080 -c-1

If PowerShell refuses to run npx because running scripts is disabled, type npx.cmd in its place.

In the installed 1.0.0 app, choose Help > About > Check for Updates. It answers “Version 1.1.0 is available”; choose Download. When the download finishes, the app asks to restart; choose Restart to install 1.1.0. Then stop the server with Ctrl+C.

Uninstall the rehearsal build afterwards (on Linux, delete its AppImage). It keeps asking http://127.0.0.1:8080/ for updates at every launch, and any program on that machine that listens on port 8080 could offer it one. Before shipping, set the real https:// address with enable_auto_updates() and export again.

Code signing

Warning

Unsigned apps trigger Gatekeeper and SmartScreen warnings. Sign production builds.

macOS

Supply a certificate, its password, and an Apple ID for notarization.

export CSC_LINK=/path/to/certificate.p12
export CSC_KEY_PASSWORD=your-password
export APPLE_ID=your@email.com
export APPLE_APP_SPECIFIC_PASSWORD=xxxx-xxxx-xxxx-xxxx

Windows

A PFX certificate and password are enough.

export CSC_LINK=/path/to/certificate.pfx
export CSC_KEY_PASSWORD=your-password

Turning updates off

disable_auto_updates("path/to/app")

Or edit the config directly.

updates:
  enabled: false

Troubleshooting

The check fails

Symptom: “Error checking for updates.”

  1. Confirm the machine is online.
  2. GitHub Releases: confirm the repo exists and is reachable.
  3. Generic HTTP: open the manifest at the url address in a browser, such as https://updates.example.com/my-app/latest.yml.
  4. GitHub Releases: for private repos, confirm GH_TOKEN is set.
  5. Check firewall rules.

Downloads, never installs

Symptom: the update arrives but the app does not swap in on restart.

  1. The app needs write permission to its own install directory.
  2. On macOS, the app must live in Applications.
  3. Antivirus software can quarantine the new artifact.

Always “No updates available”

Symptom: the app never sees a newer version.

  1. GitHub Releases: package.json version must match the release tag.
  2. The uploaded files must keep the names electron-builder gave them, which the latest*.yml manifests list.
  3. GitHub Releases: the release must be published, not saved as a draft.
  4. Generic HTTP: the latest*.yml files at the url address must be the new build’s.

Debug logging

Turn on verbose logs.

export ELECTRON_ENABLE_LOGGING=1

Logs land per platform, in a folder named after the app’s slug:

Publishing from CI

The same tag that cuts a release can build every installer. A minimal workflow:

name: Release

on:
  push:
    tags: ['v*']

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [macos-latest, windows-latest, ubuntu-latest]

    steps:
      - uses: actions/checkout@v7

      - name: Setup R
        uses: r-lib/actions/setup-r@v2

      - name: Build app
        run: |
          Rscript -e "shinyelectron::export('app', destdir = 'build')"

      - name: Upload to Release
        uses: softprops/action-gh-release@v3
        with:
          files: build/electron-app/dist/*

See the GitHub Actions vignette for the full template.

Next steps