ci: 移除 libgcc 符号修复脚本 #121
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: CI Build | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| RUST_TOOLCHAIN: "stable" | |
| RUSTC_BOOTSTRAP: "1" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 25 | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '25' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v6 | |
| - name: Make gradlew executable | |
| run: chmod +x gradlew | |
| - name: Setup Rust toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: stable | |
| targets: "x86_64-unknown-linux-gnu" | |
| components: "rustfmt,clippy,rust-src" | |
| - name: Setup Android NDK | |
| uses: nttld/setup-ndk@v1 | |
| with: | |
| ndk-version: r29 | |
| - name: Add Rust Android targets | |
| run: | | |
| rustup target add aarch64-linux-android | |
| rustup target add armv7-linux-androideabi | |
| rustup target add i686-linux-android | |
| rustup target add x86_64-linux-android | |
| - uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-ndk | |
| - name: Run sccache-cache | |
| uses: mozilla-actions/sccache-action@v0.0.9 | |
| - name: Cache Gradle dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Setup Rust cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Decode Keystore | |
| if: github.event_name != 'pull_request' | |
| env: | |
| KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} | |
| run: | | |
| echo "$KEYSTORE_BASE64" | base64 --decode > keystore.jks | |
| - name: Get version info | |
| if: github.event_name != 'pull_request' | |
| id: version | |
| run: | | |
| if [[ $GITHUB_REF == refs/tags/* ]]; then | |
| echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| else | |
| echo "version=dev-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Gen binding | |
| run: | | |
| touch local.properties | |
| ./gradlew assembleDebug -Prust-target=arm64 | |
| ./gradlew clean | |
| cd uniffi | |
| cargo clean | |
| env: | |
| SCCACHE_GHA_ENABLED: "true" | |
| RUSTC_WRAPPER: "sccache" | |
| - name: Build Debug APK | |
| if: github.event_name == 'pull_request' | |
| env: | |
| SCCACHE_GHA_ENABLED: "true" | |
| RUSTC_WRAPPER: "sccache" | |
| run: | | |
| ./gradlew assembleDebug | |
| - name: Build Release APKs | |
| if: github.event_name != 'pull_request' | |
| env: | |
| KEYSTORE_FILE: ${{ github.workspace }}/keystore.jks | |
| KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
| KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
| ANDROID_SPLIT_ABI_ENABLE: true | |
| ANDROID_SPLIT_ABI_UNIVERSAL_APK: true | |
| SCCACHE_GHA_ENABLED: "true" | |
| RUSTC_WRAPPER: "sccache" | |
| run: | | |
| rm -rf app/build/outputs/apk | |
| ./gradlew assembleRelease | |
| - name: Organize APKs | |
| if: github.event_name != 'pull_request' | |
| run: | | |
| mkdir -p output | |
| VERSION="${{ steps.version.outputs.version }}" | |
| # Copy and rename APKs | |
| cp app/build/outputs/apk/release/*-arm64-v8a-release.apk output/clash-android-${VERSION}-arm64-v8a.apk || true | |
| cp app/build/outputs/apk/release/*-armeabi-v7a-release.apk output/clash-android-${VERSION}-armeabi-v7a.apk || true | |
| cp app/build/outputs/apk/release/*-x86-release.apk output/clash-android-${VERSION}-x86.apk || true | |
| cp app/build/outputs/apk/release/*-x86_64-release.apk output/clash-android-${VERSION}-x86_64.apk || true | |
| cp app/build/outputs/apk/release/*-universal-release.apk output/clash-android-${VERSION}-all.apk || true | |
| ls -lh output/ | |
| - name: Create and publish release | |
| if: github.event_name != 'pull_request' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TAG_NAME: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || 'latest' }} | |
| run: | | |
| # Delete old latest release if creating a new latest release | |
| if [ "$TAG_NAME" = "latest" ]; then | |
| gh release delete "$TAG_NAME" --yes --cleanup-tag || true | |
| fi | |
| # Create draft release with changelog | |
| if [[ "$TAG_NAME" == v* ]]; then | |
| gh release create "$TAG_NAME" --draft --latest --title "$TAG_NAME" | |
| else | |
| gh release create "$TAG_NAME" --draft --title "测试构建" | |
| fi | |
| # Upload all package files | |
| find ./output -type f -exec gh release upload "$TAG_NAME" {} \; | |
| # Upload LICENSE file | |
| gh release upload "$TAG_NAME" LICENSE | |
| - name: Determine commit range for changelog | |
| if: github.event_name != 'pull_request' | |
| id: commit-range | |
| run: | | |
| # Check if this is a release (v* tag) or prerelease (push to main) | |
| if [[ $GITHUB_REF == refs/tags/v* ]]; then | |
| # For release: use previous v tag to current v tag | |
| CURRENT_TAG="${GITHUB_REF#refs/tags/}" | |
| # Get the previous v* tag (use -F -x for fixed string exact matching) | |
| PREVIOUS_TAG=$(git tag -l "v*" --sort=-version:refname | grep -F -x -v "${CURRENT_TAG}" | head -n 1) | |
| if [ -z "$PREVIOUS_TAG" ]; then | |
| # No previous tag found, use all commits up to current tag | |
| echo "args=${CURRENT_TAG}" >> $GITHUB_OUTPUT | |
| else | |
| echo "args=${PREVIOUS_TAG}..${CURRENT_TAG}" >> $GITHUB_OUTPUT | |
| fi | |
| else | |
| # For prerelease: use most recent v* tag to current commit | |
| LATEST_TAG=$(git tag -l "v*" --sort=-version:refname | head -n 1) | |
| if [ -z "$LATEST_TAG" ]; then | |
| # No v* tag found, use all commits up to HEAD | |
| echo "args=HEAD" >> $GITHUB_OUTPUT | |
| else | |
| echo "args=${LATEST_TAG}..HEAD" >> $GITHUB_OUTPUT | |
| fi | |
| fi | |
| - name: Generate a changelog | |
| if: github.event_name != 'pull_request' | |
| uses: orhun/git-cliff-action@main | |
| id: git-cliff | |
| with: | |
| config: .github/cliff.toml | |
| args: ${{ steps.commit-range.outputs.args }} --strip header | |
| env: | |
| GITHUB_REPO: ${{ github.repository }} | |
| OUTPUT: CHANGELOG.md | |
| - name: Publish release | |
| if: github.event_name != 'pull_request' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TAG_NAME: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || 'latest' }} | |
| run: | | |
| # Publish the release (change from draft to published) | |
| if [[ "$TAG_NAME" == v* ]]; then | |
| gh release edit "$TAG_NAME" --draft=false --latest --notes-file CHANGELOG.md | |
| else | |
| gh release edit "$TAG_NAME" --draft=false --prerelease --notes-file CHANGELOG.md | |
| fi | |