build: Implement cross-platform build info script

This commit is contained in:
Elian Doran 2024-07-21 11:45:31 +03:00
parent 374a51b77c
commit d09578735e
No known key found for this signature in database
6 changed files with 38 additions and 12 deletions

View File

@ -26,7 +26,7 @@ jobs:
cache: "npm"
- run: npm ci
- run: |
./bin/update-build-info.sh
npm run update-build-info
./bin/build-mac-x64.sh
- uses: actions/upload-artifact@v4
with:
@ -44,7 +44,7 @@ jobs:
cache: "npm"
- run: npm ci
- run: |
./bin/update-build-info.sh
npm run update-build-info
./bin/build-mac-arm64.sh
- uses: actions/upload-artifact@v4
with:
@ -62,7 +62,7 @@ jobs:
cache: "npm"
- run: npm ci
- run: |
./bin/update-build-info.sh
npm run update-build-info
./bin/build-linux-x64.sh
- uses: actions/upload-artifact@v4
with:
@ -84,7 +84,7 @@ jobs:
cache: "npm"
- run: npm ci
- run: |
./bin/update-build-info.sh
npm run update-build-info
./bin/build-server.sh
- uses: actions/upload-artifact@v4
with:
@ -109,7 +109,7 @@ jobs:
cache: "npm"
- run: npm ci
- run: |
./bin/update-build-info.sh
npm run update-build-info
./bin/build-win-x64.sh DONTPACK
- uses: actions/upload-artifact@v4
with:
@ -128,7 +128,7 @@ jobs:
- run: npm ci
- name: Run installer build
run: |
./bin/update-build-info.sh
npm run update-build-info
npm run make-electron
- name: Publish installer artifact
uses: actions/upload-artifact@v4

View File

@ -32,7 +32,7 @@ mv package.json.tmp package.json
git add package.json
./update-build-info.sh
npm run update-build-info
git add src/services/build.ts

View File

@ -1,3 +0,0 @@
#!/usr/bin/env bash
echo 'export = { buildDate:"'`date --iso-8601=seconds`'", buildRevision: "'`git log -1 --format="%H"`'" };' > src/services/build.ts

25
bin/update-build-info.ts Normal file
View File

@ -0,0 +1,25 @@
import child_process from "child_process";
import fs from "fs";
function getBuildDate() {
const now = new Date();
now.setMilliseconds(0);
return now
.toISOString()
.replace(".000", "");
}
function getGitRevision() {
return child_process.execSync('git log -1 --format="%H"')
.toString("utf-8")
.trimEnd();
}
const output = `\
export = {
buildDate: "${getBuildDate()}",
buildRevision: "${getGitRevision()}"
};
`;
fs.writeFileSync("src/services/build.ts", output);

View File

@ -40,7 +40,8 @@
"start-electron-forge": "npm run prepare-dist && electron-forge start",
"make-electron": "npm run webpack && npm run prepare-dist && electron-forge make",
"package-electron": "electron-forge package",
"prepare-dist": "rimraf ./dist && tsc && ts-node ./bin/copy-dist.ts"
"prepare-dist": "rimraf ./dist && tsc && ts-node ./bin/copy-dist.ts",
"update-build-info": "ts-node bin/update-build-info.ts"
},
"dependencies": {
"@braintree/sanitize-url": "^7.1.0",

View File

@ -1 +1,4 @@
export = { buildDate:"2024-07-14T22:32:45+03:00", buildRevision: "b811f3d399aed7e740bd8e92ef7edc7d15de7038" };
export = {
buildDate: "2024-07-21T08:44:01Z",
buildRevision: "374a51b77c35f5ff2e619b49f1e7aeda16005945"
};