diff --git a/.gitea/workflows/prepare-release.yml b/.gitea/workflows/prepare-release.yml index 73a63453..a04980e6 100644 --- a/.gitea/workflows/prepare-release.yml +++ b/.gitea/workflows/prepare-release.yml @@ -125,26 +125,39 @@ jobs: env: VERSION: ${{ steps.metadata.outputs.version }} COMMIT: ${{ steps.metadata.outputs.commit }} - GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }} + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} run: | ARTIFACT="quantengine_${VERSION}.tar.gz" + API="https://gitea.taxbaik.com/api/v1" + REPO="kjh2064/QuantEngineByItz" - echo "Checking artifact..." - ls -lh "$ARTIFACT" || echo "⚠️ Artifact not found: $ARTIFACT" + test -s "$ARTIFACT" || { echo "ERROR: artifact missing: $ARTIFACT"; exit 1; } - echo "" - echo "Checking gh CLI..." - which gh || echo "⚠️ gh CLI not found" - gh version || echo "⚠️ gh version failed" + echo "Creating release $VERSION via Gitea API..." + RELEASE_JSON=$(curl -sf -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + -d "{\"tag_name\":\"${VERSION}\",\"name\":\"Release ${VERSION}\",\"body\":\"Release Version: ${VERSION} | Commit: ${COMMIT}\",\"target_commitish\":\"main\"}" \ + "${API}/repos/${REPO}/releases") - echo "" - echo "Creating release..." - gh release create "$VERSION" "$ARTIFACT" \ - --title "Release $VERSION" \ - --notes "Release Version: $VERSION | Commit: ${COMMIT}" \ - --repo kjh2064/QuantEngineByItz + RELEASE_ID=$(echo "$RELEASE_JSON" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])") + + if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then + echo "ERROR: Failed to create release" + echo "$RELEASE_JSON" + exit 1 + fi + + echo "✓ Release created: $VERSION (id: $RELEASE_ID)" + + echo "Uploading artifact..." + curl -sf -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: multipart/form-data" \ + -F "attachment=@${ARTIFACT}" \ + "${API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${ARTIFACT}" \ + -o /dev/null - echo "✓ Release created: $VERSION" echo "✓ Artifact attached: $ARTIFACT" notification: