Skip to content

Test Fake Release

Test Fake Release #2

Workflow file for this run

name: Test Fake Release
on:
workflow_dispatch:
inputs:
fake_version:
description: 'Fake Version Name (e.g. v-test-01)'
required: true
default: 'v-test-01'
jobs:
test-fake-upload:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Create Dummy Assets
run: |
mkdir assets
echo "Test File 1" > assets/Fake-Setup.exe
echo "Test File 2" > assets/Fake-Portable.zip
- name: Push Tag to Codeberg
run: |
git config --global user.name "Test Bot"
git config --global user.email "[email protected]"
git remote add codeberg "https://M-Rajabi-Dev:${{ secrets.CODEBERG_TOKEN }}@codeberg.org/M-Rajabi-Dev/AudioShelf.git"
# ساخت تگ و ارسال
git tag -f ${{ inputs.fake_version }}
git push -f codeberg ${{ inputs.fake_version }}
- name: Create Release & Upload (Pure 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"
# 1. پیدا کردن ID ریلیز قدیمی (اگه باشه) و حذفش
OLD_ID=$(curl -s "$API_URL" | jq -r ".[] | select(.tag_name==\"$TAG\") | .id")
if [ ! -z "$OLD_ID" ] && [ "$OLD_ID" != "null" ]; then
echo "Deleting old release ID: $OLD_ID"
curl -X DELETE "$API_URL/$OLD_ID" -H "Authorization: token $CB_TOKEN"
fi
# 2. ساخت ریلیز جدید
echo "Creating new release..."
RESPONSE=$(curl -s -X POST "$API_URL" \
-H "Authorization: token $CB_TOKEN" \
-H "Content-Type: application/json" \
-d "{ \"tag_name\": \"$TAG\", \"name\": \"TEST RELEASE $TAG\", \"body\": \"Test upload via Curl\" }")
NEW_ID=$(echo $RESPONSE | jq -r .id)
echo "Created Release ID: $NEW_ID"
# 3. آپلود فایل‌ها
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