Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/update_ele…
Browse files Browse the repository at this point in the history
…ctron
  • Loading branch information
eliandoran committed Jul 21, 2024
2 parents 338012e + 4edb037 commit 62804ec
Show file tree
Hide file tree
Showing 19 changed files with 8,339 additions and 17,601 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: Dev
on:
push:
branches:
- '!develop'
- '!feature/update*'
branches-ignore:
- 'develop'
- 'feature/update**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build_docker:
name: Build Docker image
Expand Down
50 changes: 43 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ on:
branches:
- 'develop'
- 'feature/update*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build_darwin-x64:
name: Build macOS x86_64
Expand All @@ -19,7 +25,9 @@ jobs:
node-version: 20
cache: "npm"
- run: npm ci
- run: ./bin/build-mac-x64.sh
- run: |
npm run update-build-info
./bin/build-mac-x64.sh
- uses: actions/upload-artifact@v4
with:
name: trilium-mac-x64.zip
Expand All @@ -35,7 +43,9 @@ jobs:
node-version: 20
cache: "npm"
- run: npm ci
- run: ./bin/build-mac-arm64.sh
- run: |
npm run update-build-info
./bin/build-mac-arm64.sh
- uses: actions/upload-artifact@v4
with:
name: trilium-mac-arm64.zip
Expand All @@ -51,7 +61,9 @@ jobs:
node-version: 20
cache: "npm"
- run: npm ci
- run: ./bin/build-linux-x64.sh
- run: |
npm run update-build-info
./bin/build-linux-x64.sh
- uses: actions/upload-artifact@v4
with:
name: trilium-linux-x64.tar.xz
Expand All @@ -71,7 +83,9 @@ jobs:
node-version: 20
cache: "npm"
- run: npm ci
- run: ./bin/build-server.sh
- run: |
npm run update-build-info
./bin/build-server.sh
- uses: actions/upload-artifact@v4
with:
name: trilium-linux-x64-server.tar.xz
Expand All @@ -94,11 +108,33 @@ jobs:
node-version: 20
cache: "npm"
- run: npm ci
- run: ./bin/build-win-x64.sh
- run: |
npm run update-build-info
./bin/build-win-x64.sh DONTPACK
- uses: actions/upload-artifact@v4
with:
name: trilium-windows-x64.zip
path: dist/trilium-windows-x64-*.zip
name: trilium-windows-x64
path: dist/trilium-windows-x64
build_windows-installer:
name: Build Windows x86_64 (Setup)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Set up node & dependencies
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
- run: npm ci
- name: Run installer build
run: |
npm run update-build-info
npm run make-electron
- name: Publish installer artifact
uses: actions/upload-artifact@v4
with:
name: TriliumNext Notes for Windows (Setup)
path: out/make/squirrel.windows/x64/*.exe
build_docker:
name: Build Docker image
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ data/
data-test/
tmp/
.eslintcache

out/
2 changes: 1 addition & 1 deletion bin/build-linux-x64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ echo "Packaging linux x64 electron build"
BUILD_DIR=./dist/trilium-linux-x64
rm -rf "$BUILD_DIR"

mv "./dist/Trilium Notes-linux-x64" "$BUILD_DIR"
mv "./dist/TriliumNext Notes-linux-x64" "$BUILD_DIR"

cp images/app-icons/png/128x128.png "$BUILD_DIR"/icon.png
cp bin/tpl/anonymize-database.sql "$BUILD_DIR"/
Expand Down
2 changes: 1 addition & 1 deletion bin/build-mac-arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ BUILD_DIR=./dist/trilium-mac-arm64
rm -rf $BUILD_DIR

# Mac build has by default useless directory level
mv "./dist/Trilium Notes-darwin-arm64" $BUILD_DIR
mv "./dist/TriliumNext Notes-darwin-arm64" $BUILD_DIR

cp bin/tpl/anonymize-database.sql $BUILD_DIR/

Expand Down
2 changes: 1 addition & 1 deletion bin/build-mac-x64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ BUILD_DIR=./dist/trilium-mac-x64
rm -rf $BUILD_DIR

# Mac build has by default useless directory level
mv "./dist/Trilium Notes-darwin-x64" $BUILD_DIR
mv "./dist/TriliumNext Notes-darwin-x64" $BUILD_DIR

cp bin/tpl/anonymize-database.sql $BUILD_DIR/

Expand Down
14 changes: 8 additions & 6 deletions bin/build-win-x64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ echo "Packaging windows x64 electron build"
BUILD_DIR=./dist/trilium-windows-x64
rm -rf $BUILD_DIR

mv "./dist/Trilium Notes-win32-x64" $BUILD_DIR
mv "./dist/TriliumNext Notes-win32-x64" $BUILD_DIR

cp bin/tpl/anonymize-database.sql $BUILD_DIR/

Expand All @@ -34,9 +34,11 @@ rm -rf $BUILD_DIR/dump-db/node_modules

cp bin/tpl/trilium-{portable,no-cert-check,safe-mode}.bat $BUILD_DIR/

echo "Zipping windows x64 electron distribution..."
VERSION=`jq -r ".version" package.json`

cd dist
if [ "$1" != "DONTPACK" ]
then
echo "Zipping windows x64 electron distribution..."
VERSION=`jq -r ".version" package.json`

zip -r9 trilium-windows-x64-${VERSION}.zip trilium-windows-x64
cd dist
zip -r9 trilium-windows-x64-${VERSION}.zip trilium-windows-x64
fi
27 changes: 18 additions & 9 deletions bin/copy-trilium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,36 @@ for f in 'package.json' 'package-lock.json' 'README.md' 'LICENSE' 'config-sample
cp "$f" "$DIR"/
done

# Patch package.json main
sed -i 's/.\/dist\/electron.js/electron.js/g' "$DIR/package.json"

script_dir=$(realpath $(dirname $0))
cp -Rv "$script_dir/../build/src" "$DIR"
cp -R "$script_dir/../build/src" "$DIR"
cp "$script_dir/../build/electron.js" "$DIR"

# run in subshell (so we return to original dir)
(cd $DIR && npm install --only=prod)
(cd $DIR && npm run switch-electron)
(cd $DIR && npm install --omit=dev)

if [[ -d "$DIR"/node_modules ]]; then
# cleanup of useless files in dependencies
for d in 'image-q/demo' 'better-sqlite3/Release' 'better-sqlite3/deps/sqlite3.tar.gz' '@jimp/plugin-print/fonts' 'jimp/browser' 'jimp/fonts'; do
[[ -e "$DIR"/node_modules/"$d" ]] && rm -rv "$DIR"/node_modules/"$d"
# cleanup of useless files in dependencies
for d in 'image-q/demo' \
'@excalidraw/excalidraw/dist/excalidraw-assets-dev' '@excalidraw/excalidraw/dist/excalidraw.development.js' '@excalidraw/excalidraw/dist/excalidraw-with-preact.development.js' \
'mermaid/dist/mermaid.js' \
'boxicons/svg' 'boxicons/node_modules/react'/* \
'better-sqlite3/Release' 'better-sqlite3/deps/sqlite3.tar.gz' 'better-sqlite3/deps/sqlite3' \
'@jimp/plugin-print/fonts' 'jimp/browser' 'jimp/fonts'; do
[[ -e "$DIR"/node_modules/"$d" ]] && rm -r "$DIR"/node_modules/"$d"
done

# delete all tests (there are often large images as test file for jimp etc.)
for d in 'test' 'docs' 'demo'; do
find "$DIR"/node_modules -name "$d" -exec rm -rf {} \;
# delete all tests (there are often large images as test file for jimp etc.)
for d in 'test' 'docs' 'demo' 'example'; do
find "$DIR"/node_modules -name "$d" -exec rm -rf {} +
done
fi

find $DIR/libraries -name "*.map" -type f -delete
find $DIR/node_modules -name "*.map" -type f -delete
find $DIR -name "*.ts" -type f -delete

d="$DIR"/src/public
[[ -d "$d"/app-dist ]] || mkdir -pv "$d"/app-dist
Expand Down
6 changes: 4 additions & 2 deletions bin/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mv package.json.tmp package.json

git add package.json

echo 'export = { buildDate:"'`date --iso-8601=seconds`'", buildRevision: "'`git log -1 --format="%H"`'" };' > src/services/build.ts
npm run update-build-info

git add src/services/build.ts

Expand Down Expand Up @@ -65,7 +65,9 @@ if [[ $TAG == *"beta"* ]]; then
EXTRA=--prerelease
fi

echo "$GITHUB_CLI_AUTH_TOKEN" | gh auth login --with-token
if [ ! -z "$GITHUB_CLI_AUTH_TOKEN" ]; then
echo "$GITHUB_CLI_AUTH_TOKEN" | gh auth login --with-token
fi

gh release create "$TAG" \
--title "$TAG release" \
Expand Down
25 changes: 25 additions & 0 deletions bin/update-build-info.ts
Original file line number Diff line number Diff line change
@@ -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);
5 changes: 5 additions & 0 deletions electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import appIconService = require("./src/services/app_icon");
import windowService = require("./src/services/window");
import tray = require("./src/services/tray");

// Prevent Trilium starting twice on first install and on uninstall for the Windows installer.
if (require('electron-squirrel-startup')) {
process.exit(0);
}

// Adds debug features like hotkeys for triggering dev tools and reload
require("electron-debug")();

Expand Down
23 changes: 23 additions & 0 deletions forge.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
packagerConfig: {
asar: true,
// icon will break once we add .dmg support, since the .ico & .icns have to be in same dir (see https://www.electronforge.io/guides/create-and-add-icons#windows-and-macos)
icon: "./images/app-icons/win/icon"
},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {
setupIcon: "./images/app-icons/win/icon.ico",
loadingGif: "./images/app-icons/win/setup-banner.gif"
}
}
],
plugins: [
{
name: '@electron-forge/plugin-auto-unpack-natives',
config: {},
},
],
};
Binary file added images/app-icons/win/setup-banner.gif
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 images/app-icons/win/setup-banner.xcf
Binary file not shown.
Loading

0 comments on commit 62804ec

Please sign in to comment.