chore: 优化 Expo 构建工作流,添加 Java 和 Android SDK 缓存,配置加速设置
Some checks failed
/ build (push) Failing after 2m32s
Some checks failed
/ build (push) Failing after 2m32s
This commit is contained in:
@@ -5,6 +5,13 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
# 加速 npm/pnpm 下载
|
||||||
|
PNPM_REGISTRY: https://registry.npmmirror.com
|
||||||
|
# 加速 Android 构建
|
||||||
|
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.parallel=true -Dorg.gradle.configureondemand=true -Dorg.gradle.jvmargs="-Xmx4g -XX:+HeapDumpOnOutOfMemoryError"
|
||||||
|
# 使用国内镜像加速
|
||||||
|
ANDROID_SDK_ROOT: /usr/local/lib/android/sdk
|
||||||
steps:
|
steps:
|
||||||
- name: 🏗 Setup repo
|
- name: 🏗 Setup repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@@ -13,24 +20,133 @@ jobs:
|
|||||||
uses: pnpm/action-setup@v2
|
uses: pnpm/action-setup@v2
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
|
run_install: false
|
||||||
|
|
||||||
- name: 🏗 Setup Node
|
- name: 🏗 Setup Node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18.x
|
node-version: 18.x
|
||||||
cache: pnpm
|
cache: pnpm
|
||||||
|
registry-url: 'https://registry.npmmirror.com'
|
||||||
|
|
||||||
|
- name: ⚡ Configure pnpm for speed
|
||||||
|
run: |
|
||||||
|
pnpm config set registry https://registry.npmmirror.com
|
||||||
|
pnpm config set store-dir ~/.pnpm-store
|
||||||
|
pnpm config set network-timeout 60000
|
||||||
|
|
||||||
- name: 📦 Install dependencies
|
- name: 📦 Install dependencies
|
||||||
run: pnpm install
|
run: pnpm install
|
||||||
|
|
||||||
- name: 🏗 Setup Java
|
- name: ⚡ Cache Java installation
|
||||||
uses: actions/setup-java@v3
|
uses: actions/cache@v3
|
||||||
|
id: java-cache
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
path: /opt/java
|
||||||
java-version: '17'
|
key: java-17-${{ runner.os }}-v2
|
||||||
|
|
||||||
|
- name: 🏗 Setup Java (with China mirror)
|
||||||
|
if: steps.java-cache.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
# 使用清华大学镜像下载 Java (更快)
|
||||||
|
echo "Downloading Java 17 from Tsinghua mirror..."
|
||||||
|
wget -q --timeout=30 --tries=3 \
|
||||||
|
https://mirrors.tuna.tsinghua.edu.cn/Adoptium/17/jdk/x64/linux/OpenJDK17U-jdk_x64_linux_hotspot_17.0.9_9.tar.gz \
|
||||||
|
-O java17.tar.gz
|
||||||
|
|
||||||
|
# 解压并安装
|
||||||
|
tar -xf java17.tar.gz
|
||||||
|
sudo mkdir -p /opt
|
||||||
|
sudo mv jdk-17.0.9+9 /opt/java
|
||||||
|
sudo chmod -R 755 /opt/java
|
||||||
|
|
||||||
|
- name: ⚡ Configure Java environment
|
||||||
|
run: |
|
||||||
|
echo "JAVA_HOME=/opt/java" >> $GITHUB_ENV
|
||||||
|
echo "/opt/java/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
|
- name: ⚡ Verify Java installation
|
||||||
|
run: |
|
||||||
|
java -version
|
||||||
|
echo "JAVA_HOME: $JAVA_HOME"
|
||||||
|
|
||||||
|
- name: ⚡ Configure Java mirrors for speed
|
||||||
|
run: |
|
||||||
|
# 配置 Maven 使用阿里云镜像
|
||||||
|
mkdir -p ~/.m2
|
||||||
|
cat > ~/.m2/settings.xml << EOF
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
|
||||||
|
http://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||||
|
<mirrors>
|
||||||
|
<mirror>
|
||||||
|
<id>aliyunmaven</id>
|
||||||
|
<mirrorOf>*</mirrorOf>
|
||||||
|
<name>阿里云公共仓库</name>
|
||||||
|
<url>https://maven.aliyun.com/repository/public</url>
|
||||||
|
</mirror>
|
||||||
|
<mirror>
|
||||||
|
<id>aliyun-google</id>
|
||||||
|
<mirrorOf>central</mirrorOf>
|
||||||
|
<name>阿里云Google镜像</name>
|
||||||
|
<url>https://maven.aliyun.com/repository/google</url>
|
||||||
|
</mirror>
|
||||||
|
</mirrors>
|
||||||
|
</settings>
|
||||||
|
EOF
|
||||||
|
|
||||||
- name: 🏗 Setup Android SDK
|
- name: 🏗 Setup Android SDK
|
||||||
uses: android-actions/setup-android@v3
|
uses: android-actions/setup-android@v3
|
||||||
|
with:
|
||||||
|
cache-disabled: false
|
||||||
|
|
||||||
|
- name: ⚡ Cache Gradle dependencies
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches
|
||||||
|
~/.gradle/wrapper
|
||||||
|
~/.android/build-cache
|
||||||
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-gradle-
|
||||||
|
|
||||||
|
- name: ⚡ Configure Gradle for speed
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.gradle
|
||||||
|
cat > ~/.gradle/gradle.properties << EOF
|
||||||
|
org.gradle.daemon=false
|
||||||
|
org.gradle.parallel=true
|
||||||
|
org.gradle.configureondemand=true
|
||||||
|
org.gradle.jvmargs=-Xmx4g -XX:+HeapDumpOnOutOfMemoryError
|
||||||
|
android.useAndroidX=true
|
||||||
|
android.enableJetifier=true
|
||||||
|
android.enableR8.fullMode=true
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# 配置 Gradle 使用国内镜像
|
||||||
|
mkdir -p ~/.gradle/init.d
|
||||||
|
cat > ~/.gradle/init.d/mirror.gradle << EOF
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
all { ArtifactRepository repo ->
|
||||||
|
if (repo instanceof MavenArtifactRepository) {
|
||||||
|
def url = repo.url.toString()
|
||||||
|
if (url.startsWith('https://repo1.maven.org/maven2/') || url.startsWith('https://jcenter.bintray.com/') || url.startsWith('https://dl.google.com/dl/android/maven2/')) {
|
||||||
|
project.logger.lifecycle "Repository \${repo.url} replaced by https://maven.aliyun.com/repository/public/."
|
||||||
|
remove repo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maven { url 'https://maven.aliyun.com/repository/public/' }
|
||||||
|
maven { url 'https://maven.aliyun.com/repository/google/' }
|
||||||
|
maven { url 'https://maven.aliyun.com/repository/jcenter/' }
|
||||||
|
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
- name: 🏗 Setup EAS
|
- name: 🏗 Setup EAS
|
||||||
uses: expo/expo-github-action@v8
|
uses: expo/expo-github-action@v8
|
||||||
|
|||||||
Reference in New Issue
Block a user