feat: 使用 Gitea API 直接创建 Release(替代 actions/create-release)
This commit is contained in:
@@ -56,34 +56,43 @@ jobs:
|
|||||||
VERSION=${GITHUB_REF#refs/tags/}
|
VERSION=${GITHUB_REF#refs/tags/}
|
||||||
cp app/build/outputs/apk/release/app-release-unsigned.apk app/build/outputs/apk/release/app-${VERSION}-unsigned.apk
|
cp app/build/outputs/apk/release/app-release-unsigned.apk app/build/outputs/apk/release/app-${VERSION}-unsigned.apk
|
||||||
echo "APK_NAME=app-${VERSION}-unsigned.apk" >> $GITHUB_ENV
|
echo "APK_NAME=app-${VERSION}-unsigned.apk" >> $GITHUB_ENV
|
||||||
|
echo "APK_VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
echo "⚠️ 注意:生成的是未签名 APK,仅用于测试。生产环境请配置签名。"
|
echo "⚠️ 注意:生成的是未签名 APK,仅用于测试。生产环境请配置签名。"
|
||||||
|
|
||||||
- name: Create Gitea Release
|
- name: Create Gitea Release
|
||||||
id: create_release
|
id: create_release
|
||||||
uses: actions/create-release@v1
|
run: |
|
||||||
env:
|
VERSION=${GITHUB_REF#refs/tags/}
|
||||||
ACTIONS_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
|
echo "Creating release: $VERSION"
|
||||||
with:
|
|
||||||
tag_name: ${{ github.ref }}
|
|
||||||
release_name: Release ${{ github.ref }}
|
|
||||||
draft: false
|
|
||||||
prerelease: false
|
|
||||||
body: |
|
|
||||||
## 自动发布的 Release
|
|
||||||
|
|
||||||
- 版本:${{ github.ref }}
|
# 使用 Gitea API 创建 Release
|
||||||
- 提交:${{ github.sha }}
|
RESPONSE=$(curl -s -X POST "https://gitea.kg8.net/api/v1/repos/amos/android-ci-demo/releases" \
|
||||||
- 编译时间:${{ github.event.head_commit.timestamp }}
|
-H "Authorization: token ${{ secrets.ACTIONS_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{
|
||||||
|
\"tag_name\": \"$VERSION\",
|
||||||
|
\"name\": \"Release $VERSION\",
|
||||||
|
\"body\": \"## 自动发布的 Release\n\n- 版本:$VERSION\n- 提交:${{ github.sha }}\n\n### 变更\n${{ github.event.head_commit.message }}\",
|
||||||
|
\"draft\": false,
|
||||||
|
\"prerelease\": false
|
||||||
|
}")
|
||||||
|
|
||||||
### 变更日志
|
echo "Response: $RESPONSE"
|
||||||
${{ github.event.head_commit.message }}
|
|
||||||
|
# 提取 upload_url
|
||||||
|
UPLOAD_URL=$(echo $RESPONSE | grep -o '"upload_url":"[^"]*"' | cut -d'"' -f4)
|
||||||
|
echo "Upload URL: $UPLOAD_URL"
|
||||||
|
echo "UPLOAD_URL=$UPLOAD_URL" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Upload Release APK
|
- name: Upload Release APK
|
||||||
uses: actions/upload-release-asset@v1
|
run: |
|
||||||
env:
|
echo "Uploading APK: ${{ env.APK_NAME }}"
|
||||||
ACTIONS_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
|
echo "Upload URL: ${{ env.UPLOAD_URL }}"
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
# 上传 APK 到 Release
|
||||||
asset_path: app/build/outputs/apk/release/${{ env.APK_NAME }}
|
curl -s -X POST "${{ env.UPLOAD_URL }}?name=${{ env.APK_NAME }}" \
|
||||||
asset_name: ${{ env.APK_NAME }}
|
-H "Authorization: token ${{ secrets.ACTIONS_TOKEN }}" \
|
||||||
asset_content_type: application/vnd.android.package-archive
|
-H "Content-Type: application/vnd.android.package-archive" \
|
||||||
|
--data-binary "@app/build/outputs/apk/release/${{ env.APK_NAME }}"
|
||||||
|
|
||||||
|
echo "✅ APK uploaded successfully!"
|
||||||
|
|||||||
Reference in New Issue
Block a user