Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 51 additions & 14 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: Build/release

on: push
on:
push:
# A PR builds and, from a branch in this repo, signs and notarizes; it never publishes.
pull_request:
branches: [master]

permissions:
contents: read

jobs:
lint:
Expand All @@ -26,9 +33,19 @@ jobs:
needs: lint
runs-on: ${{ matrix.os }}

# Publishing uploads release assets with the workflow token.
permissions:
contents: write

strategy:
matrix:
os: [macos-15, ubuntu-24.04, windows-latest]
include:
- os: macos-15
platform: mac
- os: ubuntu-24.04
platform: linux
- os: windows-latest
platform: win

steps:
- name: Check out Git repository
Expand All @@ -49,19 +66,39 @@ jobs:
- name: Download binaries
run: npm run download-binaries

- name: Build/release Electron app
uses: samuelmeuli/action-electron-builder@v1
with:
# GitHub token, automatically provided to the action
# (No need to define this secret in the repo settings)
github_token: ${{ secrets.github_token }}
mac_certs: ${{ secrets.mac_certs }}
mac_certs_password: ${{ secrets.mac_certs_password }}

# If the commit is tagged with a version (e.g. "v1.0.0"),
# release the app after building
release: ${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Build
run: yarn build
env:
SENTRY_URL: ${{ secrets.sentry_url }}
SENTRY_ORG: ${{ secrets.sentry_org }}
SENTRY_PROJECT: ${{ secrets.sentry_project }}
SENTRY_AUTH_TOKEN: ${{ secrets.sentry_auth_token }}

# GitHub gives no secrets to a PR from a fork, so its macOS build cannot sign.
- name: Warn that a fork PR builds unsigned
if: matrix.platform == 'mac' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
run: echo "::warning::PR from a fork; the macOS app is built unsigned and not notarized. Push the branch to ${{ github.repository }} to check signing."

# Only a v* tag publishes. A macOS build from a tag or a same-repo PR fails unless it signs and notarizes.
- name: Package and publish
shell: bash
# electron-builder reads an empty CSC_LINK on macOS as a certificate path, so drop it when the secret is missing.
run: |
[ -n "$CSC_LINK" ] || unset CSC_LINK CSC_KEY_PASSWORD
force=()
if [ "${{ matrix.platform }}" = mac ] && [ "$REQUIRE_NOTARIZE" = true ]; then
force=(-c.forceCodeSigning=true)
# electron-builder skips signing whenever GITHUB_BASE_REF is set. Only same-repo PRs reach here; fork PRs get no secrets.
export CSC_FOR_PULL_REQUEST=true
fi
yarn electron-builder --${{ matrix.platform }} \
--publish ${{ startsWith(github.ref, 'refs/tags/v') && 'always' || 'never' }} \
"${force[@]}"
env:
REQUIRE_NOTARIZE: ${{ startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_LINK: ${{ matrix.platform == 'mac' && secrets.mac_certs || '' }}
CSC_KEY_PASSWORD: ${{ matrix.platform == 'mac' && secrets.mac_certs_password || '' }}
# macOS notarization API key
APPLEID: ${{ secrets.apple_id }}
APPLEIDPASS: ${{ secrets.apple_id_pass }}
Expand Down
42 changes: 30 additions & 12 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,39 @@
### Before pushing
* Check if there are any warnings in the console. Those will be treated as errors in the CI environment.

### Recommended GitHub Releases Workflow¶
From [electron.build publish](https://www.electron.build/configuration/publish#recommended-github-releases-workflow)

1. Draft a new release. Set the “Tag version” to the value of version in your application package.json, and prefix it with v. “Release title” can be anything you want.
2. For example, if your application package.json version is 1.2.3, your draft’s “Tag version” would be v1.2.3.
3. Push some commits. Every CI build will update the artifacts attached to this draft.
4. Once you are done, publish the release. GitHub will tag the latest commit for you.
The benefit of this workflow is that it allows you to always have the latest artifacts, and the release can be published once it is ready.
5. Update CHANGELOG and the download links in `docs/_layouts/default.html` to the new version.
5. Bump the version in package.json to use for the next draft and push to update the download links on the github page.
6. Uploading Debug Information
### What CI builds

`.github/workflows/build.yaml` builds the app on macOS, Ubuntu and Windows for every push and every PR into `master`. Only a `v*` tag publishes.

| Build | Publishes | macOS signs and notarizes |
|---|---|---|
| `v*` tag | yes, to a draft release | required; the build fails otherwise |
| PR from a branch in this repo | no | required; the build fails otherwise |
| PR from a fork | no | no; GitHub gives fork PRs no secrets, so the run warns |
| Other branch push | no | only if the repo has the signing secrets |

Signing needs the `mac_certs` and `mac_certs_password` secrets. Notarizing needs `apple_id`, `apple_id_pass` and `apple_id_team`. To check signing before a release, open the PR from a branch in this repo, not a fork.

### Releasing a version

1. Set `version` in `package.json` to the new version, for example `2.1.0`. Update `CHANGELOG.md` and the download links in `docs/_layouts/default.html`. Merge to `master`.
2. Tag that commit with `v` and the same version, and push the tag:
```
git tag v2.1.0
git push origin v2.1.0
```
CI builds all three platforms and uploads them to a draft release named `v2.1.0`, creating the draft if needed. electron-builder names the release from `package.json`, not from the tag, so the two must match.
3. Check the draft on GitHub, then publish it. Auto-update and the download links only see a published release.

A tag pushed after its release is already published uploads nothing; electron-builder only logs a warning. To redo a release, delete the release and tag, or bump the version.

To publish from your own machine instead, set `GH_TOKEN` and run `yarn publish-all`. It packs for every platform, but macOS can only be signed and notarized on a Mac.

### Uploading debug information

A production build uploads JavaScript source maps for the main process and the page when `SENTRY_ORG` and `SENTRY_AUTH_TOKEN` are set. The release name is `raxmlGUI@version`. The preload is not included, and a dev start does not upload.

Native crash symbols stay a manual upload. `sentry-symbols.js` downloads the Electron symbols and uploads them with `sentry-cli upload-dif`. After installing the SDK, and again after every Electron upgrade, run `node sentry-symbols.js`.
Native crash symbols are not uploaded. To add them, download the Electron symbols for the installed Electron version and upload them with `sentry-cli upload-dif`.

## Homepage

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ https://github.com/electron/electron-notarize
https://stackoverflow.com/questions/53112078/how-to-upload-dmg-file-for-notarization-in-xcode/53121755#53121755

#### Publishing with electron-builder
Need to have a GH_TOKEN in your shell env
CI publishes a release when you push a `v*` tag. See [BUILD.md](BUILD.md#releasing-a-version) for the steps and which builds sign and notarize.

#### Binaries
The binaries for RAxML on MacOS were compiled from this repository: https://github.com/jtklein/standard-RAxML
Expand Down
3 changes: 3 additions & 0 deletions e2e/no-node.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ test.describe('Node shut out', () => {
: null,
bridgeRequire: typeof window.require,
bridgeProcess: typeof window.process,
// @ts-expect-error set by the @sentry/electron auto-registered preload
sentryIpc: typeof window.__SENTRY_IPC__,
}));

expect(probe.require).toBe('undefined');
expect(probe.bridgeRequire).toBe('undefined');
expect(probe.bridgeProcess).toBe('undefined');
expect(probe.processVersions && probe.processVersions.node).toBeFalsy();
expect(probe.sentryIpc).toBe('object');
});
});
4 changes: 4 additions & 0 deletions electron.vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ function sourceMapUpload( command ) {
export default defineConfig( ( { command } ) => ( {
main: {
plugins: sourceMapUpload( command ),
build: {
// electron-store 12 and conf are ESM-only, so a CommonJS main bundles them instead of calling require().
externalizeDeps: { exclude: ['electron-store', 'conf'] },
},
},
preload: {
build: {
Expand Down
29 changes: 18 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@
"dist-pack-win": "run-s build electron-pack-win",
"publish-all": "run-s build electron-build-publish-all",
"postinstall-deps": "electron-builder install-app-deps",
"postinstall-patch": "patch-package",
"postinstall-electron": "install-electron --no",
"postinstall": "run-s postinstall-deps postinstall-patch postinstall-electron",
"postinstall": "run-s postinstall-deps postinstall-electron",
"docs-serve": "cd docs && bundle exec jekyll serve --config _config.yml,_config_dev.yml",
"typecheck": "tsc --noEmit",
"lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\" electron.vite.config.js vitest.config.mjs --max-warnings 0",
Expand All @@ -58,22 +57,20 @@
"@emotion/styled": "^11.14.1",
"@mui/icons-material": "^7.3.11",
"@mui/material": "^7.3.11",
"@sentry/electron": "^4.0.2",
"@sentry/electron": "^8.4.0",
"allotment": "^1.20.6",
"classnames": "^2.3.2",
"clean-stack": "3.0.1",
"d3-array": "^3.2.5",
"electron-log": "^4.4.8",
"electron-store": "^8.1.0",
"electron-log": "^5.4.4",
"electron-store": "^12.0.0",
"electron-updater": "^6.8.12",
"filenamify": "^4.3.0",
"lodash": "^4.18.1",
"mobx": "^7.1.7",
"mobx-react-lite": "^5.1.3",
"mobx-utils": "^6.1.0",
"parse-filepath": "^1.0.2",
"patch-package": "^8.0.1",
"postinstall-postinstall": "^2.1.0",
"prismjs": "^1.30.0",
"prismjs-bibtex": "^2.1.0",
"react": "^19.3.1",
Expand All @@ -97,15 +94,14 @@
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "5.2.0",
"dotenv": "^17.4.2",
"download": "^8.0.0",
"electron": "^45.2.3",
"electron-builder": "^24.13.3",
"electron-download": "^4.1.1",
"electron-builder": "^26.18.1",
"electron-vite": "^6.0.0",
"eslint": "^10",
"eslint-plugin-import-x": "^4.18.1",
"eslint-plugin-lodash": "^8.1.0",
"eslint-plugin-react-hooks": "^7.1.1",
"extract-zip": "^2.0.1",
"globals": "^17.14.0",
"jsdom": "^29.1.1",
"npm-run-all": "^4.1.5",
Expand All @@ -126,6 +122,14 @@
"appId": "org.jtklein.raxmlGUI2",
"productName": "raxmlGUI",
"afterSign": "./scripts/notarize.js",
"electronFuses": {
"runAsNode": false,
"enableCookieEncryption": true,
"enableNodeOptionsEnvironmentVariable": false,
"enableNodeCliInspectArguments": false,
"enableEmbeddedAsarIntegrityValidation": true,
"onlyLoadAppFromAsar": true
},
"extends": null,
"directories": {
"buildResources": "public",
Expand All @@ -140,7 +144,8 @@
"!static{,/**/*}",
"!scripts{,/**/*}",
"!test-results{,/**/*}",
"!playwright-report{,/**/*}"
"!playwright-report{,/**/*}",
"!node_modules/@oxc-parser{,/**/*}"
],
"extraResources": [
"assets/"
Expand All @@ -151,6 +156,8 @@
},
"mac": {
"identity": "Johannes Klein (9VR92ZCXA8)",
"type": "distribution",
"notarize": false,
"mergeASARs": false,
"target": [
{
Expand Down
Binary file added public/icons/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 30 additions & 14 deletions scripts/download-binaries.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require('fs').promises;
const os = require('os');
const path = require('path');
const download = require('download');
const extract = require('extract-zip');

const osName = (() => {
switch (process.platform) {
Expand All @@ -18,26 +19,41 @@ const binariesBaseDir =
const binariesUrl = `${binariesBaseDir}/${osName}.zip`;

const binPath = path.join(__dirname, '..', 'static', 'bin');
const raxmlNgPath = path.join(binPath, 'raxml-ng');
const osBinPath = path.join(binPath, osName);

// The Mac zip carries Finder metadata the app never reads.
const removeMacMetadata = () =>
fs.rm(path.join(binPath, '__MACOSX'), { recursive: true, force: true });

(async () => {
console.log('Check binaries...');
let exist = true;
try {
await fs.access(raxmlNgPath);
} catch (_) {
exist = false;
}

if (exist) {
const osBinEntries = await fs.readdir(osBinPath).catch(() => []);
if (osBinEntries.length > 0) {
await removeMacMetadata();
console.log('Binaries exist!');
return;
}

console.log(`Binaries missing, downloading from '${binariesUrl}'...`);
const response = await fetch(binariesUrl);
if (!response.ok) {
throw new Error(
`Download failed: ${response.status} ${response.statusText}`,
);
}

await download(binariesUrl, binPath, {
extract: true,
});
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), 'raxmlgui-bin-'));
try {
const zipPath = path.join(tmpDir, `${osName}.zip`);
await fs.writeFile(zipPath, Buffer.from(await response.arrayBuffer()));
// extract-zip keeps the execute bits stored in the zip entries.
await extract(zipPath, { dir: binPath });
} finally {
await fs.rm(tmpDir, { recursive: true, force: true });
}
await removeMacMetadata();
console.log('Done!');
})();
})().catch((error) => {
console.error(error);
process.exit(1);
});
7 changes: 7 additions & 0 deletions scripts/notarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ exports.default = async function notarizing(context) {
const appleIdPassword = process.env.APPLEIDPASS;
const teamId = process.env.APPLEIDTEAM;

// CI sets this on tag and same-repo PR builds, which must prove notarizing works.
if (process.env.REQUIRE_NOTARIZE === 'true' && !(appleId && appleIdPassword && teamId)) {
throw new Error(
'Refusing to skip notarization: REQUIRE_NOTARIZE is set but APPLEID, APPLEIDPASS or APPLEIDTEAM is missing.'
);
}

if (!appleId) {
console.log(
'Johannes: Skipping notarization of app because no AppleID is given.'
Expand Down
Loading
Loading