chore: 从 git 跟踪移除 CLAUDE.md #3
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: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| # ==================== Changelog ==================== | |
| prepare-release: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| changelog: ${{ steps.changelog.outputs.changelog }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get version from tag or config | |
| id: version | |
| run: | | |
| if [[ "${{ github.ref }}" == refs/tags/v* ]]; then | |
| echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| else | |
| VERSION=$(node -p "require('./bedcode-desktop/src-tauri/tauri.conf.json').version") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Extract changelog for current version | |
| id: changelog | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| # 提取当前版本的 changelog 内容(从 ## [version] 到下一个 ## 之间的内容) | |
| CHANGELOG=$(awk "/^## \\[${VERSION}\\]/,/^## \\[|^## \\[Unreleased/" CHANGELOG.md | head -n -1 | tail -n +2) | |
| # 如果没找到对应版本,使用完整 CHANGELOG | |
| if [ -z "$CHANGELOG" ]; then | |
| CHANGELOG=$(cat CHANGELOG.md) | |
| fi | |
| # 写入文件避免多行字符串在 GITHUB_OUTPUT 中的问题 | |
| echo "$CHANGELOG" > /tmp/changelog.txt | |
| { | |
| echo "changelog<<EOF" | |
| cat /tmp/changelog.txt | |
| echo "" | |
| echo "EOF" | |
| } >> $GITHUB_OUTPUT | |
| # ==================== Windows Build ==================== | |
| build-windows: | |
| needs: prepare-release | |
| runs-on: windows-latest | |
| defaults: | |
| run: | |
| working-directory: bedcode-desktop | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| cache: npm | |
| cache-dependency-path: bedcode-desktop/package-lock.json | |
| - name: Install Rust stable | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Rust cache | |
| uses: swatinem/rust-cache@v2 | |
| with: | |
| workspaces: './bedcode-desktop/src-tauri -> target' | |
| - name: Import Windows certificate | |
| if: env.WINDOWS_CERTIFICATE != '' | |
| env: | |
| WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }} | |
| WINDOWS_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_CERTIFICATE_PASSWORD }} | |
| run: | | |
| New-Item -ItemType directory -Path certificate | |
| Set-Content -Path certificate/tempCert.txt -Value $env:WINDOWS_CERTIFICATE | |
| certutil -decode certificate/tempCert.txt certificate/certificate.pfx | |
| Remove-Item certificate/tempCert.txt | |
| Import-PfxCertificate -FilePath certificate/certificate.pfx -CertStoreLocation Cert:\CurrentUser\My -Password (ConvertTo-SecureString -String $env:WINDOWS_CERTIFICATE_PASSWORD -Force -AsPlainText) | |
| - name: Install frontend dependencies | |
| run: npm install | |
| - name: Build and release | |
| uses: tauri-apps/tauri-action@v0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} | |
| TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} | |
| with: | |
| projectPath: bedcode-desktop | |
| tagName: v__VERSION__ | |
| releaseName: 'BedCode v__VERSION__' | |
| releaseBody: '${{ needs.prepare-release.outputs.changelog }}' | |
| releaseDraft: true | |
| prerelease: false | |
| updaterJsonPreferNsis: true | |
| - name: Clean up certificate | |
| if: always() | |
| run: | | |
| if (Test-Path certificate) { Remove-Item -Recurse -Force certificate } | |
| # ==================== Android Build ==================== | |
| build-android: | |
| needs: prepare-release | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: bedcode-mobile | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| cache: npm | |
| cache-dependency-path: bedcode-mobile/package-lock.json | |
| - name: Install Rust stable | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: aarch64-linux-android | |
| - name: Rust cache | |
| uses: swatinem/rust-cache@v2 | |
| with: | |
| workspaces: './bedcode-mobile/src-tauri -> target' | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: zulu | |
| java-version: 17 | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v3 | |
| - name: Setup Android NDK | |
| run: sdkmanager "ndk;27.0.12077973" | |
| - name: Configure Android signing | |
| run: | | |
| cd src-tauri/gen/android | |
| echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" > key.properties | |
| echo "keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}" >> key.properties | |
| echo "storePassword=${{ secrets.ANDROID_KEY_PASSWORD }}" >> key.properties | |
| base64 -d <<< "${{ secrets.ANDROID_KEY_BASE64 }}" > $RUNNER_TEMP/keystore.jks | |
| echo "storeFile=$RUNNER_TEMP/keystore.jks" >> key.properties | |
| - name: Install frontend dependencies | |
| run: npm install | |
| - name: Build Android APK | |
| env: | |
| TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} | |
| TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} | |
| run: npx tauri android build --apk -t aarch64 | |
| - name: Upload APK to Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.prepare-release.outputs.version }} | |
| files: | | |
| bedcode-mobile/src-tauri/gen/android/app/build/outputs/apk/universal/release/*.apk | |
| bedcode-mobile/src-tauri/gen/android/app/build/outputs/apk/universal/release/*.apk.sig | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # ==================== Publish Release ==================== | |
| publish-release: | |
| needs: [prepare-release, build-windows, build-android] | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Publish release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.prepare-release.outputs.version }} | |
| draft: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |