1+ name : Test Fake Release
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ fake_version :
7+ description : ' Fake Version Name'
8+ required : true
9+ default : ' v-test-final'
10+
11+ jobs :
12+ test-fix-upload :
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : Checkout Code
16+ uses : actions/checkout@v3
17+
18+ - name : Create Dummy Assets
19+ run : |
20+ mkdir assets
21+ echo "Final Test File" > assets/Fake-Setup.exe
22+ echo "Final Test Zip" > assets/Fake-Portable.zip
23+
24+ - name : Push Tag to Codeberg (Auth Fix)
25+ run : |
26+ git config --global user.name "GitHub Action"
27+ git config --global user.email "[email protected] " 28+
29+ # این روش احراز هویت ۱۰۰٪ کار میکنه و گیر نمیکنه
30+ git config --global http.extraheader "AUTHORIZATION: basic $(echo -n "M-Rajabi-Dev:${{ secrets.CODEBERG_TOKEN }}" | base64)"
31+
32+ git remote add codeberg "https://codeberg.org/M-Rajabi-Dev/AudioShelf.git"
33+
34+ # ساخت تگ و ارسال زورکی
35+ git tag -f ${{ inputs.fake_version }}
36+ git push -f codeberg ${{ inputs.fake_version }}
37+
38+ - name : Create Release & Upload (Curl)
39+ env :
40+ CB_TOKEN : ${{ secrets.CODEBERG_TOKEN }}
41+ REPO : ' M-Rajabi-Dev/AudioShelf'
42+ TAG : ${{ inputs.fake_version }}
43+ run : |
44+ API_URL="https://codeberg.org/api/v1/repos/$REPO/releases"
45+
46+ # حذف ریلیز تستی قدیمی اگر مونده باشه
47+ OLD_ID=$(curl -s "$API_URL" | jq -r ".[] | select(.tag_name==\"$TAG\") | .id")
48+ if [ ! -z "$OLD_ID" ] && [ "$OLD_ID" != "null" ]; then
49+ curl -X DELETE "$API_URL/$OLD_ID" -H "Authorization: token $CB_TOKEN"
50+ fi
51+
52+ # ساخت ریلیز جدید
53+ RESPONSE=$(curl -s -X POST "$API_URL" \
54+ -H "Authorization: token $CB_TOKEN" \
55+ -H "Content-Type: application/json" \
56+ -d "{ \"tag_name\": \"$TAG\", \"name\": \"FINAL TEST $TAG\", \"body\": \"Test upload via Header Auth\" }")
57+
58+ NEW_ID=$(echo $RESPONSE | jq -r .id)
59+
60+ if [ "$NEW_ID" == "null" ]; then
61+ echo "Error creating release. Response: $RESPONSE"
62+ exit 1
63+ fi
64+
65+ # آپلود فایلها
66+ cd assets
67+ for file in *; do
68+ echo "Uploading $file..."
69+ curl -f -X POST "$API_URL/$NEW_ID/assets?name=$file" \
70+ -H "Authorization: token $CB_TOKEN" \
71+ -H "Content-Type: multipart/form-data" \
72+ -F "attachment=@$file"
73+ done
0 commit comments