🔖 Release v3.7.0-alpha.2 #451
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CD For SiYuan | |
| on: | |
| push: | |
| tags: | |
| - '*-alpha*' | |
| - '*-beta*' | |
| - '*-rc*' | |
| workflow_dispatch: | |
| # ref https://docs.github.com/zh/actions/learn-github-actions/variables | |
| env: | |
| package_json: "app/package.json" | |
| jobs: | |
| prepare: | |
| name: Prepare | |
| runs-on: ubuntu-latest | |
| outputs: | |
| release_title: ${{ steps.release_info.outputs.release_title }} | |
| version: ${{ steps.version.outputs.value }} | |
| packageManager: ${{ steps.packageManager.outputs.value }} | |
| release_body: ${{ steps.release_info.outputs.release_body }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.11" | |
| - run: pip install PyGithub | |
| - id: thisLatestRelease | |
| run: | | |
| LATEST=$(gh api "repos/${{ github.repository }}/releases/latest" --jq '.tag_name' 2>/dev/null || echo "") | |
| echo "release=$LATEST" >> $GITHUB_OUTPUT | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract version from package.json | |
| id: version | |
| run: | | |
| echo "value=$(jq .version ${{ env.package_json }} -r)" >> $GITHUB_OUTPUT | |
| - name: Extract electronVersion from package.json | |
| id: electronVersion | |
| run: | | |
| echo "value=$(jq .devDependencies.electron ${{ env.package_json }} -r)" >> $GITHUB_OUTPUT | |
| - name: Extract packageManager from package.json | |
| id: packageManager | |
| run: | | |
| echo "value=$(jq .packageManager ${{ env.package_json }} -r)" >> $GITHUB_OUTPUT | |
| - name: Gather Release Information | |
| id: release_info | |
| run: | | |
| echo "release_title=SiYuan v${{ steps.version.outputs.value }}" >> $GITHUB_OUTPUT | |
| changelog_header=$(python scripts/parse-changelog-HEAD.py -t ${{ github.ref }} -b ${{ steps.thisLatestRelease.outputs.release }} -e ${{ steps.electronVersion.outputs.value }} ${{ github.repository }}) | |
| changelog=$(python scripts/parse-changelog.py -t ${{ github.ref }} ${{ github.repository }}) | |
| EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
| echo "release_body<<$EOF" >> $GITHUB_OUTPUT | |
| echo "$changelog_header" >> $GITHUB_OUTPUT | |
| echo "$changelog" >> $GITHUB_OUTPUT | |
| echo "$EOF" >> $GITHUB_OUTPUT | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build: | |
| runs-on: ${{ matrix.config.os }} | |
| name: ${{ matrix.config.name }} | |
| needs: [prepare] | |
| strategy: | |
| matrix: | |
| config: | |
| - os: ubuntu-24.04 | |
| name: ubuntu build linux | |
| kernel_path: "../app/kernel-linux/SiYuan-Kernel" | |
| build_args_prefix: "-s -w -X" | |
| build_args_suffix: "Mode=prod" | |
| electron_args: "dist-linux" | |
| goos: "linux" | |
| goarch: "amd64" | |
| suffix: "linux" | |
| - os: macos-latest | |
| name: macos build mac.dmg | |
| kernel_path: "../app/kernel-darwin/SiYuan-Kernel" | |
| build_args_prefix: "-s -w -X" | |
| build_args_suffix: "Mode=prod" | |
| electron_args: "dist-darwin" | |
| goos: "darwin" | |
| goarch: "amd64" | |
| suffix: "mac.dmg" | |
| - os: macos-latest | |
| name: macos build mac-arm64.dmg | |
| kernel_path: "../app/kernel-darwin-arm64/SiYuan-Kernel" | |
| build_args_prefix: "-s -w -X" | |
| build_args_suffix: "Mode=prod" | |
| electron_args: "dist-darwin-arm64" | |
| goos: "darwin" | |
| goarch: "arm64" | |
| suffix: "mac-arm64.dmg" | |
| - os: windows-latest | |
| name: windows build win.exe | |
| kernel_path: "../app/kernel/SiYuan-Kernel.exe" | |
| build_args_prefix: "-s -w -X" | |
| build_args_suffix: "Mode=prod" | |
| electron_args: "dist" | |
| goos: "windows" | |
| gobin: "bin" | |
| mingwsys: "MINGW64" | |
| goarch: "amd64" | |
| suffix: "win.exe" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| path: ${{ github.workspace }}/go/src/github.com/${{ github.repository }} | |
| - name: Set up MingGW | |
| uses: msys2/setup-msys2@v2 | |
| if: "contains( matrix.config.goos, 'windows')" | |
| with: | |
| install: p7zip mingw-w64-x86_64-lua | |
| - 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: true | |
| - run: go version | |
| - name: Set up goversioninfo | |
| run: go get github.com/josephspurrier/goversioninfo/cmd/goversioninfo && go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo | |
| if: "contains( matrix.config.goos, 'windows')" | |
| working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/kernel | |
| env: | |
| GO111MODULE: on | |
| CGO_ENABLED: 1 | |
| GOOS: ${{ matrix.config.goos }} | |
| GOPATH: ${{ github.workspace }}/go | |
| GOARCH: ${{ matrix.config.goarch }} | |
| - 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: Cache pnpm store | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.pnpm-store | |
| key: pnpm-${{ runner.os }}-${{ hashFiles('app/pnpm-lock.yaml') }} | |
| restore-keys: pnpm-${{ runner.os }}- | |
| - name: Install Node Dependencies | |
| run: pnpm install --no-frozen-lockfile | |
| working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app | |
| - name: Install Electron Binary | |
| run: pnpm run install:electron | |
| 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: Clean Build and Kernel Directories | |
| run: | | |
| rm -rf "${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app/build" | |
| rm -rf "${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app/kernel"* | |
| shell: bash | |
| - name: Generate Icon Resource and Properties/Version Info For Windows | |
| run: ${{ github.workspace }}\go\${{ matrix.config.gobin }}\goversioninfo -platform-specific=true -icon="resource\icon.ico" -manifest="resource\goversioninfo.exe.manifest" | |
| if: "contains( matrix.config.goos, 'windows')" | |
| working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/kernel | |
| - name: Building Kernel | |
| run: go build -tags fts5 -o "${{ matrix.config.kernel_path }}" -ldflags "${{ matrix.config.build_args_prefix }} github.com/${{ github.repository }}/kernel/util.${{ matrix.config.build_args_suffix }}" | |
| working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/kernel | |
| env: | |
| GO111MODULE: on | |
| CGO_ENABLED: 1 | |
| GOOS: ${{ matrix.config.goos }} | |
| GOPATH: ${{ github.workspace }}/go | |
| GOARCH: ${{ matrix.config.goarch }} | |
| - name: Install RPM build tools | |
| if: matrix.config.goos == 'linux' | |
| run: sudo apt-get install -y rpm | |
| - name: Building Electron App | |
| run: pnpm run ${{ matrix.config.electron_args }} | |
| working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app | |
| - name: Upload Build Artifacts (Non-Linux) | |
| if: matrix.config.goos != 'linux' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: siyuan-${{ matrix.config.suffix }} | |
| path: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app/build/siyuan-*-${{ matrix.config.suffix }} | |
| - name: Upload Build Artifacts (Linux) | |
| if: matrix.config.goos == 'linux' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: siyuan-linux | |
| path: | | |
| ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app/build/siyuan-*-linux.AppImage | |
| ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app/build/siyuan-*-linux.tar.gz | |
| ${{ 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 | |
| # Android and desktop builds run in parallel, both depend on prepare. | |
| # create_release aggregates all artifacts once both jobs succeed. | |
| 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: true | |
| - 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: Cache pnpm store | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.pnpm-store | |
| key: pnpm-${{ runner.os }}-${{ hashFiles('app/pnpm-lock.yaml') }} | |
| restore-keys: pnpm-${{ runner.os }}- | |
| - 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@v5 | |
| with: | |
| distribution: temurin | |
| java-version: "21" | |
| - name: Set up Android NDK | |
| # 锁定 NDK r28b(与本地开发环境同版本)。sdkmanager 不在 PATH 上 | |
| # (actions/runner-images#13674),用全路径调用;同时预接受 SDK 许可, | |
| # 避免 NDK 安装卡在交互式许可确认。 | |
| run: | | |
| SDKMANAGER="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" | |
| if [ ! -x "$SDKMANAGER" ]; then | |
| SDKMANAGER=$(ls "$ANDROID_HOME"/cmdline-tools/*/bin/sdkmanager 2>/dev/null | head -1) | |
| fi | |
| if [ -z "$SDKMANAGER" ]; then | |
| echo "ERROR: sdkmanager not found under $ANDROID_HOME/cmdline-tools/" | |
| exit 1 | |
| fi | |
| echo "Using sdkmanager: $SDKMANAGER" | |
| yes | "$SDKMANAGER" --licenses > /dev/null 2>&1 || true | |
| "$SDKMANAGER" "ndk;28.2.13676358" > /dev/null | |
| NDK_DIR="$ANDROID_HOME/ndk/28.2.13676358" | |
| echo "ANDROID_NDK_HOME=$NDK_DIR" >> $GITHUB_ENV | |
| echo "ANDROID_NDK_ROOT=$NDK_DIR" >> $GITHUB_ENV | |
| echo "Installed NDK r28b at $NDK_DIR" | |
| - name: Set up gomobile | |
| # 锁定到 kernel/go.mod 中 x/mobile 模块的同一版本,避免工具与库版本漂移。 | |
| # GOPATH 被显式指向 workspace 下,go install 的产物在 $GOPATH/bin, | |
| # 该目录不在默认 PATH 上,需用全路径调用并写入 $GITHUB_PATH 供后续步骤使用。 | |
| run: | | |
| go install golang.org/x/mobile/cmd/gomobile@2553ed8ce294 | |
| echo "$GOPATH/bin" >> $GITHUB_PATH | |
| "$GOPATH/bin/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: Patch siyuan-android Repositories | |
| # siyuan-android 默认把阿里云镜像排在最前,某些依赖(如 org.apache:apache:31) | |
| # 在阿里云镜像缺失会导致解析失败。CI 在海外,直接走 google()/mavenCentral() | |
| # 更稳;sed 删除所有 maven.aliyun.com 行,保留官方仓库。 | |
| run: | | |
| sed -i '/maven.aliyun.com/d' build.gradle | |
| echo "=== Patched build.gradle repositories ===" | |
| grep -A 6 "repositories" build.gradle | head -20 | |
| working-directory: ${{ 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 | |
| node scripts/trimChangelogs.js | |
| zip -r app.zip appearance guide stage $([ -d changelogs ] && echo 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 | |
| # local.properties 被 siyuan-android 的 .gitignore 忽略,CI 里需现场生成, | |
| # 否则 Gradle 报 "SDK location not found";gradlew 也需显式加可执行权限。 | |
| # 产物重命名为带版本号的固定名,确保下载文件名正确(GitHub Release 的下载名 | |
| # 取决于上传时的本地文件名,# 语法只改显示标签)。 | |
| run: | | |
| echo "sdk.dir=$ANDROID_HOME" > local.properties | |
| chmod +x ./gradlew | |
| ./gradlew assembleOfficialRelease | |
| cd app/build/outputs/apk/official/release | |
| mv siyuan-*-official-release.apk siyuan-${{ needs.prepare.outputs.version }}.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-${{ needs.prepare.outputs.version }}.apk | |
| create_release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| needs: [prepare, build, build_android] | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v8 | |
| - name: Create Release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| name: ${{ needs.prepare.outputs.release_title }} | |
| tag: ${{ github.ref }} | |
| body: ${{ needs.prepare.outputs.release_body }} | |
| draft: false | |
| prerelease: true | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload Release Assets | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GH_REPO: ${{ github.repository }} | |
| run: | | |
| VERSION=${{ needs.prepare.outputs.version }} | |
| gh release upload ${{ github.ref_name }} \ | |
| "siyuan-linux/siyuan-${VERSION}-linux.AppImage#siyuan-${VERSION}-linux.AppImage" \ | |
| "siyuan-linux/siyuan-${VERSION}-linux.tar.gz#siyuan-${VERSION}-linux.tar.gz" \ | |
| "siyuan-linux/siyuan-${VERSION}-linux.deb#siyuan-${VERSION}-linux.deb" \ | |
| "siyuan-linux/siyuan-${VERSION}-linux.rpm#siyuan-${VERSION}-linux.rpm" \ | |
| "siyuan-mac.dmg/siyuan-${VERSION}-mac.dmg#siyuan-${VERSION}-mac.dmg" \ | |
| "siyuan-mac-arm64.dmg/siyuan-${VERSION}-mac-arm64.dmg#siyuan-${VERSION}-mac-arm64.dmg" \ | |
| "siyuan-win.exe/siyuan-${VERSION}-win.exe#siyuan-${VERSION}-win.exe" \ | |
| "siyuan-android/siyuan-${VERSION}.apk#siyuan-${VERSION}.apk" |