All checks were successful
Auto Release Plugin / build-and-release (push) Successful in 58s
300 lines
11 KiB
YAML
300 lines
11 KiB
YAML
name: Auto Release Plugin
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths-ignore:
|
|
- '.github/**'
|
|
- 'README.md'
|
|
- 'jellyfin.ruleset'
|
|
- '.gitignore'
|
|
- '.editorconfig'
|
|
- 'LICENSE'
|
|
- 'logo.png'
|
|
|
|
jobs:
|
|
build-and-release:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
fetch-depth: 0
|
|
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v5
|
|
with:
|
|
dotnet-version: '9.x'
|
|
|
|
- name: Read Version from Manifest
|
|
id: read_version
|
|
run: |
|
|
VERSION=$(jq -r '.[0].versions[0].version' manifest.json)
|
|
CHANGELOG=$(jq -r '.[0].versions[0].changelog' manifest.json)
|
|
TARGET_ABI=$(jq -r '.[0].versions[0].targetAbi' manifest.json)
|
|
|
|
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<<EOF" >> $GITHUB_ENV
|
|
echo "$CHANGELOG" >> $GITHUB_ENV
|
|
echo "EOF" >> $GITHUB_ENV
|
|
|
|
- name: Build and Zip
|
|
shell: bash
|
|
run: |
|
|
# Inject version from manifest into the build
|
|
dotnet build Jellyfin.Plugin.MediaBarEnhanced/Jellyfin.Plugin.MediaBarEnhanced.csproj --configuration Release --output bin/Publish /p:Version=${{ env.VERSION }} /p:AssemblyVersion=${{ env.VERSION }}
|
|
|
|
cd bin/Publish
|
|
zip -r Jellyfin.Plugin.MediaBarEnhanced.zip *
|
|
cd ../..
|
|
|
|
# Calculate hash
|
|
HASH=$(md5sum bin/Publish/Jellyfin.Plugin.MediaBarEnhanced.zip | awk '{ print $1 }')
|
|
TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
|
|
# Export variables for next steps
|
|
echo "ZIP_HASH=$HASH" >> $GITHUB_ENV
|
|
echo "BUILD_TIME=$TIME" >> $GITHUB_ENV
|
|
echo "ZIP_PATH=bin/Publish/Jellyfin.Plugin.MediaBarEnhanced.zip" >> $GITHUB_ENV
|
|
|
|
- name: Update manifest.json
|
|
shell: bash
|
|
run: |
|
|
REPO_OWNER="${{ github.repository_owner }}"
|
|
REPO_NAME="${{ github.event.repository.name }}"
|
|
VERSION="${{ env.VERSION }}"
|
|
DOWNLOAD_URL="https://github.com/$REPO_OWNER/$REPO_NAME/releases/download/v$VERSION/Jellyfin.Plugin.MediaBarEnhanced.zip"
|
|
|
|
echo "Updating manifest.json with:"
|
|
echo "Hash: ${{ env.ZIP_HASH }}"
|
|
echo "Time: ${{ env.BUILD_TIME }}"
|
|
echo "Url: $DOWNLOAD_URL"
|
|
|
|
jq --arg hash "${{ env.ZIP_HASH }}" \
|
|
--arg time "${{ env.BUILD_TIME }}" \
|
|
--arg url "$DOWNLOAD_URL" \
|
|
'.[0].versions[0].checksum = $hash | .[0].versions[0].timestamp = $time | .[0].versions[0].sourceUrl = $url' \
|
|
manifest.json > manifest.json.tmp && mv manifest.json.tmp manifest.json
|
|
|
|
- name: Commit manifest.json
|
|
uses: stefanzweifel/git-auto-commit-action@v7
|
|
with:
|
|
commit_message: "Update manifest.json for release v${{ env.VERSION }} [skip ci]"
|
|
file_pattern: manifest.json
|
|
|
|
- name: Generate Commit Log
|
|
if: success()
|
|
shell: bash
|
|
run: |
|
|
echo "Generating commit log since last tag..."
|
|
|
|
# Get the previous tag
|
|
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
|
|
|
if [ -z "$PREV_TAG" ]; then
|
|
echo "No previous tag found. Getting all commits."
|
|
start_range=""
|
|
else
|
|
echo "Previous tag: $PREV_TAG"
|
|
start_range="$PREV_TAG.."
|
|
fi
|
|
|
|
echo "### What's Changed" > commit_log.md
|
|
echo "" >> commit_log.md
|
|
git log --pretty=format:"- %s (%h) by @%an" $start_range >> commit_log.md
|
|
|
|
# Combine Changelog from manifest (if exists) and commit log
|
|
if [ -n "${{ env.CHANGELOG }}" ]; then
|
|
echo "${{ env.CHANGELOG }}" > release_body.txt
|
|
echo "" >> release_body.txt
|
|
echo "" >> release_body.txt
|
|
cat commit_log.md >> release_body.txt
|
|
else
|
|
cat commit_log.md > release_body.txt
|
|
fi
|
|
|
|
# Debug output
|
|
cat release_body.txt
|
|
|
|
- name: Create Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: "v${{ env.VERSION }}"
|
|
name: "v${{ env.VERSION }}"
|
|
# body: ${{ env.CHANGELOG }}
|
|
files: ${{ env.ZIP_PATH }}
|
|
draft: false
|
|
prerelease: false
|
|
generate_release_notes: false
|
|
body_path: release_body.txt
|
|
|
|
|
|
# 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
|
|
|
|
REPO_OWNER="${{ github.repository_owner }}"
|
|
REPO_NAME="${{ github.event.repository.name }}"
|
|
|
|
# 1. Get info from previous steps
|
|
VERSION="${{ env.VERSION }}"
|
|
HASH="${{ env.ZIP_HASH }}"
|
|
TIME="${{ env.BUILD_TIME }}"
|
|
DOWNLOAD_URL="https://github.com/$REPO_OWNER/$REPO_NAME/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
|
|
|
|
# Update Message in Seasonals Repository
|
|
- name: Checkout Seasonal Manifest Repo
|
|
uses: actions/checkout@v6
|
|
with:
|
|
repository: ${{ github.repository_owner }}/Jellyfin-Seasonals
|
|
path: seasonal-manifest
|
|
token: ${{ secrets.JELLYFIN_PLUGIN_MANIFEST_UPDATER_PAT }}
|
|
|
|
- name: Update Seasonal Manifest
|
|
shell: bash
|
|
run: |
|
|
cd seasonal-manifest
|
|
|
|
REPO_OWNER="${{ github.repository_owner }}"
|
|
REPO_NAME="${{ github.event.repository.name }}"
|
|
|
|
# 1. Get info from previous steps
|
|
VERSION="${{ env.VERSION }}"
|
|
HASH="${{ env.ZIP_HASH }}"
|
|
TIME="${{ env.BUILD_TIME }}"
|
|
DOWNLOAD_URL="https://github.com/$REPO_OWNER/$REPO_NAME/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 Seasonal Manifest for Plugin GUID: $PLUGIN_GUID"
|
|
|
|
# 3. Update/Prepend entry in seasonal 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 Seasonal Manifest
|
|
run: |
|
|
cd seasonal-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 seasonal manifest."
|
|
fi |