Skip to content

Sample of electron app built with react and with auto-update feature and Gitlab

License

Notifications You must be signed in to change notification settings

Thibaut-Mouton/react-electron-autoupdate-with-gitlab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Electron logo

Electron & React : Build autoUpdate feature on Gitlab private repository

This project shows how to deploy auto-update feature on electron project hosted on Gitlab. Electron's auto-updater module allow downloading new versions automatically.

1. Generate Gitlab token

Gitlab token logo

Create your own token with API scope.

2. Change package.json and main.ts with your own settings

package.json :
"repository": {
  "type": "git",
  "url": "https://gitlab.com/your-gitlab-username/your-repository-name/"
}
"publish": {
"provider": "generic",
"url": "https://gitlab.com/api/v4/projects/Your-project-id/jobs/artifacts/your-branch-name/raw/dist?job=build"
}
electron/main.ts
// Auto update feature
autoUpdater.requestHeaders = {"PRIVATE-TOKEN": "your-gitlab-token"};

3. Build app and launch it locally

Run yarn run electron:build to build your app. Run mercure.exe with command line or by double-clicking it. You can see there is no new version available

4. Change files and push to repository

If you want to commit and publish a new version on your repository, don't forget to change the package.json version. Otherwise the auto-updater module won't be able to detect a new version

package.json :
"version": "1.5.0"

The commit will trigger gitlab pipeline :

Uploading artifacts for successful job
Uploading artifacts...
dist/: found 421 matching files and directories    
Uploading artifacts as "archive" to coordinator... ok 
Cleaning up file based variables
Job succeeded

Once the pipeline is finished, a new version is available at https://gitlab.com/your-username/your-repo-name/-/jobs/job-ID/artifacts/file The latest.yml file is very important because it contains the version id.

5. Run your app

You should see this message :

Update available