Files
jellyfin-plugin-smartnotify/.gitea/workflows/build-publish.yaml
2026-03-01 16:08:58 +01:00

124 lines
4.4 KiB
YAML

name: Build and Publish Plugin
on:
release:
types: [published]
permissions:
contents: write
jobs:
build:
name: Build Plugin + Update Manifest
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GT_TOKEN }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Set version from tag
id: vars
run: |
TAG="${{ gitea.event.release.tag_name }}"
VERSION="${TAG#v}" # Remove 'v' prefix
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "TAG=$TAG" >> "$GITHUB_ENV"
- name: Restore dependencies
run: dotnet restore
- name: Build plugin
run: |
dotnet publish Jellyfin.Plugin.SmartNotify/Jellyfin.Plugin.SmartNotify.csproj \
--configuration Release \
--output ./publish \
-p:Version=${VERSION}.0
- name: Create plugin ZIP
run: |
cd publish
zip -r ../smartnotify_${VERSION}.zip .
cd ..
# Calculate MD5 checksum
CHECKSUM=$(md5sum smartnotify_${VERSION}.zip | cut -d' ' -f1)
echo "CHECKSUM=$CHECKSUM" >> "$GITHUB_ENV"
echo "Checksum: $CHECKSUM"
- name: Upload ZIP to Release
env:
GIT_TOKEN: ${{ secrets.GT_TOKEN }}
run: |
# Get release ID
RELEASE_ID=$(curl -s "https://git.tdpi.dev/api/v1/repos/TDPI/jellyfin-plugin-smartnotify/releases/tags/${TAG}" \
-H "Authorization: token $GIT_TOKEN" | jq -r '.id')
# Upload asset
curl -X POST "https://git.tdpi.dev/api/v1/repos/TDPI/jellyfin-plugin-smartnotify/releases/${RELEASE_ID}/assets?name=smartnotify_${VERSION}.zip" \
-H "Authorization: token $GIT_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @smartnotify_${VERSION}.zip
- name: Update manifest.json
env:
GIT_TOKEN: ${{ secrets.GT_TOKEN }}
run: |
# Get changelog for this version
CHANGELOG=$(awk '/^## '"$VERSION"'/{flag=1} /^## / && flag && !/^## '"$VERSION"'/{exit} flag' CHANGELOG.md | tail -n +2)
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# Update manifest.json with new version
python3 << EOF
import json
with open('manifest.json', 'r') as f:
manifest = json.load(f)
new_version = {
"version": "${VERSION}.0",
"changelog": """${CHANGELOG}""".strip(),
"targetAbi": "10.11.0.0",
"sourceUrl": "https://git.tdpi.dev/TDPI/jellyfin-plugin-smartnotify/releases/download/${TAG}/smartnotify_${VERSION}.zip",
"checksum": "${CHECKSUM}",
"timestamp": "${TIMESTAMP}"
}
# Insert at beginning of versions array
manifest[0]["versions"].insert(0, new_version)
# Keep only last 10 versions
manifest[0]["versions"] = manifest[0]["versions"][:10]
with open('manifest.json', 'w') as f:
json.dump(manifest, f, indent=2, ensure_ascii=False)
print("Manifest updated successfully")
EOF
# Commit and push manifest
git config user.name "Gitea Actions"
git config user.email "actions@git.tdpi.dev"
git add manifest.json
git commit -m "chore: update manifest for ${TAG}"
git push https://x-access-token:${GIT_TOKEN}@git.tdpi.dev/TDPI/jellyfin-plugin-smartnotify.git HEAD:main
- name: Summary
run: |
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version:** ${VERSION}" >> $GITHUB_STEP_SUMMARY
echo "- **Checksum:** ${CHECKSUM}" >> $GITHUB_STEP_SUMMARY
echo "- **Target ABI:** 10.11.0.0" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Manifest URL" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "https://git.tdpi.dev/TDPI/jellyfin-plugin-smartnotify/raw/branch/main/manifest.json" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY