mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
85b6fa9eee
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
314 lines
10 KiB
YAML
314 lines
10 KiB
YAML
name: Build and test
|
|
|
|
on:
|
|
push:
|
|
branches: [ "dev", "main", "release/**" ]
|
|
paths-ignore:
|
|
- '**.md'
|
|
- 'fastlane/**'
|
|
- '.github/workflows/crowdin_contributors.yml'
|
|
pull_request:
|
|
branches: [ "dev" ]
|
|
paths-ignore:
|
|
- '**.md'
|
|
- 'fastlane/**'
|
|
- '.github/workflows/crowdin_contributors.yml'
|
|
workflow_dispatch: { }
|
|
|
|
env:
|
|
# Misc
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
# Signing info
|
|
IDE_SIGNING_ALIAS: ${{ secrets.IDE_SIGNING_ALIAS }}
|
|
IDE_SIGNING_AUTH_PASS: ${{ secrets.IDE_SIGNING_AUTH_PASS }}
|
|
IDE_SIGNING_AUTH_USER: ${{ secrets.IDE_SIGNING_AUTH_USER }}
|
|
IDE_SIGNING_KEY_PASS: ${{ secrets.IDE_SIGNING_KEY_PASS }}
|
|
IDE_SIGNING_STORE_PASS: ${{ secrets.IDE_SIGNING_STORE_PASS }}
|
|
IDE_SIGNING_URL: ${{ secrets.IDE_SIGNING_URL }}
|
|
IDE_SIGNING_KEY_BIN: ${{ secrets.IDE_SIGNING_KEY_BIN }}
|
|
|
|
# Publishing credentials
|
|
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MVN_USERNAME }}
|
|
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MVN_PASSWORD }}
|
|
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MVN_SIGNING_KEY }}
|
|
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.MVN_SIGNING_KEY_ID }}
|
|
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MVN_SIGNING_KEY_PASSWORD }}
|
|
|
|
# Build configuration
|
|
BUILD_JAVA_VERSION: '17'
|
|
BUILD_JAVA_DIST: 'temurin'
|
|
BUILD_IS_RELEASE: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/release/**' }}
|
|
ReleaseAndroidIDE: ${{ github.ref == 'refs/heads/main' }}
|
|
|
|
jobs:
|
|
build_apk:
|
|
strategy:
|
|
matrix:
|
|
build_type: ['debug', 'release']
|
|
name: Build APK
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Cancel previous runs
|
|
uses: styfle/cancel-workflow-action@0.12.1
|
|
with:
|
|
access_token: ${{ github.token }}
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: ${{ env.BUILD_JAVA_VERSION }}
|
|
distribution: ${{ env.BUILD_JAVA_DIST }}
|
|
- name: Change Gradle wrapper permissions
|
|
run: chmod +x ./gradlew
|
|
- name: Restore cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-gradle-
|
|
- name: Assemble ${{ matrix.build_type }} APK
|
|
run: |
|
|
build_type=${{ matrix.build_type }}
|
|
./gradlew :app:assemble${build_type^}
|
|
- name: Copy ${{ matrix.build_type }} APK
|
|
run: |
|
|
cp app/build/outputs/apk/${{ matrix.build_type }}/app-*.apk ./
|
|
- name: Upload arm64-v8a ${{ matrix.build_type }} APK
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: apk-arm64-v8a-${{ matrix.build_type }}
|
|
path: app-arm64-v8a-${{ matrix.build_type }}.apk
|
|
- name: Upload armeabi-v7a ${{ matrix.build_type }} APK
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: apk-armeabi-v7a-${{ matrix.build_type }}
|
|
path: app-armeabi-v7a-${{ matrix.build_type }}.apk
|
|
- name: Upload x86_64 ${{ matrix.build_type }} APK
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: apk-x86_64-${{ matrix.build_type }}
|
|
path: app-x86_64-${{ matrix.build_type }}.apk
|
|
- name: Upload ${{ matrix.build_type }} mappings
|
|
if: ${{ matrix.build_type == 'release' }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: release-mappings
|
|
path: '**/build/outputs/mapping'
|
|
|
|
run_unit_tests:
|
|
name: Run unit tests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: ${{ env.BUILD_JAVA_VERSION }}
|
|
distribution: ${{ env.BUILD_JAVA_DIST }}
|
|
- name: Change Gradle wrapper permissions
|
|
run: chmod +x ./gradlew
|
|
- name: Restore cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-gradle-
|
|
- name: Run unit tests
|
|
run: ./gradlew runTestsInCI --continue
|
|
env:
|
|
ANDROIDIDE_TEST: true
|
|
- name: Upload test reports
|
|
if: ${{ always() }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: test-results-unit-tests
|
|
path: '**/build/reports/tests/'
|
|
|
|
run_tooling_api_tests:
|
|
name: Build and test Tooling API
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: ${{ env.BUILD_JAVA_VERSION }}
|
|
distribution: ${{ env.BUILD_JAVA_DIST }}
|
|
- name: Change Gradle wrapper permissions
|
|
run: chmod +x ./gradlew
|
|
- name: Restore cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-gradle-
|
|
- name: Run tooling API tests
|
|
run: ./gradlew :subprojects:tooling-api-impl:build --continue
|
|
env:
|
|
ANDROIDIDE_TEST: true
|
|
TEST_TOOLING_API_IMPL: true
|
|
- name: Upload test reports
|
|
if: ${{ always() }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: test-results-tooling-api-tests
|
|
path: '**/build/reports/tests/'
|
|
|
|
run_connected_checks:
|
|
name: Run connected checks
|
|
runs-on: macos-latest
|
|
if: false
|
|
strategy:
|
|
matrix:
|
|
api-level: [ 26, 32 ]
|
|
target: [ default ]
|
|
steps:
|
|
- name: Cancel previous runs
|
|
uses: styfle/cancel-workflow-action@0.12.1
|
|
with:
|
|
access_token: ${{ github.token }}
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: ${{ env.BUILD_JAVA_VERSION }}
|
|
distribution: ${{ env.BUILD_JAVA_DIST }}
|
|
- name: Change Gradle wrapper permissions
|
|
run: chmod +x ./gradlew
|
|
- name: Restore cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-gradle-
|
|
- name: Run connected checks
|
|
uses: reactivecircus/android-emulator-runner@v2
|
|
with:
|
|
api-level: ${{ matrix.api-level }}
|
|
target: ${{ matrix.target }}
|
|
arch: x86_64
|
|
profile: Nexus 6
|
|
script: ./gradlew connectedCheck
|
|
- name: Upload test reports
|
|
if: ${{ always() }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: test-results-android-tests-${{ matrix.api-level }}-${{ matrix.target }}
|
|
path: '**/build/reports/androidTests/'
|
|
|
|
publish:
|
|
name: Publish release
|
|
runs-on: ubuntu-latest
|
|
needs: [ build_apk, run_unit_tests, run_tooling_api_tests ]
|
|
if: |
|
|
always()
|
|
&& github.ref == 'refs/heads/main'
|
|
&& github.event_name != 'pull_request'
|
|
&& needs.build_apk.result == 'success'
|
|
&& needs.run_unit_tests.result == 'success'
|
|
&& needs.run_tooling_api_tests.result == 'success'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: ${{ env.BUILD_JAVA_VERSION }}
|
|
distribution: ${{ env.BUILD_JAVA_DIST }}
|
|
- name: Download arm64-v8a APK
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: apk-arm64-v8a-release
|
|
- name: Download x86_64 APK
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: apk-x86_64-release
|
|
- name: Download armeabi-v7a APK
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: apk-armeabi-v7a-release
|
|
- name: Change Gradle wrapper permissions
|
|
run: chmod +x ./gradlew
|
|
- name: Restore cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-gradle-
|
|
- name: Generate checksums
|
|
run: |
|
|
mkdir -p build
|
|
|
|
md5sum *.apk > build/CHECKSUMS-md5.txt
|
|
sha256sum *.apk > build/CHECKSUMS-sha256.txt
|
|
sha512sum *.apk > build/CHECKSUMS-sha512.txt
|
|
|
|
find build -type f -name "CHECKSUMS*.txt" -exec echo {} \; -exec cat {} \; -exec echo "" \;
|
|
- name: Publish release
|
|
run: ./gradlew nyxMake nyxMark nyxPublish publish release --stacktrace
|
|
- name: Archive Nyx state file
|
|
uses: actions/upload-artifact@v4
|
|
if: ${{ always() }}
|
|
with:
|
|
name: .nyx-state-${{ github.job }}.json
|
|
path: build/nyx-state.json
|
|
|
|
publish_snapshots:
|
|
name: Publish package snapshots
|
|
runs-on: ubuntu-latest
|
|
needs: [ build_apk ]
|
|
if: ${{ always() && github.ref != 'refs/heads/main' && github.event_name != 'pull_request' && needs.build_apk.result == 'success' }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: ${{ env.BUILD_JAVA_VERSION }}
|
|
distribution: ${{ env.BUILD_JAVA_DIST }}
|
|
- name: Change Gradle wrapper permissions
|
|
run: chmod +x ./gradlew
|
|
- name: Restore cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-gradle-
|
|
- name: Publish snapshots
|
|
run: ./gradlew publishAllPublicationsToMavenCentralRepository --stacktrace
|