Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit d095787

Browse files
committed
build: Implement cross-platform build info script
1 parent 374a51b commit d095787

File tree

6 files changed

+38
-12
lines changed

6 files changed

+38
-12
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
cache: "npm"
2727
- run: npm ci
2828
- run: |
29-
./bin/update-build-info.sh
29+
npm run update-build-info
3030
./bin/build-mac-x64.sh
3131
- uses: actions/upload-artifact@v4
3232
with:
@@ -44,7 +44,7 @@ jobs:
4444
cache: "npm"
4545
- run: npm ci
4646
- run: |
47-
./bin/update-build-info.sh
47+
npm run update-build-info
4848
./bin/build-mac-arm64.sh
4949
- uses: actions/upload-artifact@v4
5050
with:
@@ -62,7 +62,7 @@ jobs:
6262
cache: "npm"
6363
- run: npm ci
6464
- run: |
65-
./bin/update-build-info.sh
65+
npm run update-build-info
6666
./bin/build-linux-x64.sh
6767
- uses: actions/upload-artifact@v4
6868
with:
@@ -84,7 +84,7 @@ jobs:
8484
cache: "npm"
8585
- run: npm ci
8686
- run: |
87-
./bin/update-build-info.sh
87+
npm run update-build-info
8888
./bin/build-server.sh
8989
- uses: actions/upload-artifact@v4
9090
with:
@@ -109,7 +109,7 @@ jobs:
109109
cache: "npm"
110110
- run: npm ci
111111
- run: |
112-
./bin/update-build-info.sh
112+
npm run update-build-info
113113
./bin/build-win-x64.sh DONTPACK
114114
- uses: actions/upload-artifact@v4
115115
with:
@@ -128,7 +128,7 @@ jobs:
128128
- run: npm ci
129129
- name: Run installer build
130130
run: |
131-
./bin/update-build-info.sh
131+
npm run update-build-info
132132
npm run make-electron
133133
- name: Publish installer artifact
134134
uses: actions/upload-artifact@v4

bin/release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ mv package.json.tmp package.json
3232

3333
git add package.json
3434

35-
./update-build-info.sh
35+
npm run update-build-info
3636

3737
git add src/services/build.ts
3838

bin/update-build-info.sh

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

bin/update-build-info.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import child_process from "child_process";
2+
import fs from "fs";
3+
4+
function getBuildDate() {
5+
const now = new Date();
6+
now.setMilliseconds(0);
7+
return now
8+
.toISOString()
9+
.replace(".000", "");
10+
}
11+
12+
function getGitRevision() {
13+
return child_process.execSync('git log -1 --format="%H"')
14+
.toString("utf-8")
15+
.trimEnd();
16+
}
17+
18+
const output = `\
19+
export = {
20+
buildDate: "${getBuildDate()}",
21+
buildRevision: "${getGitRevision()}"
22+
};
23+
`;
24+
25+
fs.writeFileSync("src/services/build.ts", output);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"start-electron-forge": "npm run prepare-dist && electron-forge start",
4141
"make-electron": "npm run webpack && npm run prepare-dist && electron-forge make",
4242
"package-electron": "electron-forge package",
43-
"prepare-dist": "rimraf ./dist && tsc && ts-node ./bin/copy-dist.ts"
43+
"prepare-dist": "rimraf ./dist && tsc && ts-node ./bin/copy-dist.ts",
44+
"update-build-info": "ts-node bin/update-build-info.ts"
4445
},
4546
"dependencies": {
4647
"@braintree/sanitize-url": "^7.1.0",

src/services/build.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
export = { buildDate:"2024-07-14T22:32:45+03:00", buildRevision: "b811f3d399aed7e740bd8e92ef7edc7d15de7038" };
1+
export = {
2+
buildDate: "2024-07-21T08:44:01Z",
3+
buildRevision: "374a51b77c35f5ff2e619b49f1e7aeda16005945"
4+
};

0 commit comments

Comments
 (0)