Compare commits
5
Commits
test-v0.0.1
...
v1.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43277c5c67 | ||
|
|
3cc811cd8e | ||
|
|
56298d080f | ||
|
|
5cafc3b41c | ||
|
|
8971e8885d |
@@ -50,53 +50,48 @@ jobs:
|
|||||||
echo "APK_FILE=$APK_FILE" >> $GITHUB_ENV
|
echo "APK_FILE=$APK_FILE" >> $GITHUB_ENV
|
||||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Create or Update Release
|
- name: Debug Network
|
||||||
id: create_release
|
|
||||||
env:
|
|
||||||
GITEA_USER: ${{ secrets.GITEAUSER }}
|
|
||||||
GITEA_PASS: ${{ secrets.GITEAPASS }}
|
|
||||||
run: |
|
run: |
|
||||||
VERSION=${{ env.VERSION }}
|
echo "Testing network connectivity..."
|
||||||
REPO="${{ github.repository }}"
|
ping -c 2 gitea.kg8.net || echo "ping failed"
|
||||||
|
curl -v "https://gitea.kg8.net/api/v1/version" 2>&1 | head -20 || echo "curl failed"
|
||||||
echo "Creating release for $VERSION..."
|
|
||||||
|
|
||||||
# 检查 Release 是否已存在
|
|
||||||
EXISTING=$(curl -s -u "$GITEA_USER:$GITEA_PASS" "https://gitea.kg8.net/api/v1/repos/$REPO/releases/tags/$VERSION")
|
|
||||||
RELEASE_ID=$(echo "$EXISTING" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
|
||||||
|
|
||||||
if [ -n "$RELEASE_ID" ]; then
|
|
||||||
echo "Release 已存在 (ID: $RELEASE_ID),删除旧的..."
|
|
||||||
curl -s -X DELETE -u "$GITEA_USER:$GITEA_PASS" "https://gitea.kg8.net/api/v1/repos/$REPO/releases/$RELEASE_ID"
|
|
||||||
sleep 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 创建新的 Release
|
|
||||||
RESPONSE=$(curl -s -X POST "https://gitea.kg8.net/api/v1/repos/$REPO/releases" \
|
|
||||||
-u "$GITEA_USER:$GITEA_PASS" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{\"tag_name\":\"$VERSION\",\"name\":\"Release $VERSION\",\"draft\":false,\"prerelease\":false}")
|
|
||||||
|
|
||||||
echo "Response: $RESPONSE"
|
|
||||||
|
|
||||||
NEW_RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
|
||||||
|
|
||||||
if [ -z "$NEW_RELEASE_ID" ]; then
|
|
||||||
echo "❌ Failed to create release"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "release_id=$NEW_RELEASE_ID" >> $GITHUB_OUTPUT
|
|
||||||
echo "✅ Release 创建成功 (ID: $NEW_RELEASE_ID)"
|
|
||||||
|
|
||||||
- name: Upload APK
|
- name: Create Release and Upload APK
|
||||||
env:
|
env:
|
||||||
GITEA_USER: ${{ secrets.GITEAUSER }}
|
AUTH: ${{ secrets.AUTHB64 }}
|
||||||
GITEA_PASS: ${{ secrets.GITEAPASS }}
|
VERSION: ${{ env.VERSION }}
|
||||||
|
APK_FILE: ${{ env.APK_FILE }}
|
||||||
|
REPO: ${{ github.repository }}
|
||||||
run: |
|
run: |
|
||||||
echo "Uploading: ${{ env.APK_FILE }}"
|
echo "Creating release for ${VERSION}..."
|
||||||
ls -lh ${{ env.APK_FILE }}
|
|
||||||
curl -s -X POST "https://gitea.kg8.net/api/v1/repos/${{ github.repository }}/releases/${{ steps.create_release.outputs.release_id }}/assets" \
|
# 尝试不同的 API endpoint
|
||||||
-u "$GITEA_USER:$GITEA_PASS" \
|
for API_URL in "https://gitea.kg8.net/api/v1" "http://localhost:3000/api/v1" "http://127.0.0.1:3000/api/v1"; do
|
||||||
-F "attachment=@${{ env.APK_FILE }}"
|
echo "Trying: ${API_URL}"
|
||||||
echo '✅ APK 上传成功!'
|
RESPONSE=$(curl -s -X POST "${API_URL}/repos/${REPO}/releases" \
|
||||||
|
-H "Authorization: Basic ${AUTH}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"${VERSION}\",\"name\":\"Release ${VERSION}\",\"draft\":false,\"prerelease\":false}" \
|
||||||
|
--connect-timeout 5)
|
||||||
|
|
||||||
|
echo "Response: ${RESPONSE}"
|
||||||
|
|
||||||
|
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
||||||
|
|
||||||
|
if [ -n "$RELEASE_ID" ]; then
|
||||||
|
echo "✅ Release 创建成功 (ID: ${RELEASE_ID}) via ${API_URL}"
|
||||||
|
|
||||||
|
# 上传 APK
|
||||||
|
echo "Uploading APK: ${APK_FILE}"
|
||||||
|
UPLOAD_RESPONSE=$(curl -s -X POST "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets" \
|
||||||
|
-H "Authorization: Basic ${AUTH}" \
|
||||||
|
-F "attachment=@${APK_FILE}")
|
||||||
|
|
||||||
|
echo "Upload Response: ${UPLOAD_RESPONSE}"
|
||||||
|
echo '✅ APK 上传成功!'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "❌ Failed to create release on all endpoints"
|
||||||
|
exit 1
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Reference in New Issue
Block a user