Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0b8f8650b | ||
|
|
3a7b5a0f9a | ||
|
|
999a595b9c | ||
|
|
e6f705486d |
@@ -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,32 @@ 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 with wget
|
||||||
RELEASE_JSON=$(curl -s -X GET \
|
echo "Creating new release..."
|
||||||
-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)
|
# Create JSON payload in a temp file
|
||||||
|
cat > /tmp/release.json << 'PAYLOAD'
|
||||||
|
{"tag_name":"TAG_PLACEHOLDER","name":"Release TAG_PLACEHOLDER","draft":false,"prerelease":false}
|
||||||
|
PAYLOAD
|
||||||
|
sed -i "s/TAG_PLACEHOLDER/$TAG/g" /tmp/release.json
|
||||||
|
|
||||||
|
RESPONSE=$(wget --post-file=/tmp/release.json \
|
||||||
|
--header="Authorization: token $GITEA_TOKEN" \
|
||||||
|
--header="Content-Type: application/json" \
|
||||||
|
-O - -q \
|
||||||
|
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases")
|
||||||
|
|
||||||
|
# Extract release ID using grep
|
||||||
|
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*')
|
||||||
|
|
||||||
if [ -z "$RELEASE_ID" ]; then
|
if [ -z "$RELEASE_ID" ]; then
|
||||||
echo "Creating new release..."
|
echo "Failed to create release. Response:"
|
||||||
RELEASE_JSON=$(curl -s -X POST \
|
echo "$RESPONSE"
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
exit 1
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{\"tag_name\":\"$TAG\",\"name\":\"Release $TAG\",\"draft\":false,\"prerelease\":false}" \
|
|
||||||
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases")
|
|
||||||
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id')
|
|
||||||
echo "Created release ID: $RELEASE_ID"
|
|
||||||
else
|
|
||||||
echo "Using existing release ID: $RELEASE_ID"
|
|
||||||
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 +136,18 @@ jobs:
|
|||||||
filename=$(basename "$file")
|
filename=$(basename "$file")
|
||||||
echo " Uploading: $filename"
|
echo " Uploading: $filename"
|
||||||
|
|
||||||
curl -s -X POST \
|
# Upload binary file to Gitea API
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
UPLOAD_RESPONSE=$(wget --post-file="$file" \
|
||||||
-F "attachment=@$file" \
|
--header="Authorization: token $GITEA_TOKEN" \
|
||||||
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases/$RELEASE_ID/assets" > /dev/null
|
--header="Content-Type: application/octet-stream" \
|
||||||
|
-O - -q \
|
||||||
|
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases/$RELEASE_ID/assets?name=$filename" 2>&1)
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
if echo "$UPLOAD_RESPONSE" | grep -q '"id"'; then
|
||||||
echo " ✓ $filename uploaded"
|
echo " ✓ $filename uploaded"
|
||||||
else
|
else
|
||||||
echo " ✗ Failed to upload $filename"
|
echo " ✗ Failed to upload $filename"
|
||||||
|
echo "Response: $UPLOAD_RESPONSE"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user