Skip to content

Commit a08389d

Browse files
authored
Build script and document updates (#14)
2 parents ac51a24 + 993a5e4 commit a08389d

9 files changed

Lines changed: 353 additions & 349 deletions

File tree

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
contents: write
1212
steps:
1313
- uses: actions/checkout@v5
14+
with:
15+
fetch-depth: 0
1416

1517
- name: Setup Node.js
1618
uses: actions/setup-node@v5
@@ -40,8 +42,6 @@ jobs:
4042
- name: Build
4143
run: corepack yarn build
4244

43-
- name: Create Release
44-
uses: softprops/action-gh-release@v2
45-
with:
46-
files: dist/*.xpi
47-
generate_release_notes: true
45+
- run: npx changelogithub@13.16.0 --assets 'dist/*.xpi'
46+
env:
47+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ build/
33
.vscode/
44
.zed/
55
.web-ext-config.mjs
6+
manifest.json
67

78
# Logs
89
logs

.web-ext-config.example.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ export default {
77
firefox: "/usr/bin/thunderbird",
88
firefoxProfile: "/home/your/.config/your-testing-thunderbird-profile",
99
profileCreateIfMissing: true,
10+
// keepProfileChanges: true,
1011
},
1112
};

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Basically `yarn && yarn build`. See [CONTRIBUTING.md](./CONTRIBUTING.md) to get
4747

4848
1. Launch your favorite text editor.
4949
2. Start GhostText server in your text editor (e.g. with `:GhostTextStart` in Vim).
50-
3. Press the gray Ghostbird button <img src="./ext/gray.svg" width="24" height="24" border="1"> in the Thunderbird mail compose window. (The default shortcut is `Ctrl-E`)
50+
3. Press the gray Ghostbird button <img src="./ext/gray.svg" width="24" height="24" border="1"> in the Thunderbird mail compose window. (The default shortcut is <kbd>Ctrl</kbd>+<kbd>E</kbd>)
5151
* If the connection is successful, the button will turn blue <img src="./ext/blue.svg" width="24" height="24" border="1">.
5252
* If the connection fails, the button will turn red <img src="./ext/red.svg" width="24" height="24" border="1">. Make sure that the GhostText server is listening. See [Troubleshooting page of original GhostText](https://ghosttext.fregante.com/troubleshooting/#unable-to-connect).
5353
4. Write your email in the text editor.
@@ -157,8 +157,8 @@ If you liked the idea, please:
157157
We need help with:
158158

159159
* [Website](https://exteditor.github.io/ghostbird/) and materials (Please post [screenshots to the wiki](https://github.com/exteditor/ghostbird/wiki/Screenshots))
160-
* [Testing with various text editors](https://github.com/exteditor/ghostbird/wiki/Text_editors_known_to_work_with)
161-
* [Testing with various OSes](https://github.com/exteditor/ghostbird/wiki/OSes_known_to_work_with)
160+
* [Testing with various text editors](https://github.com/exteditor/ghostbird/wiki/TextEditorsKnownToWorkWith)
161+
* [Testing with various OSes](https://github.com/exteditor/ghostbird/wiki/OSesKnownToWorkWith)
162162
* Wiki pages for [user guides](https://github.com/exteditor/ghostbird/wiki/HowTo) and [troubleshooting](https://github.com/exteditor/ghostbird/wiki/Troubleshooting)
163163
* Developing the server counterpart so that this can be used as an External Editor replacement ([GhostText-Any](https://github.com/newsch/GhostText-Any/) or [Helix-Ghost][helix] can be a good starting point)
164164
* Creating a testing checklist for testing and debugging ([This page](https://github.com/exteditor/exteditor/wiki/Things-to-test) can be a good starting point)

doc/faq.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
### What text editors are supported?
2121

2222
* See [Requirements section in README.md](../README.md#requirements), but it isn't the official list. If your favorite editor isn't listed, try searching for it.
23-
* If you tried the add-on, please add your text editor to [the wiki page](https://github.com/exteditor/ghostbird/wiki/Text_editors_known_to_work_with).
23+
* If you tried the add-on, please add your favorite text editor to [the wiki page](https://github.com/exteditor/ghostbird/wiki/TextEditorsKnownToWorkWith) if it's not there.
2424

2525
### How do I install it?
2626

@@ -53,7 +53,7 @@
5353
<img width="400" height="194" title="profile-wide email format config" alt="profile-wide email format config" src="https://github.com/user-attachments/assets/cbbe7494-1cce-4da8-944f-f5b99d925de4" />
5454

5555
* You can set per-account option at `Account Setting`>`Composition & Addressing`>`Composition` section. Check or uncheck the `Compose messages in HTML format` checkbox.
56-
56+
5757
<img width="400" height="184" alt="per-account email format config" title="per-account email format config" src="https://github.com/user-attachments/assets/9305cec5-dc83-4893-8128-bdbaadaa9f6f" />
5858

5959
* After adjusting the option, you have to start a `New Message`.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"git-describe": "^4.1.1",
6565
"jsdom": "^26.1.0",
6666
"rolldown": "latest",
67-
"tsdown": "^0.14.1",
67+
"tsdown": "^0.15.1",
6868
"typedoc": "^0.28.12",
6969
"typedoc-plugin-markdown": "^4.8.1",
7070
"typedoc-plugin-mermaid": "^1.12.0",
@@ -75,5 +75,10 @@
7575
},
7676
"peerDependencies": {
7777
"@vitest/ui": "*"
78+
},
79+
"peerDependenciesMeta": {
80+
"@vitest/ui": {
81+
"optional": true
82+
}
7883
}
7984
}

tools/generate_manifest.ts

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,28 @@ import type { EmittedAsset, Plugin } from "rolldown"
33
import manifest from "../manifest_template.json" with { type: "json" }
44
import pkg from "../package.json" with { type: "json" }
55

6-
type VersionInfo = { version: string; envInfo: Record<string, string> | undefined }
6+
type VersionInfo = { version: string }
77

88
export type Options = { env?: undefined | Record<string, string> }
99

1010
/** Generates manifest.json from the template file */
1111
export const generateManifest = ({ env }: Options = {}): Plugin => ({
1212
name: "generate_manifest",
1313
async generateBundle(): Promise<void> {
14+
// manifest.json can be reused for reproducibility
15+
let existing = await this.resolve("./ext/manifest.json")
16+
if (existing) {
17+
this.info(`manifest.json already exists; skipping generation`)
18+
return
19+
}
20+
1421
this.info("Generating manifest.json")
15-
let { version, envInfo } = await getVersionInfo(env ?? {}).catch((e) => {
22+
let { version } = await getVersionInfo(env).catch((e) => {
1623
this.warn(e)
17-
return { version: "unknown", envInfo: undefined }
24+
this.warn(
25+
"Generating dummy version; Build from a Git clone or place your ext/manifest.json to use the real one instead",
26+
)
27+
return { version: `unknown-${Date.now()}-try-placing-your-manifest-json-in-ext-directory-before-build` }
1828
})
1929
let manifest = makeManifestJson(version)
2030

@@ -24,14 +34,6 @@ export const generateManifest = ({ env }: Options = {}): Plugin => ({
2434
originalFileName: "manifest_template.json",
2535
source: manifest,
2636
} satisfies EmittedAsset)
27-
28-
if (envInfo) {
29-
this.emitFile({
30-
type: "asset",
31-
fileName: "env.yarn",
32-
source: listEnv(envInfo),
33-
} satisfies EmittedAsset)
34-
}
3537
},
3638
})
3739

@@ -47,43 +49,33 @@ function makeManifestJson(version: string): string {
4749
return JSON.stringify(contents, undefined, 2)
4850
}
4951

50-
async function getVersionInfo(envInfo: Record<string, string>): Promise<VersionInfo> {
51-
let { GITHUB_REF_NAME: refName, GITHUB_SHA: sha, GITHUB_REF_TYPE: refType } = envInfo
52+
async function getVersionInfo(envInfo: undefined | Record<string, string>): Promise<VersionInfo> {
53+
let { GITHUB_REF_NAME: refName, GITHUB_SHA: sha, GITHUB_REF_TYPE: refType } = envInfo ?? {}
5254

5355
// Use version info from env if available
5456
if (refName && sha && refType) {
5557
if (refType === "tag" && refName.startsWith("v")) {
5658
// this is a release build
57-
return { version: refName.slice(1), envInfo }
59+
let version = appendSha(refName.slice(1), sha)
60+
return { version }
5861
} else {
5962
// this is a nightly build
60-
return { version: `nightly-${refName}-${sha}`, envInfo }
63+
return { version: `nightly-${refName}-${sha}` }
6164
}
6265
}
6366

6467
// Query git for local build
65-
let { semverString } = await gitDescribe({
68+
let { semverString, hash, distance } = await gitDescribe({
6669
customArguments: ["--abbrev=16"],
6770
})
6871
if (!semverString) {
6972
throw Error("couldn't get the version from git")
7073
}
71-
return { version: semverString, envInfo: undefined }
74+
let version = distance === 0 ? appendSha(semverString, hash.slice(1)) : semverString
75+
76+
return { version }
7277
}
7378

74-
function listEnv(envInfo: Record<string, string>): string {
75-
let keys = new Set([
76-
"CI",
77-
"GITHUB_REF_NAME",
78-
"GITHUB_SHA",
79-
"GITHUB_REF_TYPE",
80-
"GITHUB_SERVER_URL",
81-
"GITHUB_REPOSITORY",
82-
"GITHUB_RUN_ID",
83-
])
84-
return Object.entries(envInfo)
85-
.filter((pair) => keys.has(pair[0]))
86-
.sort()
87-
.map((pair) => pair.join("="))
88-
.join("\n")
79+
function appendSha(version: string, sha: string): string {
80+
return `${version}.${parseInt(sha.slice(0, 7), 16)}`
8981
}

tools/tsdown_config.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
import { existsSync } from "node:fs"
21-
import { dirname, resolve } from "node:path"
21+
import { dirname, join, resolve } from "node:path"
2222
import { env } from "node:process"
2323
import type { Options, UserConfig } from "tsdown"
2424
import { barrelsby } from "./barrelsby"
@@ -33,23 +33,19 @@ export default (): UserConfig => {
3333
]
3434
}
3535

36-
const isRelease = env.CI === "true"
36+
const isRelease = env.CI === "true" || existsSync(join(__dirname, "..", "ext", "manifest.json"))
3737

3838
const commonConfig = {
3939
outDir: "dist/ext/",
4040
tsconfig: "src/root/tsconfig.json",
4141
ignoreWatch: [/[/](?:[.]|build[/]|dist[/])/i, /index[.]ts$/i],
4242
platform: "browser",
43-
// Corresponds to Thunderbird 128 ESR
44-
target: "firefox128",
43+
// Corresponds to Thunderbird 140 ESR
44+
target: "firefox140",
4545
sourcemap: true,
4646
// We don't remove whitespaces for people like me who enjoy unpacking xpis and reading the content.
4747
// We still bundle because it reduces the number of files to check.
48-
minify: {
49-
compress: false,
50-
mangle: false,
51-
removeWhitespace: false,
52-
},
48+
minify: "dce-only",
5349
define: {
5450
// Remove in-source tests
5551
"import.meta.vitest": "undefined",

0 commit comments

Comments
 (0)