diff --git a/.gitea/workflows/release_automation.yml b/.gitea/workflows/release_automation.yml index 0c52459..d685921 100644 --- a/.gitea/workflows/release_automation.yml +++ b/.gitea/workflows/release_automation.yml @@ -40,6 +40,11 @@ jobs: echo "Detected Version: $VERSION" echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "TARGET_ABI=$TARGET_ABI" >> $GITHUB_ENV + + # Also export GUID for later use + PLUGIN_GUID=$(jq -r '.[0].guid' manifest.json) + echo "PLUGIN_GUID=$PLUGIN_GUID" >> $GITHUB_ENV # Escape newlines in changelog for GITHUB_ENV echo "CHANGELOG<> $GITHUB_ENV @@ -101,3 +106,78 @@ jobs: tag_name: "v${{ env.VERSION }}" draft: false prerelease: false + + # Update Message in Remote Repository + - name: Checkout Central Manifest Repo + uses: actions/checkout@v6 + with: + repository: ${{ github.repository_owner }}/jellyfin-plugin-manifest + path: central-manifest + token: ${{ secrets.JELLYFIN_PLUGIN_MANIFEST_UPDATER_PAT }} + + - name: Update Central Manifest + shell: bash + run: | + cd central-manifest + + # 1. Get info from previous steps + VERSION="${{ env.VERSION }}" + HASH="${{ env.ZIP_HASH }}" + TIME="${{ env.BUILD_TIME }}" + DOWNLOAD_URL="https://git.mahom03-spacecloud.de/${{ github.repository_owner }}/${{ github.repository }}/releases/download/v$VERSION/Jellyfin.Plugin.MediaBarEnhanced.zip" + + # 2. Get info from env + PLUGIN_GUID="${{ env.PLUGIN_GUID }}" + CHANGELOG="${{ env.CHANGELOG }}" + TARGET_ABI="${{ env.TARGET_ABI }}" + + echo "Updating Central Manifest for Plugin GUID: $PLUGIN_GUID" + + # 3. Update/Prepend entry in central manifest.json + # Logic: + # - If array is empty or new version != old version: PREPEND new entry + # - If new version == old version: OVERWRITE (update) existing entry (re-release) + + jq --arg guid "$PLUGIN_GUID" \ + --arg hash "$HASH" \ + --arg time "$TIME" \ + --arg url "$DOWNLOAD_URL" \ + --arg ver "$VERSION" \ + --arg changelog "$CHANGELOG" \ + --arg abi "$TARGET_ABI" \ + 'map(if .guid == $guid then + if .versions[0].version != $ver then + # New Version -> Prepend + .versions = [{ + "version": $ver, + "changelog": $changelog, + "targetAbi": $abi, + "sourceUrl": $url, + "checksum": $hash, + "timestamp": $time + }] + .versions + else + # Same Version -> Update existing (overwrite top) + .versions[0].changelog = $changelog | + .versions[0].targetAbi = $abi | + .versions[0].sourceUrl = $url | + .versions[0].checksum = $hash | + .versions[0].timestamp = $time + end + else . end)' \ + manifest.json > manifest.json.tmp && mv manifest.json.tmp manifest.json + + - name: Commit and Push Central Manifest + run: | + cd central-manifest + git config user.name "CodeDevMLH" + git config user.email "145071728+CodeDevMLH@users.noreply.github.com" + + # Check if there are changes + if [[ -n $(git status -s) ]]; then + git add manifest.json + git commit -m "Auto-Update MediaBar Enhanced to v${{ env.VERSION }}" + git push + else + echo "No changes to central manifest." + fi \ No newline at end of file diff --git a/.github/workflows/release_automation.yml b/.github/workflows/release_automation.yml index 9cb1927..f6e7578 100644 --- a/.github/workflows/release_automation.yml +++ b/.github/workflows/release_automation.yml @@ -39,6 +39,11 @@ jobs: echo "Detected Version: $VERSION" echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "TARGET_ABI=$TARGET_ABI" >> $GITHUB_ENV + + # Also export GUID for later use + PLUGIN_GUID=$(jq -r '.[0].guid' manifest.json) + echo "PLUGIN_GUID=$PLUGIN_GUID" >> $GITHUB_ENV # Escape newlines in changelog for GITHUB_ENV echo "CHANGELOG<> $GITHUB_ENV @@ -99,3 +104,78 @@ jobs: draft: false prerelease: false generate_release_notes: true + + # Update Message in Remote Repository + - name: Checkout Central Manifest Repo + uses: actions/checkout@v6 + with: + repository: ${{ github.repository_owner }}/jellyfin-plugin-manifest + path: central-manifest + token: ${{ secrets.JELLYFIN_PLUGIN_MANIFEST_UPDATER_PAT }} + + - name: Update Central Manifest + shell: bash + run: | + cd central-manifest + + # 1. Get info from previous steps + VERSION="${{ env.VERSION }}" + HASH="${{ env.ZIP_HASH }}" + TIME="${{ env.BUILD_TIME }}" + DOWNLOAD_URL="https://github.com/${{ github.repository_owner }}/${{ github.repository }}/releases/download/v$VERSION/Jellyfin.Plugin.MediaBarEnhanced.zip" + + # 2. Get info from env + PLUGIN_GUID="${{ env.PLUGIN_GUID }}" + CHANGELOG="${{ env.CHANGELOG }}" + TARGET_ABI="${{ env.TARGET_ABI }}" + + echo "Updating Central Manifest for Plugin GUID: $PLUGIN_GUID" + + # 3. Update/Prepend entry in central manifest.json + # Logic: + # - If array is empty or new version != old version: PREPEND new entry + # - If new version == old version: OVERWRITE (update) existing entry (re-release) + + jq --arg guid "$PLUGIN_GUID" \ + --arg hash "$HASH" \ + --arg time "$TIME" \ + --arg url "$DOWNLOAD_URL" \ + --arg ver "$VERSION" \ + --arg changelog "$CHANGELOG" \ + --arg abi "$TARGET_ABI" \ + 'map(if .guid == $guid then + if .versions[0].version != $ver then + # New Version -> Prepend + .versions = [{ + "version": $ver, + "changelog": $changelog, + "targetAbi": $abi, + "sourceUrl": $url, + "checksum": $hash, + "timestamp": $time + }] + .versions + else + # Same Version -> Update existing (overwrite top) + .versions[0].changelog = $changelog | + .versions[0].targetAbi = $abi | + .versions[0].sourceUrl = $url | + .versions[0].checksum = $hash | + .versions[0].timestamp = $time + end + else . end)' \ + manifest.json > manifest.json.tmp && mv manifest.json.tmp manifest.json + + - name: Commit and Push Central Manifest + run: | + cd central-manifest + git config user.name "CodeDevMLH" + git config user.email "145071728+CodeDevMLH@users.noreply.github.com" + + # Check if there are changes + if [[ -n $(git status -s) ]]; then + git add manifest.json + git commit -m "Auto-Update MediaBar Enhanced to v${{ env.VERSION }}" + git push + else + echo "No changes to central manifest." + fi \ No newline at end of file