chore: 更新版本号 #13
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: Beta 构建 | ||
|
Check failure on line 1 in .github/workflows/build-beta.yml
|
||
| on: | ||
| push: | ||
| branches: [dev] | ||
| paths: ['package.json'] | ||
| workflow_dispatch: | ||
| inputs: | ||
| force_build: | ||
| description: '强制构建 Beta 版本' | ||
| required: false | ||
| default: 'false' | ||
| type: boolean | ||
| jobs: | ||
| check-version: | ||
| if: github.actor == 'maotoumao' || github.event_name == 'push' | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| should_build: ${{ steps.version_check.outputs.should_build }} | ||
| version: ${{ steps.version_check.outputs.version }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Check version format | ||
| id: version_check | ||
| run: | | ||
| VERSION=$(node -p "require('./package.json').version") | ||
| echo "Current version: $VERSION" | ||
| # 检查版本是否符合 -beta.xx 格式 | ||
| if [[ $VERSION =~ -beta\.[0-9]{1,2}$ ]]; then | ||
| echo "✅ Version matches beta format: $VERSION" | ||
| echo "should_build=true" >> $GITHUB_OUTPUT | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
| elif [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.force_build }}" == "true" ]]; then | ||
| echo "🔧 Force build triggered by workflow_dispatch" | ||
| echo "should_build=true" >> $GITHUB_OUTPUT | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "❌ Version does not match beta format or not forced: $VERSION" | ||
| echo "should_build=false" >> $GITHUB_OUTPUT | ||
| fi | ||
| build-beta: | ||
| needs: check-version | ||
| if: needs.check-version.outputs.should_build == 'true' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Java | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '17' | ||
| distribution: 'temurin' | ||
| cache: 'gradle' | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: 'npm' | ||
| - name: Cache React Native dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| node_modules | ||
| ~/.gradle/caches | ||
| ~/.gradle/wrapper | ||
| android/.gradle | ||
| key: ${{ runner.os }}-rn-${{ hashFiles('package-lock.json', 'android/gradle/wrapper/gradle-wrapper.properties') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-rn- | ||
| - name: Install Dependencies | ||
| run: npm ci --prefer-offline --no-audit | ||
| - name: Setup Keystore (if secrets available) | ||
| if: ${{ secrets.RELEASE_KEYSTORE_BASE64 != '' }} | ||
| run: | | ||
| echo "${{ secrets.RELEASE_KEYSTORE_BASE64 }}" | base64 -d > android/app/release.keystore | ||
| cat > android/keystore.properties << 'EOF' | ||
| RELEASE_STORE_FILE=release.keystore | ||
| RELEASE_STORE_PASSWORD=${{ secrets.RELEASE_STORE_PASSWORD }} | ||
| RELEASE_KEY_ALIAS=${{ secrets.RELEASE_KEY_ALIAS }} | ||
| RELEASE_KEY_PASSWORD=${{ secrets.RELEASE_KEY_PASSWORD }} | ||
| EOF | ||
| chmod 600 android/keystore.properties android/app/release.keystore | ||
| - name: Make gradlew executable | ||
| run: chmod +x android/gradlew | ||
| - name: Build Beta APK | ||
| run: | | ||
| cd android | ||
| ./gradlew assembleRelease --parallel --build-cache --configure-on-demand | ||
| - name: List generated APKs | ||
| run: | | ||
| echo "📱 Generated APK files:" | ||
| find android/app/build/outputs/apk/release -name "*.apk" -exec ls -lh {} \; | ||
| - name: Upload Beta APKs | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: beta-apks-${{ needs.check-version.outputs.version }} | ||
| path: android/app/build/outputs/apk/release/*.apk | ||
| retention-days: 30 | ||
| - name: Build Summary | ||
| run: | | ||
| echo "🎉 Beta build completed successfully!" | ||
| echo "📦 Version: ${{ needs.check-version.outputs.version }}" | ||
| echo "🚀 Triggered by: ${{ github.event_name }}" | ||
| echo "👤 Actor: ${{ github.actor }}" | ||