@@ -236,7 +236,7 @@ jobs:
236236
237237 upload-to-gitlab-maven :
238238 runs-on : ubuntu-latest
239- # needs: [build] # 依赖于 build 作业成功
239+ needs : [build] # 依赖于 build 作业成功
240240 # if: github.event_name == 'push' && github.ref == 'refs/heads/master' # 仅当推送到 master 分支时执行
241241
242242 steps :
@@ -252,23 +252,24 @@ jobs:
252252 - name : Configure Maven for GitLab
253253 run : |
254254 mkdir -p ~/.m2
255- cat > ~/.m2/settings.xml <<EOF
256- <settings>
257- <servers>
258- <server>
259- <id>gitlab-maven</id>
260- <configuration>
261- <httpHeaders>
262- <property>
263- <name>Deploy-Token</name>
264- <value>${{ secrets.GITLAB_DEPLOY_TOKEN }}</value>
265- </property>
266- </httpHeaders>
267- </configuration>
268- </server>
269- </servers>
270- </settings>
271- EOF
255+ cat > ~/.m2/settings.xml << 'SETTINGS_XML'
256+ <?xml version="1.0" encoding="UTF-8"?>
257+ <settings>
258+ <servers>
259+ <server>
260+ <id>gitlab-maven</id>
261+ <configuration>
262+ <httpHeaders>
263+ <property>
264+ <name>Deploy-Token</name>
265+ <value>${{ secrets.GITLAB_DEPLOY_TOKEN }}</value>
266+ </property>
267+ </httpHeaders>
268+ </configuration>
269+ </server>
270+ </servers>
271+ </settings>
272+ SETTINGS_XML
272273
273274 - name : Upload POS SDK AARs to GitLab Maven
274275 env :
@@ -362,20 +363,23 @@ jobs:
362363 # 方法2: 使用 curl 作为备用方案
363364 echo "🔄 尝试使用 curl 上传..."
364365
365- # 创建临时 pom.xml
366- cat > /tmp/temp.pom << 'EOF'
367- <?xml version="1.0" encoding="UTF-8"?>
368- <project xmlns="http://maven.apache.org/POM/4.0.0"
369- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
370- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
371- http://maven.apache.org/xsd/maven-4.0.0.xsd">
372- <modelVersion>4.0.0</modelVersion>
373- <groupId>$groupId</groupId>
374- <artifactId>$artifactId</artifactId>
375- <version>$version</version>
376- <packaging>aar</packaging>
377- </project>
378- EOF
366+ # 使用 echo 创建临时 pom.xml,避免 heredoc
367+ echo '<?xml version="1.0" encoding="UTF-8"?>
368+ <project xmlns="http://maven.apache.org/POM/4.0.0"
369+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
370+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
371+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
372+ <modelVersion>4.0.0</modelVersion>
373+ <groupId>REPLACE_GROUPID</groupId>
374+ <artifactId>REPLACE_ARTIFACTID</artifactId>
375+ <version>REPLACE_VERSION</version>
376+ <packaging>aar</packaging>
377+ </project>' > /tmp/temp.pom
378+
379+ # 替换变量
380+ sed -i "s/REPLACE_GROUPID/$groupId/g" /tmp/temp.pom
381+ sed -i "s/REPLACE_ARTIFACTID/$artifactId/g" /tmp/temp.pom
382+ sed -i "s/REPLACE_VERSION/$version/g" /tmp/temp.pom
379383
380384 # 上传 AAR 文件
381385 echo "📤 上传 AAR 文件..."
0 commit comments