Speed up downloads by combining multiple network connections in parallel
TypeScript bandwidth-aggregationcross-platformdesktop-appdownloaderdownloadmanagerlinuxmacosmulticonnectionparallel-downloadswindows
Fix the release build, and write release notes from the changelog (#108)
Anmol Kapilaefca7ab9dab
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex f77b727..c75b5e8 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -60,6 +60,11 @@ jobs:- name: Run smoke testsrun: xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24 -noreset" npm run test:e2e:smoke+ # Packages the build the tests just made: electron-builder checks all of electron-builder.yml+ # (every OS's settings) first, so a bad option fails here instead of on a release tag.+ - name: Package+ run: npx electron-builder --linux dir --publish never+- name: Upload reportif: failure()uses: actions/upload-artifact@v4diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 1cb8b02..9a08eae 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -30,10 +30,13 @@ jobs:node-version: 22cache: npm- # The tag names the version the build gets; a mismatch would ship one version as another.- - name: Check the tag matches package.json+ # The tag names the version the build gets; a mismatch would ship one version as another. The+ # changelog entry becomes the release notes. Both are checked before the long build.+ - name: Check the tag matches package.json and has a changelog entryshell: bash- run: test "v$(node -p "require('./package.json').version")" = "$GITHUB_REF_NAME"+ run: |+ test "v$(node -p "require('./package.json').version")" = "$GITHUB_REF_NAME"+ node scripts/release-notes.mjs "$GITHUB_REF_NAME" --changelog > /dev/null- name: Install rpmbuildif: runner.os == 'Linux'diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex af7b769..319acf2 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -60,15 +60,16 @@ Tests build the app first; set `PLEXO_E2E_SKIP_BUILD=1` when `out/` is already fA release ships seven files: `Plexo` for macOS (Apple silicon and Intel `.dmg`), Windows (one installer for x64 and ARM64) and Linux (`AppImage` and `.deb`, x86_64 and ARM64). The download page (`docs/`, served by GitHub Pages) reads them from the latest GitHub Release and labels each one from its file name (`docs/downloads.js`), so keep the naming in `electron-builder.yml` intact.-A version tag releases it: `.github/workflows/release.yml` builds every OS and leaves a draft GitHub Release with the downloads table.+First bump the version and add its entry at the top of `docs/changelog.js`, in one PR. The entry becomes the release notes, and a tag without one stops before building.```bash-npm version <version> --no-git-tag-version # e.g. 1.0.0-rc.15-git commit -am "Release v<version>" && git push+npm version <version> --no-git-tag-version # e.g. 1.0.0-rc.16+# add the v<version> entry to docs/changelog.js, open the PR, merge it+git checkout main && git pullgit tag v<version> && git push origin v<version>```-Then add your notes to the draft and publish it. Publishing is what ships it: it becomes the Latest release, and within a few hours every running Plexo downloads it in the background and offers a restart. Leave rc releases unmarked as pre-release: the app only updates to Latest, which a pre-release never is. Mark one pre-release (a beta after 1.0, say) to keep it from everyone's automatic updates. A build to throw away? Delete the draft and the tag.+The tag runs `.github/workflows/release.yml`: it builds every OS and leaves a draft GitHub Release with the changelog entry and the downloads table. Check the draft and publish it. Publishing is what ships it: it becomes the Latest release, and within a few hours every running Plexo downloads it in the background and offers a restart. Leave rc releases unmarked as pre-release: the app only updates to Latest, which a pre-release never is. Mark one pre-release (a beta after 1.0, say) to keep it from everyone's automatic updates. A build to throw away? Delete the draft and the tag.Besides the downloads, a release carries what the app's updater reads (`src/main/updater.ts`): the `latest*.yml` channel files, the macOS `.zip`s and the blockmaps. `scripts/release-notes.mjs --files` lists them; the download page ignores them.diff --git a/docs/changelog.js b/docs/changelog.jsindex 0757776..41b344b 100644--- a/docs/changelog.js+++ b/docs/changelog.js@@ -1,14 +1,49 @@/*- * The "What's new" panel on the download page. The page shows the entry whose `version` matches- * the latest GitHub release's tag; a release with no entry here falls back to its own notes.+ * What's new in each version: the top of its GitHub Release's notes (scripts/release-notes.mjs).+ * A version tag with no entry here doesn't build (.github/workflows/release.yml), so add the+ * entry in the same PR as the version bump, newest first.*- * Add the next version's entry before publishing it, newest first. `kind` is one of new, faster,- * improved or fixed; `text` may wrap `code` in backticks.+ * `kind` is one of new, faster, improved or fixed; `text` may wrap `code` in backticks.*/;(function (root) {'use strict'root.PlexoChangelog = [+ {+ version: 'v1.0.0-rc.15',+ items: [+ {+ kind: 'new',+ title: 'Automatic updates',+ text: 'New versions download in the background and install when you restart. The update button in the bottom bar shows how far along it is. Turn automatic updates off there, or in the Plexo menu on a Mac.'+ },+ {+ kind: 'new',+ title: 'Scheduled downloads',+ text: 'Let downloads run only at set times, like overnight, under Networks → Speed & data limits. Outside those times they wait in the queue. Plexo needs to be running for them to start.'+ },+ {+ kind: 'new',+ title: 'Downloads from your browser',+ text: 'The Plexo extension for Chrome, Edge and Firefox hands a download to Plexo with your sign-in, so files behind a login download as they do in the browser.'+ },+ {+ kind: 'new',+ title: 'Right-click a download',+ text: 'Every action for a download, from Pause to Move file to Trash, is in its right-click menu. Text fields get Cut, Copy and Paste too.'+ },+ {+ kind: 'improved',+ title: 'Easier on busy networks',+ text: 'Downloads on Auto now share each network’s 32 streams instead of each taking 32, and up to four run at once.'+ },+ {+ kind: 'fixed',+ title: 'Smaller fixes',+ text: 'Servers that answered Plexo’s first check with the whole file now download in parallel, and file names sent encoded (like `=?UTF-8?B?…?=`) are saved readable.'+ }+ ]+ },{version: 'v1.0.0-rc.12',items: [diff --git a/e2e/releaseNotes.spec.ts b/e2e/releaseNotes.spec.tsindex ac26690..57a81a1 100644--- a/e2e/releaseNotes.spec.ts+++ b/e2e/releaseNotes.spec.ts@@ -32,11 +32,24 @@ function writeChannelFiles(root: string, version: string, names = channelFiles):}}+/** A changelog with one entry for each of `versions`, in docs/changelog.js's shape. */+function writeChangelog(root: string, versions: string[]): void {+ const entries = versions.map((version) => ({+ version: `v${version}`,+ items: [{ kind: 'fixed', title: 'Fixes', text: `What changed in ${version}.` }]+ }))+ writeFileSync(+ join(root, 'docs/changelog.js'),+ `module.exports.PlexoChangelog = ${JSON.stringify(entries)}\n`+ )+}+function prepareRelease(root: string, files: string[]): string {for (const dir of ['scripts', 'docs', 'dist']) mkdirSync(join(root, dir), { recursive: true })for (const file of ['scripts/release-notes.mjs', 'docs/downloads.js']) {copyFileSync(resolve(__dirname, '..', file), join(root, file))}+ writeChangelog(root, ['1.0.0-rc.1', '1.0.0', '1.0.0-rc.11+build.1'])for (const file of files) writeFileSync(join(root, 'dist', file), 'build')return join(root, 'scripts/release-notes.mjs')}@@ -72,13 +85,11 @@ test.describe('release artifact selection @smoke', () => {.sort())- const notesPath = join(root, 'notes.md')- writeFileSync(notesPath, 'Release changes.\n')- const notes = spawnSync(process.execPath, [script, `v${version}`, notesPath], {- encoding: 'utf8'- })+ const notes = spawnSync(process.execPath, [script, `v${version}`], { encoding: 'utf8' })expect(notes.status, notes.stderr).toBe(0)- expect(notes.stdout).toContain('Release changes.\n\n## Downloads')+ expect(notes.stdout).toContain(+ `## What's new\n\n- **Fixed: Fixes.** What changed in ${version}.\n\n## Downloads`+ )for (const file of expected) {const url = `https://github.com/anmolkapil/plexo/releases/download/v${version}/${file}`expect(notes.stdout.split(url + ')')).toHaveLength(2)@@ -89,6 +100,23 @@ test.describe('release artifact selection @smoke', () => {})}+ // The workflow runs --changelog before building, so a tag without notes stops there.+ test('a version with no changelog entry is refused', () => {+ const root = test.info().outputPath('release')+ const script = prepareRelease(root, builds('1.0.0-rc.2'))+ writeChannelFiles(root, '1.0.0-rc.2')+ for (const mode of [[], ['--files'], ['--changelog']]) {+ const result = spawnSync(process.execPath, [script, 'v1.0.0-rc.2', ...mode], {+ encoding: 'utf8'+ })+ expect(result).toMatchObject({+ status: 1,+ stdout: '',+ stderr: expect.stringContaining('No v1.0.0-rc.2 entry in docs/changelog.js')+ })+ }+ })+// Either way the release would reach no installed app, or point them all at another build.test('a release without its own latest*.yml is refused', () => {const root = test.info().outputPath('release')diff --git a/electron-builder.yml b/electron-builder.ymlindex f71e858..fc2251e 100644--- a/electron-builder.yml+++ b/electron-builder.yml@@ -40,6 +40,8 @@ nsis:uninstallDisplayName: ${productName}createDesktopShortcut: alwaysmac:+ # Only the zips go by this name: the dmg has its own (dmg.artifactName).+ artifactName: ${name}-${version}-${arch}-mac.${ext}target:- target: dmgarch: [x64, arm64]@@ -80,8 +82,6 @@ linux:category: Utility# Offered for magnet links and .torrent files ("Open with"), not made their default.mimeTypes: [x-scheme-handler/magnet, application/x-bittorrent, x-scheme-handler/plexo]-zip:- artifactName: ${name}-${version}-${arch}-mac.${ext}appImage:artifactName: ${name}-${version}-${arch}.${ext}npmRebuild: falsediff --git a/scripts/release-notes.mjs b/scripts/release-notes.mjsindex bdc75f1..a0303aa 100644--- a/scripts/release-notes.mjs+++ b/scripts/release-notes.mjs@@ -2,28 +2,47 @@// Builds a GitHub Release from the files in dist/, so the Releases page describes each file the// same way the download page does (both use docs/downloads.js).//-// node scripts/release-notes.mjs v1.0.0-rc.8 [notes.md] the release body: your notes, then the+// node scripts/release-notes.mjs v1.0.0-rc.8 the release body: the version's+// docs/changelog.js entry, then the// downloads table// node scripts/release-notes.mjs v1.0.0-rc.8 --files the files to upload, one per line+// node scripts/release-notes.mjs v1.0.0-rc.8 --changelog just the changelog entry; fails when+// there isn't one//-// Only files the download page knows how to describe are included, so update metadata, blockmaps-// and anything else electron-builder leaves in dist/ never reach a release.+// The notes describe only files the download page knows how to describe; the upload list adds+// what the app's updater reads, and nothing else electron-builder leaves in dist/.import { readFileSync, readdirSync, statSync } from 'node:fs'import { createRequire } from 'node:module'import { join } from 'node:path'import { fileURLToPath } from 'node:url'-const { PlexoDownloads: downloads } = createRequire(import.meta.url)('../docs/downloads.js')+const require = createRequire(import.meta.url)+const { PlexoDownloads: downloads } = require('../docs/downloads.js')+const { PlexoChangelog: changelog } = require('../docs/changelog.js')const REPO = 'anmolkapil/plexo'const SITE = 'https://getplexo.app/'const [tag, arg] = process.argv.slice(2)if (!tag || !/^v\d/.test(tag)) {- console.error('usage: release-notes.mjs <tag, e.g. v1.0.0-rc.8> [notes.md | --files]')+ console.error('usage: release-notes.mjs <tag, e.g. v1.0.0-rc.8> [--files | --changelog]')process.exit(2)}+const KIND = { new: 'New', faster: 'Faster', improved: 'Improved', fixed: 'Fixed' }+const entry = changelog.find((candidate) => candidate.version === tag)+if (!entry) {+ console.error(`No ${tag} entry in docs/changelog.js — add one, then tag again.`)+ process.exit(1)+}+const whatsNew =+ "## What's new\n\n" ++ entry.items.map((item) => `- **${KIND[item.kind]}: ${item.title}.** ${item.text}`).join('\n')+if (arg === '--changelog') {+ console.log(whatsNew)+ process.exit(0)+}+const version = tag.slice(1)// RPM names use a dot before the architecture; other builds use a hyphen or underscore.const artifactName =@@ -76,7 +95,6 @@ if (arg === '--files') {[...files.map((file) => file.path), ...updateFiles.map((name) => join(dist, name))].join('\n'))} else {- const notes = arg ? readFileSync(arg, 'utf-8').trim() + '\n\n' : ''- console.log(notes + downloads.markdown(files, SITE))+ console.log(whatsNew + '\n\n' + downloads.markdown(files, SITE))console.error(`${files.length} files: ${files.map((file) => file.name).join(', ')}`)}