2 Commits

Author SHA1 Message Date
Ducky SSH User
999a595b9c Remove jq dependency from release workflow
Some checks failed
Build and Release / build (push) Failing after 12s
- Replace jq with grep for parsing JSON responses
- Use curl -w to capture HTTP response codes
- Improve error handling and logging
- Check HTTP response codes for upload success
- Should work on runners without jq installed
- Fixes 'command not found' error on release creation
2025-12-20 06:28:25 +00:00
Ducky SSH User
e6f705486d Fix git tag checkout in Gitea Actions workflow
Some checks failed
Build and Release / build (push) Failing after 10s
- For tags: fetch with explicit ref mapping to refs/tags/
- For branches: fetch with explicit ref mapping to refs/remotes/origin/
- Properly checkout tag refs using refs/tags/ path
- Fixes 'pathspec did not match any file(s)' error on tag builds
2025-12-20 06:24:56 +00:00

View File

@@ -17,10 +17,14 @@ jobs:
cd $GITHUB_WORKSPACE cd $GITHUB_WORKSPACE
git init git init
git remote add origin ${{ github.server_url }}/${{ github.repository }}.git git remote add origin ${{ github.server_url }}/${{ github.repository }}.git
git fetch origin ${{ github.ref }}
if [[ "${{ github.ref }}" == refs/tags/* ]]; then if [[ "${{ github.ref }}" == refs/tags/* ]]; then
git checkout ${{ github.ref_name }} # For tags, fetch the specific tag and checkout the commit it points to
git fetch origin ${{ github.ref }}:refs/tags/${{ github.ref_name }}
git checkout refs/tags/${{ github.ref_name }}
else else
# For branches, fetch and checkout with tracking
git fetch origin ${{ github.ref_name }}:refs/remotes/origin/${{ github.ref_name }}
git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }} git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
fi fi
@@ -99,26 +103,25 @@ jobs:
echo "Creating release for tag: $TAG" echo "Creating release for tag: $TAG"
echo "Repository: $REPO_OWNER/$REPO_NAME" echo "Repository: $REPO_OWNER/$REPO_NAME"
# Get or create release # Create release using Gitea API
RELEASE_JSON=$(curl -s -X GET \
-H "Authorization: token $GITEA_TOKEN" \
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases/tags/$TAG" 2>/dev/null || echo "{}")
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id // empty' 2>/dev/null)
if [ -z "$RELEASE_ID" ]; then
echo "Creating new release..." echo "Creating new release..."
RELEASE_JSON=$(curl -s -X POST \ RESPONSE=$(curl -s -X POST \
-H "Authorization: token $GITEA_TOKEN" \ -H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG\",\"name\":\"Release $TAG\",\"draft\":false,\"prerelease\":false}" \ -d "{\"tag_name\":\"$TAG\",\"name\":\"Release $TAG\",\"draft\":false,\"prerelease\":false}" \
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases") "$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases")
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id')
echo "Created release ID: $RELEASE_ID" # Extract release ID using grep instead of jq
else RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*')
echo "Using existing release ID: $RELEASE_ID"
if [ -z "$RELEASE_ID" ]; then
echo "Failed to create release. Response:"
echo "$RESPONSE"
exit 1
fi fi
echo "Created release ID: $RELEASE_ID"
# Upload all binaries # Upload all binaries
echo "Uploading release artifacts..." echo "Uploading release artifacts..."
for file in bin/*; do for file in bin/*; do
@@ -126,15 +129,18 @@ jobs:
filename=$(basename "$file") filename=$(basename "$file")
echo " Uploading: $filename" echo " Uploading: $filename"
curl -s -X POST \ UPLOAD_RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
-H "Authorization: token $GITEA_TOKEN" \ -H "Authorization: token $GITEA_TOKEN" \
-F "attachment=@$file" \ -F "attachment=@$file" \
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases/$RELEASE_ID/assets" > /dev/null "$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases/$RELEASE_ID/assets")
if [ $? -eq 0 ]; then HTTP_CODE=$(echo "$UPLOAD_RESPONSE" | tail -n 1)
echo " ✓ $filename uploaded"
if [ "$HTTP_CODE" = "201" ] || [ "$HTTP_CODE" = "200" ]; then
echo " ✓ $filename uploaded (HTTP $HTTP_CODE)"
else else
echo " ✗ Failed to upload $filename" echo " ✗ Failed to upload $filename (HTTP $HTTP_CODE)"
echo "Response: $(echo "$UPLOAD_RESPONSE" | head -n -1)"
fi fi
fi fi
done done