Skip to content

Commit 318cc76

Browse files
committed
v1.4.2
1 parent 1f9720a commit 318cc76

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

.github/workflows/build-and-release.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,24 +177,51 @@ jobs:
177177
name: base-artifacts
178178
path: base
179179

180-
- name: Download Temurin JDK 8 (${{ matrix.suffix }})
180+
- name: Download JDK 8 (${{ matrix.suffix }})
181181
run: |
182-
# 使用 Eclipse Adoptium API 获取最新的 JDK 8 下载链接
182+
# 默认使用 Adoptium API
183183
API_URL="https://api.adoptium.net/v3/binary/latest/8/ga/${{ matrix.os_api }}/${{ matrix.arch_api }}/jdk/hotspot/normal/eclipse"
184184
185+
# 特殊处理:如果遇到 macOS aarch64,改用 Azul Zulu 下载链接
186+
if [ "${{ matrix.os_api }}" == "mac" ] && [ "${{ matrix.arch_api }}" == "aarch64" ]; then
187+
echo "Detected macOS aarch64 (Apple Silicon). Adoptium does not provide JDK 8 for this arch."
188+
echo "Switching to Azul Zulu OpenJDK 8..."
189+
# Azul Zulu JDK 8 for macOS ARM64 (这是直接下载链接,版本可能会变,建议使用 latest API 或固定版本)
190+
# 为了稳定性,这里使用 Azul 的 API 获取最新 JDK 8 LTS
191+
API_URL="https://api.azul.com/zulu/download/community/v1.0/bundles/latest/binary/?jdk_version=8&os=macos&arch=arm64&bundle_type=jdk&ext=tar.gz"
192+
fi
193+
185194
echo "Fetching JDK from: $API_URL"
186195
187196
if [ "${{ matrix.ext }}" == "zip" ]; then
197+
# Windows
188198
curl -L "$API_URL" -o jdk_bundle.zip
189199
unzip -q jdk_bundle.zip -d jdk_extracted
190200
else
201+
# Linux / Mac
191202
curl -L "$API_URL" -o jdk_bundle.tar.gz
192203
mkdir jdk_extracted
193204
tar -xzf jdk_bundle.tar.gz -C jdk_extracted
194205
fi
195206
196207
# 重命名提取出的 JDK 目录为统一名称 'jdk'
197-
mv jdk_extracted/* jdk_final
208+
# 注意:Azul 和 Adoptium 解压后的目录结构可能略有不同,需要通配符处理
209+
# Azul 通常解压后是 zulu8.xx.xx-ca-jdk8.0.xx-macosx_aarch64
210+
# Adoptium 解压后是 jdk8uXXX-bXX
211+
212+
# 找到 jdk_extracted 下唯一的子目录并移动内容
213+
SUBDIR=$(ls jdk_extracted | head -n 1)
214+
mv "jdk_extracted/$SUBDIR" jdk_final
215+
216+
# macOS 特殊处理:macOS 的 JDK 结构通常是 /Contents/Home 才是真正的 JAVA_HOME
217+
if [ "${{ matrix.os_api }}" == "mac" ]; then
218+
if [ -d "jdk_final/Contents/Home" ]; then
219+
echo "Detected macOS bundle structure. Adjusting root..."
220+
mv jdk_final/Contents/Home jdk_real
221+
rm -rf jdk_final
222+
mv jdk_real jdk_final
223+
fi
224+
fi
198225
199226
- name: Create Distribution Structure
200227
run: |
@@ -216,7 +243,6 @@ jobs:
216243
if: matrix.os_api != 'windows'
217244
run: |
218245
cd ${{ env.DIST_DIR }}
219-
# 创建启动脚本,强制使用内置 JDK
220246
cat <<EOF > start.sh
221247
#!/bin/bash
222248
BASE_DIR=\$(cd "\$(dirname "\$0")" && pwd)

0 commit comments

Comments
 (0)