Skip to content

Commit cfccf29

Browse files
authored
Merge pull request #1773 from TriliumNext/feature/nx_monorepo
Set up NX-based monorepo
2 parents 308bbd1 + 81ebbb9 commit cfccf29

File tree

2,130 files changed

+30147
-35097
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,130 files changed

+30147
-35097
lines changed

.gitattributes

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package-lock.json linguist-generated=true
22
**/package-lock.json linguist-generated=true
3-
src/public/app/doc_notes/en/User[[:space:]]Guide/** linguist-generated=true
4-
src/public/app/doc_notes/en/User[[:space:]]Guide/**/*.md eol=lf
3+
4+
apps/server/src/assets/doc_notes/en/User[[:space:]]Guide/** linguist-generated=true
5+
apps/server/src/assets/doc_notes/en/User[[:space:]]Guide/**/*.html eol=lf
6+
7+
docs/**/*.md eol=lf
8+
docs/**/*.json eol=lf
59

610
demo/**/*.html eol=lf
711
demo/**/*.json eol=lf
@@ -10,4 +14,4 @@ demo/**/*.txt eol=lf
1014
demo/**/*.js eol=lf
1115
demo/**/*.css eol=lf
1216

13-
libraries/** linguist-vendored
17+
apps/client/src/libraries/** linguist-vendored

.github/actions/build-electron/action.yml

+143-148
Original file line numberDiff line numberDiff line change
@@ -18,152 +18,147 @@ inputs:
1818
runs:
1919
using: composite
2020
steps:
21-
# Certificate setup
22-
- name: Import Apple certificates
23-
if: inputs.os == 'macos'
24-
uses: apple-actions/import-codesign-certs@v5
25-
with:
26-
p12-file-base64: ${{ env.APPLE_APP_CERTIFICATE_BASE64 }}
27-
p12-password: ${{ env.APPLE_APP_CERTIFICATE_PASSWORD }}
28-
keychain: build-app-${{ github.run_id }}
29-
keychain-password: ${{ github.run_id }}
30-
31-
- name: Install Installer certificate
32-
if: inputs.os == 'macos'
33-
uses: apple-actions/import-codesign-certs@v5
34-
with:
35-
p12-file-base64: ${{ env.APPLE_INSTALLER_CERTIFICATE_BASE64 }}
36-
p12-password: ${{ env.APPLE_INSTALLER_CERTIFICATE_PASSWORD }}
37-
keychain: build-installer-${{ github.run_id }}
38-
keychain-password: ${{ github.run_id }}
39-
40-
- name: Verify certificates
41-
if: inputs.os == 'macos'
42-
shell: ${{ inputs.shell }}
43-
run: |
44-
echo "Available signing identities in app keychain:"
45-
security find-identity -v -p codesigning build-app-${{ github.run_id }}.keychain
46-
47-
echo "Available signing identities in installer keychain:"
48-
security find-identity -v -p codesigning build-installer-${{ github.run_id }}.keychain
49-
50-
# Make the keychains searchable
51-
security list-keychains -d user -s build-app-${{ github.run_id }}.keychain build-installer-${{ github.run_id }}.keychain $(security list-keychains -d user | tr -d '"')
52-
security default-keychain -s build-app-${{ github.run_id }}.keychain
53-
security unlock-keychain -p ${{ github.run_id }} build-app-${{ github.run_id }}.keychain
54-
security unlock-keychain -p ${{ github.run_id }} build-installer-${{ github.run_id }}.keychain
55-
security set-keychain-settings -t 3600 -l build-app-${{ github.run_id }}.keychain
56-
security set-keychain-settings -t 3600 -l build-installer-${{ github.run_id }}.keychain
57-
58-
- name: Set up Python and other macOS dependencies
59-
if: ${{ inputs.os == 'macos' }}
60-
shell: ${{ inputs.shell }}
61-
run: |
62-
brew install python-setuptools
63-
brew install create-dmg
64-
65-
- name: Install dependencies for RPM and Flatpak package building
66-
if: ${{ inputs.os == 'linux' }}
67-
shell: ${{ inputs.shell }}
68-
run: |
69-
sudo apt-get update && sudo apt-get install rpm flatpak-builder elfutils
70-
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
71-
FLATPAK_ARCH=$(if [[ ${{ inputs.arch }} = 'arm64' ]]; then echo 'aarch64'; else echo 'x86_64'; fi)
72-
FLATPAK_VERSION='24.08'
73-
flatpak install --user --no-deps --arch $FLATPAK_ARCH --assumeyes runtime/org.freedesktop.Platform/$FLATPAK_ARCH/$FLATPAK_VERSION runtime/org.freedesktop.Sdk/$FLATPAK_ARCH/$FLATPAK_VERSION org.electronjs.Electron2.BaseApp/$FLATPAK_ARCH/$FLATPAK_VERSION
74-
75-
# Build setup
76-
- name: Install dependencies
77-
shell: ${{ inputs.shell }}
78-
run: npm ci
79-
80-
- name: Update build info
81-
shell: ${{ inputs.shell }}
82-
run: npm run chore:update-build-info
83-
84-
# Critical debugging configuration
85-
- name: Run electron-forge build with enhanced logging
86-
shell: ${{ inputs.shell }}
87-
env:
88-
# Pass through required environment variables for signing and notarization
89-
APPLE_TEAM_ID: ${{ env.APPLE_TEAM_ID }}
90-
APPLE_ID: ${{ env.APPLE_ID }}
91-
APPLE_ID_PASSWORD: ${{ env.APPLE_ID_PASSWORD }}
92-
WINDOWS_SIGN_EXECUTABLE: ${{ env.WINDOWS_SIGN_EXECUTABLE }}
93-
TRILIUM_ARTIFACT_NAME_HINT: TriliumNextNotes-${{ github.ref_name }}-${{ inputs.os }}-${{ inputs.arch }}
94-
run: npm run electron-forge:make -- --arch=${{ inputs.arch }} --platform=${{ inputs.forge_platform }}
95-
96-
# Add DMG signing step
97-
- name: Sign DMG
98-
if: inputs.os == 'macos'
99-
shell: ${{ inputs.shell }}
100-
run: |
101-
echo "Signing DMG file..."
102-
dmg_file=$(find ./dist -name "*.dmg" -print -quit)
103-
if [ -n "$dmg_file" ]; then
104-
echo "Found DMG: $dmg_file"
105-
# Get the first valid signing identity from the keychain
106-
SIGNING_IDENTITY=$(security find-identity -v -p codesigning build-app-${{ github.run_id }}.keychain | grep "Developer ID Application" | head -1 | sed -E 's/.*"([^"]+)".*/\1/')
107-
if [ -z "$SIGNING_IDENTITY" ]; then
108-
echo "Error: No valid Developer ID Application certificate found in keychain"
109-
exit 1
110-
fi
111-
echo "Using signing identity: $SIGNING_IDENTITY"
112-
# Sign the DMG
113-
codesign --force --sign "$SIGNING_IDENTITY" --options runtime --timestamp "$dmg_file"
114-
# Notarize the DMG
115-
xcrun notarytool submit "$dmg_file" --apple-id "$APPLE_ID" --password "$APPLE_ID_PASSWORD" --team-id "$APPLE_TEAM_ID" --wait
116-
# Staple the notarization ticket
117-
xcrun stapler staple "$dmg_file"
118-
else
119-
echo "No DMG found to sign"
120-
fi
121-
122-
- name: Verify code signing
123-
if: inputs.os == 'macos'
124-
shell: ${{ inputs.shell }}
125-
run: |
126-
echo "Verifying code signing for all artifacts..."
127-
128-
# First check the .app bundle
129-
echo "Looking for .app bundle..."
130-
app_bundle=$(find ./dist -name "*.app" -print -quit)
131-
if [ -n "$app_bundle" ]; then
132-
echo "Found app bundle: $app_bundle"
133-
echo "Verifying app bundle signing..."
134-
codesign --verify --deep --strict --verbose=2 "$app_bundle"
135-
echo "Displaying app bundle signing info..."
136-
codesign --display --verbose=2 "$app_bundle"
137-
138-
echo "Checking entitlements..."
139-
codesign --display --entitlements :- "$app_bundle"
140-
141-
echo "Checking notarization status..."
142-
xcrun stapler validate "$app_bundle" || echo "Warning: App bundle not notarized yet"
143-
else
144-
echo "No .app bundle found to verify"
145-
fi
146-
147-
# Then check DMG if it exists
148-
echo "Looking for DMG..."
149-
dmg_file=$(find ./dist -name "*.dmg" -print -quit)
150-
if [ -n "$dmg_file" ]; then
151-
echo "Found DMG: $dmg_file"
152-
echo "Verifying DMG signing..."
153-
codesign --verify --deep --strict --verbose=2 "$dmg_file"
154-
echo "Displaying DMG signing info..."
155-
codesign --display --verbose=2 "$dmg_file"
156-
157-
echo "Checking DMG notarization..."
158-
xcrun stapler validate "$dmg_file" || echo "Warning: DMG not notarized yet"
159-
else
160-
echo "No DMG found to verify"
161-
fi
162-
163-
# Finally check ZIP if it exists
164-
echo "Looking for ZIP..."
165-
zip_file=$(find ./dist -name "*.zip" -print -quit)
166-
if [ -n "$zip_file" ]; then
167-
echo "Found ZIP: $zip_file"
168-
echo "Note: ZIP files are not code signed, but their contents should be"
21+
# Certificate setup
22+
- name: Import Apple certificates
23+
if: inputs.os == 'macos'
24+
uses: apple-actions/import-codesign-certs@v5
25+
with:
26+
p12-file-base64: ${{ env.APPLE_APP_CERTIFICATE_BASE64 }}
27+
p12-password: ${{ env.APPLE_APP_CERTIFICATE_PASSWORD }}
28+
keychain: build-app-${{ github.run_id }}
29+
keychain-password: ${{ github.run_id }}
30+
31+
- name: Install Installer certificate
32+
if: inputs.os == 'macos'
33+
uses: apple-actions/import-codesign-certs@v5
34+
with:
35+
p12-file-base64: ${{ env.APPLE_INSTALLER_CERTIFICATE_BASE64 }}
36+
p12-password: ${{ env.APPLE_INSTALLER_CERTIFICATE_PASSWORD }}
37+
keychain: build-installer-${{ github.run_id }}
38+
keychain-password: ${{ github.run_id }}
39+
40+
- name: Verify certificates
41+
if: inputs.os == 'macos'
42+
shell: ${{ inputs.shell }}
43+
run: |
44+
echo "Available signing identities in app keychain:"
45+
security find-identity -v -p codesigning build-app-${{ github.run_id }}.keychain
46+
47+
echo "Available signing identities in installer keychain:"
48+
security find-identity -v -p codesigning build-installer-${{ github.run_id }}.keychain
49+
50+
# Make the keychains searchable
51+
security list-keychains -d user -s build-app-${{ github.run_id }}.keychain build-installer-${{ github.run_id }}.keychain $(security list-keychains -d user | tr -d '"')
52+
security default-keychain -s build-app-${{ github.run_id }}.keychain
53+
security unlock-keychain -p ${{ github.run_id }} build-app-${{ github.run_id }}.keychain
54+
security unlock-keychain -p ${{ github.run_id }} build-installer-${{ github.run_id }}.keychain
55+
security set-keychain-settings -t 3600 -l build-app-${{ github.run_id }}.keychain
56+
security set-keychain-settings -t 3600 -l build-installer-${{ github.run_id }}.keychain
57+
58+
- name: Set up Python and other macOS dependencies
59+
if: ${{ inputs.os == 'macos' }}
60+
shell: ${{ inputs.shell }}
61+
run: |
62+
brew install python-setuptools
63+
brew install create-dmg
64+
65+
- name: Install dependencies for RPM and Flatpak package building
66+
if: ${{ inputs.os == 'linux' }}
67+
shell: ${{ inputs.shell }}
68+
run: |
69+
sudo apt-get update && sudo apt-get install rpm flatpak-builder elfutils
70+
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
71+
FLATPAK_ARCH=$(if [[ ${{ inputs.arch }} = 'arm64' ]]; then echo 'aarch64'; else echo 'x86_64'; fi)
72+
FLATPAK_VERSION='24.08'
73+
flatpak install --user --no-deps --arch $FLATPAK_ARCH --assumeyes runtime/org.freedesktop.Platform/$FLATPAK_ARCH/$FLATPAK_VERSION runtime/org.freedesktop.Sdk/$FLATPAK_ARCH/$FLATPAK_VERSION org.electronjs.Electron2.BaseApp/$FLATPAK_ARCH/$FLATPAK_VERSION
74+
75+
- name: Update build info
76+
shell: ${{ inputs.shell }}
77+
run: npm run chore:update-build-info
78+
79+
# Critical debugging configuration
80+
- name: Run electron-forge build with enhanced logging
81+
shell: ${{ inputs.shell }}
82+
env:
83+
# Pass through required environment variables for signing and notarization
84+
APPLE_TEAM_ID: ${{ env.APPLE_TEAM_ID }}
85+
APPLE_ID: ${{ env.APPLE_ID }}
86+
APPLE_ID_PASSWORD: ${{ env.APPLE_ID_PASSWORD }}
87+
WINDOWS_SIGN_EXECUTABLE: ${{ env.WINDOWS_SIGN_EXECUTABLE }}
88+
TRILIUM_ARTIFACT_NAME_HINT: TriliumNextNotes-${{ github.ref_name }}-${{ inputs.os }}-${{ inputs.arch }}
89+
run: pnpm nx --project=desktop electron-forge:make -- --arch=${{ inputs.arch }} --platform=${{ inputs.forge_platform }}
90+
91+
# Add DMG signing step
92+
- name: Sign DMG
93+
if: inputs.os == 'macos'
94+
shell: ${{ inputs.shell }}
95+
run: |
96+
echo "Signing DMG file..."
97+
dmg_file=$(find ./apps/desktop/dist -name "*.dmg" -print -quit)
98+
if [ -n "$dmg_file" ]; then
99+
echo "Found DMG: $dmg_file"
100+
# Get the first valid signing identity from the keychain
101+
SIGNING_IDENTITY=$(security find-identity -v -p codesigning build-app-${{ github.run_id }}.keychain | grep "Developer ID Application" | head -1 | sed -E 's/.*"([^"]+)".*/\1/')
102+
if [ -z "$SIGNING_IDENTITY" ]; then
103+
echo "Error: No valid Developer ID Application certificate found in keychain"
104+
exit 1
169105
fi
106+
echo "Using signing identity: $SIGNING_IDENTITY"
107+
# Sign the DMG
108+
codesign --force --sign "$SIGNING_IDENTITY" --options runtime --timestamp "$dmg_file"
109+
# Notarize the DMG
110+
xcrun notarytool submit "$dmg_file" --apple-id "$APPLE_ID" --password "$APPLE_ID_PASSWORD" --team-id "$APPLE_TEAM_ID" --wait
111+
# Staple the notarization ticket
112+
xcrun stapler staple "$dmg_file"
113+
else
114+
echo "No DMG found to sign"
115+
fi
116+
117+
- name: Verify code signing
118+
if: inputs.os == 'macos'
119+
shell: ${{ inputs.shell }}
120+
run: |
121+
echo "Verifying code signing for all artifacts..."
122+
123+
# First check the .app bundle
124+
echo "Looking for .app bundle..."
125+
app_bundle=$(find ./apps/desktop/dist -name "*.app" -print -quit)
126+
if [ -n "$app_bundle" ]; then
127+
echo "Found app bundle: $app_bundle"
128+
echo "Verifying app bundle signing..."
129+
codesign --verify --deep --strict --verbose=2 "$app_bundle"
130+
echo "Displaying app bundle signing info..."
131+
codesign --display --verbose=2 "$app_bundle"
132+
133+
echo "Checking entitlements..."
134+
codesign --display --entitlements :- "$app_bundle"
135+
136+
echo "Checking notarization status..."
137+
xcrun stapler validate "$app_bundle" || echo "Warning: App bundle not notarized yet"
138+
else
139+
echo "No .app bundle found to verify"
140+
fi
141+
142+
# Then check DMG if it exists
143+
echo "Looking for DMG..."
144+
dmg_file=$(find ./apps/desktop/dist -name "*.dmg" -print -quit)
145+
if [ -n "$dmg_file" ]; then
146+
echo "Found DMG: $dmg_file"
147+
echo "Verifying DMG signing..."
148+
codesign --verify --deep --strict --verbose=2 "$dmg_file"
149+
echo "Displaying DMG signing info..."
150+
codesign --display --verbose=2 "$dmg_file"
151+
152+
echo "Checking DMG notarization..."
153+
xcrun stapler validate "$dmg_file" || echo "Warning: DMG not notarized yet"
154+
else
155+
echo "No DMG found to verify"
156+
fi
157+
158+
# Finally check ZIP if it exists
159+
echo "Looking for ZIP..."
160+
zip_file=$(find ./apps/desktop/dist -name "*.zip" -print -quit)
161+
if [ -n "$zip_file" ]; then
162+
echo "Found ZIP: $zip_file"
163+
echo "Note: ZIP files are not code signed, but their contents should be"
164+
fi

.github/actions/build-server/action.yml

+23-22
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,26 @@ inputs:
88
runs:
99
using: composite
1010
steps:
11-
- name: Set up node & dependencies
12-
uses: actions/setup-node@v4
13-
with:
14-
node-version: 22
15-
cache: "npm"
16-
- name: Install dependencies
17-
shell: bash
18-
run: npm ci
19-
- name: Run Linux server build
20-
env:
21-
MATRIX_ARCH: ${{ inputs.arch }}
22-
shell: bash
23-
run: |
24-
npm run chore:update-build-info
25-
./bin/build-server.sh
26-
- name: Prepare artifacts
27-
shell: bash
28-
run: |
29-
mkdir -p upload
30-
file=$(find dist -name '*.tar.xz' -print -quit)
31-
name=${{ github.ref_name }}
32-
cp "$file" "upload/TriliumNextNotes-Server-${name//\//-}-${{ inputs.os }}-${{ inputs.arch }}.tar.xz"
11+
- uses: pnpm/action-setup@v4
12+
- name: Set up node & dependencies
13+
uses: actions/setup-node@v4
14+
with:
15+
node-version: 22
16+
cache: "pnpm"
17+
- name: Install dependencies
18+
shell: bash
19+
run: pnpm install --frozen-lockfile
20+
- name: Run Linux server build
21+
env:
22+
MATRIX_ARCH: ${{ inputs.arch }}
23+
shell: bash
24+
run: |
25+
pnpm run chore:update-build-info
26+
pnpm nx --project=server package
27+
- name: Prepare artifacts
28+
shell: bash
29+
run: |
30+
mkdir -p upload
31+
file=$(find ./apps/server/out -name '*.tar.xz' -print -quit)
32+
name=${{ github.ref_name }}
33+
cp "$file" "upload/TriliumNextNotes-Server-${name//\//-}-${{ inputs.os }}-${{ inputs.arch }}.tar.xz"

0 commit comments

Comments
 (0)