fix: Replace gh CLI with direct Gitea API calls (curl)
Root cause found via SSH log analysis (actions_log/.../2326.log):
'gh release create' failed with exit code 127 (command not found).
The act_runner Docker image used for jobs does not ship the
GitHub CLI (gh), so any step relying on it fails immediately.
Fix: Replace gh CLI calls with direct Gitea REST API calls using
curl, which is available in the base image:
1. POST /repos/{repo}/releases -- create release, parse id via python3
2. POST /repos/{repo}/releases/{id}/assets -- upload artifact as multipart
This removes the gh CLI dependency entirely and matches how
deploy-prod.yml already talks to Gitea (curl + REST API).
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user