name: '🚀 Release Plugin' on: push: tags: - 'v*.*.*' workflow_dispatch: inputs: version: description: 'Version to release (e.g., v1.0.0)' required: true type: string jobs: build-and-release: runs-on: ubuntu-latest container: image: gitea.tourolle.paris/dtourolle/srfplay-builder:latest steps: - name: Checkout repository uses: actions/checkout@v4 with: path: release-${{ github.run_id }} - name: Get version id: get_version run: | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then VERSION="${{ github.event.inputs.version }}" else VERSION="${GITHUB_REF#refs/tags/}" fi echo "version=${VERSION}" >> $GITHUB_OUTPUT echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT echo "Building version: ${VERSION}" - name: Cache NuGet packages uses: actions/cache@v3 with: path: ~/.nuget/packages key: nuget-${{ hashFiles('**/Jellyfin.Plugin.SRFPlay.csproj', '**/Jellyfin.Plugin.SRFPlay.Tests.csproj') }} restore-keys: nuget- - name: Restore dependencies working-directory: release-${{ github.run_id }} run: dotnet restore Jellyfin.Plugin.SRFPlay.sln - name: Build solution working-directory: release-${{ github.run_id }} run: dotnet build Jellyfin.Plugin.SRFPlay.sln --configuration Release --no-restore --no-self-contained /m:1 - name: Run tests working-directory: release-${{ github.run_id }} run: dotnet test Jellyfin.Plugin.SRFPlay.sln --no-build --configuration Release --verbosity normal - name: Build Jellyfin Plugins working-directory: release-${{ github.run_id }} # v1.2.0 -> 1.2.0.9 / 1.2.0.11 / 1.2.0.12, one per Jellyfin generation # (see .gitea/scripts/build-plugins.sh). run: .gitea/scripts/build-plugins.sh "${{ steps.get_version.outputs.version_number }}.%d" - name: Create Release working-directory: release-${{ github.run_id }} env: GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # Get repository information REPO_OWNER="${{ github.repository_owner }}" REPO_NAME="${{ github.event.repository.name }}" GITEA_URL="${{ github.server_url }}" # Create release using Gitea API VERSION="${{ steps.get_version.outputs.version }}" RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \ -H "Authorization: token ${GITEA_TOKEN}" \ -H "Content-Type: application/json" \ "${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases" \ -d "$(jq -n --arg tag "$VERSION" --arg name "Release $VERSION" --arg body "SRFPlay Jellyfin Plugin. See attached files for plugin installation." '{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: false}')") HTTP_CODE=$(echo "$RESPONSE" | tail -n1) BODY=$(echo "$RESPONSE" | sed '$d') if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then RELEASE_ID=$(echo "$BODY" | jq -r '.id') echo "Created release with ID: ${RELEASE_ID}" else echo "Failed to create release. HTTP ${HTTP_CODE}" echo "$BODY" exit 1 fi # Upload one plugin zip per Jellyfin generation cut -f3 artifacts/builds.tsv | while read -r ZIP; do echo "Uploading ${ZIP}..." curl -f -X POST \ -H "Authorization: token ${GITEA_TOKEN}" \ -H "Content-Type: application/zip" \ --data-binary "@${ZIP}" \ "${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases/${RELEASE_ID}/assets?name=$(basename "${ZIP}")" done # Upload build.yaml echo "Uploading build.yaml..." curl -f -X POST \ -H "Authorization: token ${GITEA_TOKEN}" \ -H "Content-Type: application/x-yaml" \ --data-binary "@build.yaml" \ "${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases/${RELEASE_ID}/assets?name=build.yaml" echo "✅ Release created successfully!" echo "View at: ${GITEA_URL}/${REPO_OWNER}/${REPO_NAME}/releases/tag/${{ steps.get_version.outputs.version }}" - name: Update manifest.json working-directory: release-${{ github.run_id }} env: GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | REPO_OWNER="${{ github.repository_owner }}" REPO_NAME="${{ github.event.repository.name }}" GITEA_URL="${{ github.server_url }}" VERSION="${{ steps.get_version.outputs.version_number }}" TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") # builds.tsv is read before the checkout below replaces the tree. BUILDS=$(cat artifacts/builds.tsv) git config user.name "Gitea Actions" git config user.email "actions@gitea.tourolle.paris" git fetch origin master # -B against origin/master for the same reason as the nightly: a bare # `checkout master` edits the manifest on a stale base if master moved. git checkout -B master origin/master # One entry per Jellyfin generation; each server installs the newest # entry whose targetAbi it satisfies. NEW_VERSIONS=$(echo "${BUILDS}" | jq -R -s \ --arg url "${GITEA_URL}/${REPO_OWNER}/${REPO_NAME}/releases/download/${{ steps.get_version.outputs.version }}" \ --arg release "${VERSION}" --arg ts "${TIMESTAMP}" \ 'split("\n") | map(select(length > 0) | split("\t") | {version: .[0], changelog: "Release \($release)", targetAbi: .[1], sourceUrl: "\($url)/\(.[2] | split("/") | last)", checksum: .[3], timestamp: $ts}) | reverse') jq --argjson newvers "${NEW_VERSIONS}" '.[0].versions = $newvers + .[0].versions' manifest.json > manifest.tmp && mv manifest.tmp manifest.json git add manifest.json git commit -m "Update manifest.json for version ${VERSION}" git push origin master - name: Cleanup if: always() run: rm -rf release-${{ github.run_id }}