Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:construction_worker: Improve cd

Daniel8fbf038d8d31
diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml
index 4f10823a1e..b5ce24be9c 100644
--- a/.github/workflows/cd.yml
+++ b/.github/workflows/cd.yml
@@ -220,10 +220,126 @@ jobs:
${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app/build/siyuan-*-linux.deb
${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app/build/siyuan-*-linux.rpm
+ build_android:
+ runs-on: ubuntu-latest
+ name: ubuntu build android.apk
+ needs: prepare
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v6
+ with:
+ path: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}
+
+ - name: Set up Go
+ uses: actions/setup-go@v6
+ with:
+ go-version-file: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/kernel/go.mod
+ cache-dependency-path: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/kernel/go.sum
+ cache: false
+ - run: go version
+
+ - name: Set up Node
+ uses: actions/setup-node@v6
+ with:
+ node-version: 24
+
+ - name: Install Node pnpm
+ run: npm install -g ${{ needs.prepare.outputs.packageManager }}
+ working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app
+
+ - name: Install Node Dependencies
+ run: pnpm install --no-frozen-lockfile
+ working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app
+
+ - name: Building UI
+ run: pnpm run build
+ working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app
+
+ - name: Set up JDK
+ uses: actions/setup-java@v4
+ with:
+ distribution: temurin
+ java-version: "21"
+
+ - name: Set up Android NDK
+ # 锁定 NDK r28b(与本地开发环境同版本,保证 CI 产物与本地一致)
+ run: |
+ sdkmanager "ndk;28.2.13676358" > /dev/null
+ NDK_DIR="$ANDROID_HOME/ndk/28.2.13676358"
+ echo "ANDROID_NDK_HOME=$NDK_DIR" >> $GITHUB_ENV
+ echo "Installed NDK r28b at $NDK_DIR"
+
+ - name: Set up gomobile
+ # 锁定到 kernel/go.mod 中 x/mobile 模块的同一版本,避免工具与库版本漂移
+ run: |
+ go install golang.org/x/mobile/cmd/gomobile@2553ed8ce294
+ gomobile init
+ env:
+ GOPATH: ${{ github.workspace }}/go
+
+ - name: Building Android Kernel
+ run: gomobile bind -tags fts5 -ldflags "-s -w" -v -o kernel.aar -target android/arm64 -androidapi 26 ./mobile/
+ working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/kernel
+ env:
+ GOPATH: ${{ github.workspace }}/go
+ CGO_ENABLED: 1
+ JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
+
+ - name: Checkout siyuan-android
+ uses: actions/checkout@v6
+ with:
+ repository: siyuan-note/siyuan-android
+ ref: main
+ path: ${{ github.workspace }}/siyuan-android
+
+ - name: Prepare siyuan-android Build Inputs
+ run: |
+ mkdir -p ${{ github.workspace }}/siyuan-android/app/libs
+ cp ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/kernel/kernel.aar \
+ ${{ github.workspace }}/siyuan-android/app/libs/kernel.aar
+ cd ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app
+ zip -r app.zip appearance guide stage changelogs
+ mkdir -p ${{ github.workspace }}/siyuan-android/app/src/main/assets
+ cp app.zip ${{ github.workspace }}/siyuan-android/app/src/main/assets/app.zip
+
+ - name: Inject Signing Config
+ run: |
+ echo "$ANDROID_KEYSTORE_BASE64" | base64 -d > ${{ github.workspace }}/siyuan-android/app/siyuan-android.jks
+ cat > ${{ github.workspace }}/siyuan-android/signings.gradle <<EOF
+ android {
+ signingConfigs {
+ siyuanConfig {
+ storeFile file("siyuan-android.jks")
+ storePassword "$ANDROID_KEYSTORE_PASSWORD"
+ keyAlias "$ANDROID_KEY_ALIAS"
+ keyPassword "$ANDROID_KEY_PASSWORD"
+ }
+ }
+ }
+ EOF
+ env:
+ ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
+ ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
+ ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
+ ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
+
+ - name: Building Android App
+ run: |
+ ./gradlew assembleOfficialRelease
+ cd app/build/outputs/apk/official/release
+ mv siyuan-*-official-release.apk siyuan-android.apk
+ working-directory: ${{ github.workspace }}/siyuan-android
+
+ - name: Upload Build Artifacts
+ uses: actions/upload-artifact@v7
+ with:
+ name: siyuan-android
+ path: ${{ github.workspace }}/siyuan-android/app/build/outputs/apk/official/release/siyuan-android.apk
+
create_release:
name: Create Release
runs-on: ubuntu-latest
- needs: [prepare, build]
+ needs: [prepare, build, build_android]
steps:
- name: Download all artifacts
uses: actions/download-artifact@v8
@@ -252,4 +368,5 @@ jobs:
"siyuan-linux/siyuan-${VERSION}-linux.rpm#siyuan-${REL_VER}-linux.rpm" \
"siyuan-mac.dmg/siyuan-${VERSION}-mac.dmg#siyuan-${REL_VER}-mac.dmg" \
"siyuan-mac-arm64.dmg/siyuan-${VERSION}-mac-arm64.dmg#siyuan-${REL_VER}-mac-arm64.dmg" \
- "siyuan-win.exe/siyuan-${VERSION}-win.exe#siyuan-${REL_VER}-win.exe"
+ "siyuan-win.exe/siyuan-${VERSION}-win.exe#siyuan-${REL_VER}-win.exe" \
+ "siyuan-android/siyuan-android.apk#siyuan-${REL_VER}.apk"