Skip to content

Commit 6a1d5eb

Browse files
committed
Conveyorize!
1. Add a GitHub Actions CI job to compile the JS. The GitHub Desktop build system does a lot of customizations based on what the current OS is. Although it could be fixed to support cross-building, it's easier to just use Actions to build the out/ directory on each target platform. This requires some small adjustments to build.ts so we can produce the input files without running Electron Packager. 2. Add conveyor.conf 3. Update the README 4. Adjust the startup code to be more flexible about URL parsing. This is needed because the way URL open requests are received with Conveyor is different.
1 parent 2496d49 commit 6a1d5eb

12 files changed

Lines changed: 693 additions & 234 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ name: CI
33
on:
44
push:
55
branches:
6-
- development
7-
- __release-*
6+
- conveyorize
87
pull_request:
98

109
jobs:
@@ -57,42 +56,31 @@ jobs:
5756
env:
5857
npm_config_arch: ${{ matrix.arch }}
5958
TARGET_ARCH: ${{ matrix.arch }}
60-
- name: Lint
61-
run: yarn lint
6259
- name: Validate changelog
6360
run: yarn validate-changelog
6461
- name: Ensure a clean working directory
6562
run: git diff --name-status --exit-code
66-
- name: Build production app
63+
64+
# This will place a prepared app directory with native files and OS-specific JS in out/
65+
- name: Create app files
6766
run: yarn build:prod
6867
env:
69-
DESKTOP_OAUTH_CLIENT_ID: ${{ secrets.DESKTOP_OAUTH_CLIENT_ID }}
70-
DESKTOP_OAUTH_CLIENT_SECRET:
71-
${{ secrets.DESKTOP_OAUTH_CLIENT_SECRET }}
72-
APPLE_ID: ${{ secrets.APPLE_ID }}
73-
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
74-
DESKTOPBOT_TOKEN: ${{ secrets.DESKTOPBOT_TOKEN }}
75-
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
76-
npm_config_arch: ${{ matrix.arch }}
77-
TARGET_ARCH: ${{ matrix.arch }}
78-
- name: Prepare testing environment
79-
if: matrix.arch == 'x64'
80-
run: yarn test:setup
81-
- name: Run unit tests
82-
if: matrix.arch == 'x64'
83-
run: yarn test:unit
84-
- name: Run script tests
85-
if: matrix.arch == 'x64'
86-
run: yarn test:script
87-
- name: Publish production app
88-
run: yarn run publish
89-
env:
90-
npm_config_arch: ${{ matrix.arch }}
91-
DESKTOPBOT_TOKEN: ${{ secrets.DESKTOPBOT_TOKEN }}
92-
WINDOWS_CERT_PASSWORD: ${{ secrets.WINDOWS_CERT_PASSWORD }}
93-
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
94-
DEPLOYMENT_SECRET: ${{ secrets.DEPLOYMENT_SECRET }}
95-
AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }}
96-
AZURE_STORAGE_ACCESS_KEY: ${{ secrets.AZURE_STORAGE_ACCESS_KEY }}
97-
AZURE_BLOB_CONTAINER: ${{ secrets.AZURE_BLOB_CONTAINER }}
98-
AZURE_STORAGE_URL: ${{ secrets.AZURE_STORAGE_URL }}
68+
SKIP_ELECTRON_PACKAGER: true
69+
70+
- name: Tarball of the results
71+
if: ${{ matrix.os != 'windows-2019' }}
72+
run: tar czvf build-out-${{ matrix.os }}-${{ matrix.arch }}.tar out
73+
74+
- name: Create artifact from Mac output
75+
if: ${{ matrix.os != 'windows-2019' }}
76+
uses: actions/upload-artifact@v3
77+
with:
78+
name: build-out-${{ matrix.friendlyName }}-${{ matrix.arch }}
79+
path: build-out-${{ matrix.os }}-${{ matrix.arch }}.tar
80+
81+
- name: Create artifact from Windows output
82+
if: ${{ matrix.os == 'windows-2019' }}
83+
uses: actions/upload-artifact@v3
84+
with:
85+
name: build-out-${{ matrix.friendlyName }}-${{ matrix.arch }}
86+
path: out

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
out/
2+
out-*/
23
dist/
34
node_modules/
45
coverage/
@@ -16,3 +17,4 @@ app/node_modules/
1617
junit*.xml
1718
*.swp
1819
tslint-rules/
20+
output

README.md

Lines changed: 50 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,74 @@
1-
# [GitHub Desktop](https://desktop.github.com)
1+
# Conveyorized version of [GitHub Desktop](https://desktop.github.com)
22

3-
[GitHub Desktop](https://desktop.github.com/) is an open source [Electron](https://www.electronjs.org/)-based
4-
GitHub app. It is written in [TypeScript](https://www.typescriptlang.org) and
5-
uses [React](https://reactjs.org/).
3+
This repository shows how to package a complex real world Electron app with [Conveyor](https://hydraulic.software/). It features:
64

7-
![GitHub Desktop screenshot - Windows](https://cloud.githubusercontent.com/assets/359239/26094502/a1f56d02-3a5d-11e7-8799-23c7ba5e5106.png)
5+
- Automatic online updates, checked at each launch.
6+
- Files released via GitHub Releases.
7+
- The [generated download page](https://hydraulic-software.github.io/github-desktop/download.html) being hosted by GitHub pages.
88

9-
## Where can I get it?
9+
Conveyor is a tool that makes distributing desktop apps easier. It builds, signs and notarizes self-updating
10+
packages for you and offers many useful features, like cross-building/signing of packages, different update modes (silent/background and
11+
update-at-launch), and [much more](https://conveyor.hydraulic.dev/).
1012

11-
Download the official installer for your operating system:
13+
## Packaging
1214

13-
- [macOS](https://central.github.com/deployments/desktop/desktop/latest/darwin)
14-
- [macOS (Apple silicon)](https://central.github.com/deployments/desktop/desktop/latest/darwin-arm64)
15-
- [Windows](https://central.github.com/deployments/desktop/desktop/latest/win32)
16-
- [Windows machine-wide install](https://central.github.com/deployments/desktop/desktop/latest/win32?format=msi)
15+
There are three parts. Let's look at them in turn.
1716

18-
You can install this alongside your existing GitHub Desktop for Mac or GitHub
19-
Desktop for Windows application.
17+
Open [conveyor.conf](conveyor.conf) where there are extensive comments. The package can be built by installing Conveyor and
18+
then running:
2019

21-
Linux is not officially supported; however, you can find installers created for Linux from a fork of GitHub Desktop in the [Community Releases](https://github.com/desktop/desktop#community-releases) section.
20+
```
21+
conveyor make site
22+
```
2223

23-
**NOTE**: There is no current migration path to import your existing
24-
repositories into the new application - you can drag-and-drop your repositories
25-
from disk onto the application to get started.
24+
The output directory will now contain packages for Windows, Mac Intel and Mac ARM along with update repository metadata and a generated
25+
download page.
2626

27+
The `conveyor.conf` file imports the raw files to package from the output of a [GitHub Actions CI job](.github/workflows/ci.yml). This is
28+
useful because even though GH Desktop is written in TypeScript the build system picks different node.js extensions and produces
29+
customized JS bundles depending on what OS you build it on. Conveyor can make packages for all supported OS' from whatever you choose to
30+
run it on, and it would be possible to extend the GH Desktop build system to support the same feature to allow arbitrary cross-builds.
2731

28-
### Beta Channel
32+
## Releasing
2933

30-
Want to test out new features and get fixes before everyone else? Install the
31-
beta channel to get access to early builds of Desktop:
34+
To do a release:
3235

33-
- [macOS](https://central.github.com/deployments/desktop/desktop/latest/darwin?env=beta)
34-
- [macOS (Apple silicon)](https://central.github.com/deployments/desktop/desktop/latest/darwin-arm64?env=beta)
35-
- [Windows](https://central.github.com/deployments/desktop/desktop/latest/win32?env=beta)
36-
- [Windows (ARM64)](https://central.github.com/deployments/desktop/desktop/latest/win32-arm64?env=beta)
36+
* Run `conveyor make site --rerun=all`.
37+
* Put the output files into a new GitHub release, except for the `download.html`.
38+
* Put `download.html` into the `docs` subdirectory, commit and push.
3739

38-
The release notes for the latest beta versions are available [here](https://desktop.github.com/release-notes/?env=beta).
40+
## Packaging features used
3941

40-
### Community Releases
42+
This repo demos:
4143

42-
There are several community-supported package managers that can be used to
43-
install GitHub Desktop:
44-
- Windows users can install using [winget](https://docs.microsoft.com/en-us/windows/package-manager/winget/) `c:/> winget install github-desktop` or [Chocolatey](https://chocolatey.org/) `c:\> choco install github-desktop`
45-
- macOS users can install using [Homebrew](https://brew.sh/) package manager:
46-
`$ brew install --cask github`
44+
1. Importing `package.json` files to avoid redundant configuration.
45+
2. Downloading the results of GitHub Actions.
46+
3. Setting which operating systems and CPU architectures are supported.
47+
4. [Aggressive updates](https://conveyor.hydraulic.dev/5.0/configs/#update-modes), which makes these packages check for new versions on every launch. Try downloading the old Mac release and then
48+
running it to see the update in action (on Windows the installer EXE will always install the latest version).
49+
5. [Registering URL schemes](https://conveyor.hydraulic.dev/5.0/configs/os-integration/#url-handlers-deep-linking) for OAuth logins.
50+
6. Setting [custom metadata and entitlements](https://conveyor.hydraulic.dev/5.0/configs/os-integration/#custom-integrations) for Mac apps.
4751

48-
Installers for various Linux distributions can be found on the
49-
[`shiftkey/desktop`](https://github.com/shiftkey/desktop) fork.
52+
These packages are code-signed but you can create self-signed projects if you want.
5053

51-
Arch Linux users can install the latest version from the
52-
[AUR](https://aur.archlinux.org/packages/github-desktop-bin/).
54+
## Comparison to other tools
5355

54-
## Is GitHub Desktop right for me? What are the primary areas of focus?
56+
You can compare the config against the code needed to use other Electron packaging tools by reading the [script/build.ts] and [script/package.ts] files.
57+
The `packageApp()` function in `build.ts` and everything reachable from it could be deleted, along with the whole of `package.ts`. You could
58+
also delete all the code that sets up and instantiates the update manager, because Conveyor doesn't require you to do anything to initialize
59+
the update system.
5560

56-
[This document](https://github.com/desktop/desktop/blob/development/docs/process/what-is-desktop.md) describes the focus of GitHub Desktop and who the product is most useful for.
61+
There are some feature differences vs apps packaged using Electron Forge/Squirrel. On Windows:
5762

58-
And to see what the team is working on currently and in the near future, check out the [GitHub Desktop roadmap](https://github.com/desktop/desktop/blob/development/docs/process/roadmap.md).
63+
* Your app will update itself in the background even when not in use, using the same background transfer service Windows Update
64+
uses. As a consequence your app will be always up-to-date even if only used rarely.
65+
* There is no .NET dependency.
66+
* Enterprise rollouts are easier:
67+
* You don't need to do anything special for IT departments. The MSIX file Conveyor creates is sufficient to give them a good experience.
68+
* Your app doesn't install itself to the user's home directory, which can cause problems with profile roaming on managed networks.
69+
* Fractional rollouts aren't currently supported. You can have a beta channel though just by creating two different sites.
5970

60-
## I have a problem with GitHub Desktop
61-
62-
Note: The [GitHub Desktop Code of Conduct](https://github.com/desktop/desktop/blob/development/CODE_OF_CONDUCT.md) applies in all interactions relating to the GitHub Desktop project.
63-
64-
First, please search the [open issues](https://github.com/desktop/desktop/issues?q=is%3Aopen)
65-
and [closed issues](https://github.com/desktop/desktop/issues?q=is%3Aclosed)
66-
to see if your issue hasn't already been reported (it may also be fixed).
67-
68-
There is also a list of [known issues](https://github.com/desktop/desktop/blob/development/docs/known-issues.md)
69-
that are being tracked against Desktop, and some of these issues have workarounds.
70-
71-
If you can't find an issue that matches what you're seeing, open a [new issue](https://github.com/desktop/desktop/issues/new/choose),
72-
choose the right template and provide us with enough information to investigate
73-
further.
74-
75-
## The issue I reported isn't fixed yet. What can I do?
76-
77-
If nobody has responded to your issue in a few days, you're welcome to respond to it with a friendly ping in the issue. Please do not respond more than a second time if nobody has responded. The GitHub Desktop maintainers are constrained in time and resources, and diagnosing individual configurations can be difficult and time consuming. While we'll try to at least get you pointed in the right direction, we can't guarantee we'll be able to dig too deeply into any one person's issue.
78-
79-
## How can I contribute to GitHub Desktop?
80-
81-
The [CONTRIBUTING.md](./.github/CONTRIBUTING.md) document will help you get setup and
82-
familiar with the source. The [documentation](docs/) folder also contains more
83-
resources relevant to the project.
84-
85-
If you're looking for something to work on, check out the [help wanted](https://github.com/desktop/desktop/issues?q=is%3Aissue+is%3Aopen+label%3A%22help%20wanted%22) label.
86-
87-
## Building Desktop
88-
89-
To get your development environment set up for building Desktop, see [setup.md](./docs/contributing/setup.md).
90-
91-
## More Resources
92-
93-
See [desktop.github.com](https://desktop.github.com) for more product-oriented
94-
information about GitHub Desktop.
95-
96-
97-
See our [getting started documentation](https://docs.github.com/en/desktop/installing-and-configuring-github-desktop/overview/getting-started-with-github-desktop) for more information on how to set up, authenticate, and configure GitHub Desktop.
71+
On macOS the [Sparkle 2 framework](https://sparkle-project.org/) is used instead of Squirrel.Mac.
9872

9973
## License
10074

app/src/lib/find-toast-activator-clsid.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

app/src/main-process/main.ts

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,22 @@ function getExtraErrorContext(): Record<string, string> {
9494
}
9595
}
9696

97-
/** Extra argument for the protocol launcher on Windows */
98-
const protocolLauncherArg = '--protocol-launcher'
99-
10097
const possibleProtocols = new Set(['x-github-client'])
101-
if (__DEV__) {
102-
possibleProtocols.add('x-github-desktop-dev-auth')
103-
} else {
104-
possibleProtocols.add('x-github-desktop-auth')
105-
}
98+
possibleProtocols.add('x-github-desktop-dev-auth')
99+
possibleProtocols.add('x-github-desktop-auth')
106100
// Also support Desktop Classic's protocols.
107101
if (__DARWIN__) {
108102
possibleProtocols.add('github-mac')
109103
} else if (__WIN32__) {
110104
possibleProtocols.add('github-windows')
111105
}
112106

113-
// On Windows, in order to get notifications properly working for dev builds,
114-
// we'll want to set the right App User Model ID from production builds.
115-
if (__WIN32__ && __DEV__) {
116-
app.setAppUserModelId('com.squirrel.GitHubDesktop.GitHubDesktop')
107+
// We have to inform Electron of our package ID (== "app user model ID") as otherwise notifications won't work correctly.
108+
// Package/AUMIDs can be discovered with the Get-StartApps powershell cmdlet. When packaged as MSIX using Conveyor the
109+
// package ID is the name of the app combined with a text-encoded hash of the X.509 signing certificate subject name.
110+
// It is therefore stable as long as the package is always signed with the same identity (doesn't have to be the same key).
111+
if (__WIN32__) {
112+
app.setAppUserModelId('GithubDesktop_fg3qp2cw01ypp!GithubDesktop')
117113
}
118114

119115
app.on('window-all-closed', () => {
@@ -244,9 +240,7 @@ function handlePossibleProtocolLauncherArgs(args: ReadonlyArray<string>) {
244240
log.info(`Received possible protocol arguments: ${args.length}`)
245241

246242
if (__WIN32__) {
247-
// Desktop registers it's protocol handler callback on Windows as
248-
// `[executable path] --protocol-launcher "%1"`. Note that extra command
249-
// line arguments might be added by Chromium
243+
// Note that extra command line arguments might be added by Chromium
250244
// (https://electronjs.org/docs/api/app#event-second-instance).
251245
// At launch Desktop checks for that exact scenario here before doing any
252246
// processing. If there's more than one matching url argument because of a
@@ -264,7 +258,7 @@ function handlePossibleProtocolLauncherArgs(args: ReadonlyArray<string>) {
264258
}
265259
})
266260

267-
if (args.includes(protocolLauncherArg) && matchingUrls.length === 1) {
261+
if (matchingUrls.length === 1) {
268262
handleAppURL(matchingUrls[0])
269263
} else {
270264
log.error(`Malformed launch arguments received: ${args}`)
@@ -274,18 +268,8 @@ function handlePossibleProtocolLauncherArgs(args: ReadonlyArray<string>) {
274268
}
275269
}
276270

277-
/**
278-
* Wrapper around app.setAsDefaultProtocolClient that adds our
279-
* custom prefix command line switches on Windows.
280-
*/
281271
function setAsDefaultProtocolClient(protocol: string) {
282-
if (__WIN32__) {
283-
app.setAsDefaultProtocolClient(protocol, process.execPath, [
284-
protocolLauncherArg,
285-
])
286-
} else {
287-
app.setAsDefaultProtocolClient(protocol)
288-
}
272+
// Unnecessary when packaged with Conveyor: URL handling is always declarative in package metadata.
289273
}
290274

291275
if (process.env.GITHUB_DESKTOP_DISABLE_HARDWARE_ACCELERATION) {

app/src/main-process/menu/build-default-menu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ export function buildDefaultMenu({
570570
)
571571
}
572572

573-
if (__RELEASE_CHANNEL__ === 'development' || __RELEASE_CHANNEL__ === 'test') {
573+
if (true || __RELEASE_CHANNEL__ === 'development' || __RELEASE_CHANNEL__ === 'test') {
574574
helpItems.push({
575575
label: 'Show notification',
576576
click: emit('test-show-notification'),

0 commit comments

Comments
 (0)