Skip to content

Test Fake Release

Test Fake Release #3

Workflow file for this run

name: Test Fake Release
on:
workflow_dispatch:
inputs:
fake_version:
description: 'Fake Version Name'
required: true
default: 'v-test-final'
jobs:
test-fix-upload:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Create Dummy Assets
run: |
mkdir assets
echo "Final Test File" > assets/Fake-Setup.exe
echo "Final Test Zip" > assets/Fake-Portable.zip
- name: Push Tag to Codeberg (Auth Fix)
run: |
git config --global user.name "GitHub Action"
git config --global user.email "[email protected]"
# این روش احراز هویت ۱۰۰٪ کار می‌کنه و گیر نمی‌کنه
git config --global http.extraheader "AUTHORIZATION: basic $(echo -n "M-Rajabi-Dev:${{ secrets.CODEBERG_TOKEN }}" | base64)"
git remote add codeberg "https://codeberg.org/M-Rajabi-Dev/AudioShelf.git"
# ساخت تگ و ارسال زورکی
git tag -f ${{ inputs.fake_version }}
git push -f codeberg ${{ inputs.fake_version }}
- name: Create Release & Upload (Curl)
env:
CB_TOKEN: ${{ secrets.CODEBERG_TOKEN }}
REPO: 'M-Rajabi-Dev/AudioShelf'
TAG: ${{ inputs.fake_version }}
run: |
API_URL="https://codeberg.org/api/v1/repos/$REPO/releases"
# حذف ریلیز تستی قدیمی اگر مونده باشه
OLD_ID=$(curl -s "$API_URL" | jq -r ".[] | select(.tag_name==\"$TAG\") | .id")
if [ ! -z "$OLD_ID" ] && [ "$OLD_ID" != "null" ]; then
curl -X DELETE "$API_URL/$OLD_ID" -H "Authorization: token $CB_TOKEN"
fi
# ساخت ریلیز جدید
RESPONSE=$(curl -s -X POST "$API_URL" \
-H "Authorization: token $CB_TOKEN" \
-H "Content-Type: application/json" \
-d "{ \"tag_name\": \"$TAG\", \"name\": \"FINAL TEST $TAG\", \"body\": \"Test upload via Header Auth\" }")
NEW_ID=$(echo $RESPONSE | jq -r .id)
if [ "$NEW_ID" == "null" ]; then
echo "Error creating release. Response: $RESPONSE"
exit 1
fi
# آپلود فایل‌ها
cd assets
for file in *; do
echo "Uploading $file..."
curl -f -X POST "$API_URL/$NEW_ID/assets?name=$file" \
-H "Authorization: token $CB_TOKEN" \
-H "Content-Type: multipart/form-data" \
-F "attachment=@$file"
done