From 947aaa61564775b8f15e62563f45b2eafe0dfeac Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 13 Jul 2024 21:10:40 +0300 Subject: [PATCH 1/9] webpack: Switch to TypeScript-based config --- package.json | 2 +- webpack.config.js => webpack.config.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename webpack.config.js => webpack.config.ts (82%) diff --git a/package.json b/package.json index e37e6204cc..e48bff6c27 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "build-backend-docs": "rm -rf ./docs/backend_api && ./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/backend_api src/becca/entities/*.js src/services/backend_script_api.js src/services/sql.js", "build-frontend-docs": "rm -rf ./docs/frontend_api && ./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/frontend_api src/public/app/entities/*.js src/public/app/services/frontend_script_api.js src/public/app/widgets/basic_widget.js src/public/app/widgets/note_context_aware_widget.js src/public/app/widgets/right_panel_widget.js", "build-docs": "npm run build-backend-docs && npm run build-frontend-docs", - "webpack": "webpack -c webpack.config.js", + "webpack": "webpack -c webpack.config.ts", "test-jasmine": "TRILIUM_DATA_DIR=~/trilium/data-test jasmine", "test-es6": "node -r esm spec-es6/attribute_parser.spec.js ", "test": "npm run test-jasmine && npm run test-es6", diff --git a/webpack.config.js b/webpack.config.ts similarity index 82% rename from webpack.config.js rename to webpack.config.ts index 41077c00e5..bd7135e249 100644 --- a/webpack.config.js +++ b/webpack.config.ts @@ -1,5 +1,5 @@ -const path = require('path'); -const assetPath = require('./src/services/asset_path'); +import path = require('path'); +import assetPath = require('./src/services/asset_path'); module.exports = { mode: 'production', From 5b30bae5b27675301df2cc9b409076be8d603c7a Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 13 Jul 2024 21:11:03 +0300 Subject: [PATCH 2/9] bin: Adapt copy-trilium to TypeScript changes --- bin/copy-trilium.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index 9fdfe0293f..8affb7be31 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +shopt -s globstar +set -e + if [[ $# -eq 0 ]] ; then echo "Missing argument of target directory" exit 1 @@ -9,25 +12,36 @@ if ! [[ $(which npm) ]]; then exit 1 fi -n exec 18.18.2 npm run webpack || npm run webpack +# Trigger the TypeScript build +echo TypeScript build start +npx tsc +echo TypeScript build finished +# Copy the TypeScript artifacts DIR="$1" - rm -rf "$DIR" mkdir -pv "$DIR" +echo Webpack start +npm run webpack +echo Webpack finish + echo "Copying Trilium to build directory $DIR" for d in 'images' 'libraries' 'src' 'db'; do cp -r "$d" "$DIR"/ done -for f in 'package.json' 'package-lock.json' 'README.md' 'LICENSE' 'config-sample.ini' 'electron.js'; do + +for f in 'package.json' 'package-lock.json' 'README.md' 'LICENSE' 'config-sample.ini'; do cp "$f" "$DIR"/ done -cp webpack-* "$DIR"/ # here warning because there is no 'webpack-*', but webpack.config.js only + +script_dir=$(realpath $(dirname $0)) +cp -Rv "$script_dir/../build/src" "$DIR" +cp "$script_dir/../build/electron.js" "$DIR" # run in subshell (so we return to original dir) -(cd $DIR && n exec 18.18.2 npm install --only=prod) +(cd $DIR && npm install --only=prod) if [[ -d "$DIR"/node_modules ]]; then # cleanup of useless files in dependencies From 7c43a49046acbee943509f4ba2a477fe87758f6a Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 13 Jul 2024 21:35:34 +0300 Subject: [PATCH 3/9] ci: Add workflow for building macOS x86_64 --- .github/workflows/dev.yml | 2 ++ .github/workflows/main.yml | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 392046d2c5..58e21d36ae 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -1,6 +1,8 @@ name: Dev on: push: + branches_ignore: + - 'feature/fix_build_scripts' jobs: build_docker: name: Build Docker image diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7474323969..5498558bef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,10 +3,27 @@ on: push: branches: - 'develop' + - 'feature/fix_build_scripts' env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} jobs: + build_macos_64: + name: Build macOS x86_64 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up node & dependencies + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: "npm" + - run: npm ci + - run: ./bin/build-mac-x64.sh + - uses: actions/upload-artifact@v4 + with: + name: trilium-mac-x64.zip + path: dist/trilium-mac-x64*.zip build_docker: name: Build Docker image runs-on: ubuntu-latest From e6ff99198f988247088d1e5ea3089ff4ad5b356c Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 13 Jul 2024 22:10:57 +0300 Subject: [PATCH 4/9] ci: Fix docker build after macOS integration --- .dockerignore | 3 ++- Dockerfile | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index 941905c66f..64bcb69833 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,4 +6,5 @@ /npm-debug.log node_modules -src/**/*.ts \ No newline at end of file +src/**/*.ts +!src/services/asset_path.ts \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index dfeb4a0d75..78f058529a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,7 +34,8 @@ RUN set -x \ && npm prune --omit=dev \ && cp src/public/app/share.js src/public/app-dist/. \ && cp -r src/public/app/doc_notes src/public/app-dist/. \ - && rm -rf src/public/app + && rm -rf src/public/app \ + && rm src/services/asset_path.ts # Some setup tools need to be kept RUN apk add --no-cache su-exec shadow From 99ea741275a3c06e715249b4ba625a64c803e231 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 13 Jul 2024 22:52:28 +0300 Subject: [PATCH 5/9] ci: Add build Linux --- .github/workflows/main.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5498558bef..eb6f548211 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} jobs: - build_macos_64: + build_darwin-x64: name: Build macOS x86_64 runs-on: ubuntu-latest steps: @@ -24,6 +24,26 @@ jobs: with: name: trilium-mac-x64.zip path: dist/trilium-mac-x64*.zip + build_linux-x64: + name: Build Linux x86_64 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up node & dependencies + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: "npm" + - run: npm ci + - run: ./bin/build-linux-x64.sh + - uses: actions/upload-artifact@v4 + with: + name: trilium-linux-x64.tar.xz + path: dist/trilium-linux-x64-*.tar.xz + - uses: actions/upload-artifact@v4 + with: + name: trilium_amd64.deb + path: dist/trilium_*.deb build_docker: name: Build Docker image runs-on: ubuntu-latest From 7aed6d4ad47fd1a220ca6dd8b7fdf636a41639d2 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 13 Jul 2024 23:16:00 +0300 Subject: [PATCH 6/9] ci: Add build Linux Server --- .github/workflows/main.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eb6f548211..d826bf63f9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,6 +44,22 @@ jobs: with: name: trilium_amd64.deb path: dist/trilium_*.deb + build_linux_server-x64: + name: Build Linux Server x86_64 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up node & dependencies + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: "npm" + - run: npm ci + - run: ./bin/build-server.sh + - uses: actions/upload-artifact@v4 + with: + name: trilium-linux-x64-server-x64.tar.xz + path: dist/trilium-linux-x64-server-*.tar.xz build_docker: name: Build Docker image runs-on: ubuntu-latest From 998db5ce95aead5427e51b1a9954c567a06c9dd0 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 13 Jul 2024 23:23:37 +0300 Subject: [PATCH 7/9] ci: Add build Windows --- .github/workflows/main.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d826bf63f9..ba4f6052a1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -58,8 +58,24 @@ jobs: - run: ./bin/build-server.sh - uses: actions/upload-artifact@v4 with: - name: trilium-linux-x64-server-x64.tar.xz + name: trilium-linux-x64-server.tar.xz path: dist/trilium-linux-x64-server-*.tar.xz + build_windows-x64: + name: Build Windows x86_64 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up node & dependencies + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: "npm" + - run: npm ci + - run: ./bin/build-win-x64.sh + - uses: actions/upload-artifact@v4 + with: + name: trilium-windows-x64.zip + path: dist/trilium-windows-x64-*.zip build_docker: name: Build Docker image runs-on: ubuntu-latest From 3f5e5fd840cc035ccc55717e8ea2f3649a9c579c Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 14 Jul 2024 00:28:30 +0300 Subject: [PATCH 8/9] ci: Set up Wine --- .github/workflows/main.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ba4f6052a1..6f1269a708 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -64,6 +64,13 @@ jobs: name: Build Windows x86_64 runs-on: ubuntu-latest steps: + - name: Set up Wine + run: | + sudo dpkg --add-architecture i386 + wget -qO - https://dl.winehq.org/wine-builds/winehq.key | sudo apt-key add - + sudo add-apt-repository ppa:cybermax-dexter/sdl2-backport + sudo apt-add-repository "deb https://dl.winehq.org/wine-builds/ubuntu $(lsb_release -cs) main" + sudo apt install --install-recommends winehq-stable - uses: actions/checkout@v4 - name: Set up node & dependencies uses: actions/setup-node@v4 From 75ebe24abbc84af0a6fb47e23bcc298d129dd97e Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 14 Jul 2024 00:43:04 +0300 Subject: [PATCH 9/9] ci: Remove temporary branch config --- .github/workflows/dev.yml | 2 -- .github/workflows/main.yml | 1 - 2 files changed, 3 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 58e21d36ae..392046d2c5 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -1,8 +1,6 @@ name: Dev on: push: - branches_ignore: - - 'feature/fix_build_scripts' jobs: build_docker: name: Build Docker image diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6f1269a708..529e685e9a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,7 +3,6 @@ on: push: branches: - 'develop' - - 'feature/fix_build_scripts' env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }}