Files
blackBarRemover/.gitea/workflows/release.yml
T
karol b7693b606e
Build and Release Plugin / release (push) Failing after 34s
fix: replace release assets cleanly in Gitea Action
2026-09-17 21:09:12 +02:00

136 lines
5.4 KiB
YAML

name: Build and Release Plugin
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
9.0.x
10.0.x
- name: Build Plugin
run: dotnet build JellyfinPlugin/JellyfinPlugin.csproj -c Release
- name: Create ZIP Archives
run: |
cd JellyfinPlugin/bin/Release/
# Zip net9.0 (Jellyfin 10.11)
cd net9.0
zip -j ../../../../BlackBarRemover_${{ github.ref_name }}_jf10.11.zip *
cd ..
# Zip net10.0 (Jellyfin 12.0)
cd net10.0
zip -j ../../../../BlackBarRemover_${{ github.ref_name }}_jf12.0.zip *
cd ..
- name: Generate Checksums
id: checksum
run: |
MD5_SUM_9=$(md5sum BlackBarRemover_${{ github.ref_name }}_jf10.11.zip | awk '{print $1}')
MD5_SUM_10=$(md5sum BlackBarRemover_${{ github.ref_name }}_jf12.0.zip | awk '{print $1}')
echo "md5_9=$MD5_SUM_9" >> $GITHUB_OUTPUT
echo "md5_10=$MD5_SUM_10" >> $GITHUB_OUTPUT
- name: Create Gitea Release
run: |
API_URL="${{ github.api_url }}"
REPO="${{ github.repository }}"
TOKEN="${{ github.token }}"
TAG="${{ github.ref_name }}"
IS_PRERELEASE="false"
if [[ "$TAG" == *"beta"* ]] || [[ "$TAG" == *"alpha"* ]] || [[ "$TAG" == v0.* ]]; then
IS_PRERELEASE="true"
fi
# Check if release exists
EXISTING_REL=$(curl -s -H "Authorization: token $TOKEN" "$API_URL/repos/$REPO/releases/tags/$TAG")
REL_ID=$(echo "$EXISTING_REL" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
if [ -z "$REL_ID" ] || [ "$REL_ID" == "null" ]; then
RELEASE_RES=$(curl -s -X POST "$API_URL/repos/$REPO/releases" \
-H "Authorization: token $TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG\", \"name\":\"Release $TAG\", \"body\":\"Automated release\", \"draft\":false, \"prerelease\":$IS_PRERELEASE}")
REL_ID=$(echo "$RELEASE_RES" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
fi
# Delete existing assets for this release if present
ASSETS=$(curl -s -H "Authorization: token $TOKEN" "$API_URL/repos/$REPO/releases/$REL_ID/assets")
echo "$ASSETS" | grep -o '"id":[0-9]*' | cut -d':' -f2 | while read -r asset_id; do
if [ -n "$asset_id" ]; then
curl -s -X DELETE -H "Authorization: token $TOKEN" "$API_URL/repos/$REPO/releases/$REL_ID/assets/$asset_id"
fi
done
# Upload Assets
curl -s -X POST "$API_URL/repos/$REPO/releases/$REL_ID/assets" \
-H "Authorization: token $TOKEN" \
-F "attachment=@BlackBarRemover_${TAG}_jf10.11.zip"
curl -s -X POST "$API_URL/repos/$REPO/releases/$REL_ID/assets" \
-H "Authorization: token $TOKEN" \
-F "attachment=@BlackBarRemover_${TAG}_jf12.0.zip"
- name: Update manifest.json
run: |
git config user.name "Gitea Actions"
git config user.email "actions@gitea.local"
git checkout -B manifest
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
CLEAN_VERSION="${VERSION%%-*}"
cat > manifest.json <<EOF
[
{
"guid": "12345678-1234-1234-1234-1234567890ab",
"name": "Black Bar Remover",
"description": "Automatically detects and removes black bars from video files.",
"overview": "Automatically detects and removes black bars from video files via CSS or FFmpeg.",
"owner": "karol",
"category": "Playback",
"imageUrl": "",
"versions": [
{
"version": "$CLEAN_VERSION",
"changelog": "Automated Release ${{ github.ref_name }} (Jellyfin 12.0)",
"targetAbi": "12.0.0.0",
"sourceUrl": "https://gitea.labus.uk/karol/blackBarRemover/releases/download/${{ github.ref_name }}/BlackBarRemover_${{ github.ref_name }}_jf12.0.zip",
"checksum": "${{ steps.checksum.outputs.md5_10 }}",
"timestamp": "$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
},
{
"version": "$CLEAN_VERSION",
"changelog": "Automated Release ${{ github.ref_name }} (Jellyfin 10.11)",
"targetAbi": "10.11.0.0",
"sourceUrl": "https://gitea.labus.uk/karol/blackBarRemover/releases/download/${{ github.ref_name }}/BlackBarRemover_${{ github.ref_name }}_jf10.11.zip",
"checksum": "${{ steps.checksum.outputs.md5_9 }}",
"timestamp": "$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
}
]
}
]
EOF
git add manifest.json
git commit -m "Update manifest for ${{ github.ref_name }}"
git push -f origin manifest