Skip to content

Commit 453d2fd

Browse files
committed
ci: Publish pinned Moonbase v2 3.1.1.2 to test feed
1 parent ae79e2e commit 453d2fd

1 file changed

Lines changed: 243 additions & 0 deletions

File tree

Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
name: Publish Moonbase v2 3.1.1.2 test update
2+
3+
on:
4+
push:
5+
branches:
6+
- ci/moonbase-live-tv-groups-v2-test-20261113
7+
8+
# This workflow exists only on a release branch; PR feature code is unchanged.
9+
10+
permissions:
11+
contents: write
12+
13+
concurrency:
14+
group: moonbase-test-release
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
name: Build Plugins
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
with:
26+
ref: ${{ github.sha }}
27+
fetch-depth: 2
28+
29+
- name: Validate source and select release version
30+
id: jf_meta
31+
env:
32+
FEATURE_SOURCE_SHA: 'ae79e2ee744c23b187f47d873db1a65e62f11551'
33+
RELEASE_VERSION: '3.1.1.2'
34+
run: |
35+
set -euo pipefail
36+
37+
# This branch is exactly the selected v2 source plus this release workflow.
38+
test "$(git rev-parse HEAD^)" = "$FEATURE_SOURCE_SHA"
39+
if ! git diff --quiet "$FEATURE_SOURCE_SHA" HEAD -- Jellyfin Emby shared; then
40+
echo "::error::Release branch differs from pinned feature source."
41+
exit 1
42+
fi
43+
44+
SOURCE_VERSION="$(grep -oPm1 '(?<=<MoonfinVersion>)[^<]+' Jellyfin/backend/Moonfin.Server.csproj).0"
45+
ABI="$(grep 'Jellyfin.Controller' Jellyfin/backend/Moonfin.Server.csproj | grep -oP 'Version="\\K[^"]+')"
46+
SCRIPT_VERSION="$(grep -oPm1 'VERSION="\\$\\{1:-\\K[^}]+' Jellyfin/build.sh)"
47+
if [ "$SCRIPT_VERSION" != "$SOURCE_VERSION" ]; then
48+
echo "::error::Source version drift: build.sh says $SCRIPT_VERSION; csproj says $SOURCE_VERSION."
49+
exit 1
50+
fi
51+
52+
SCRIPT_ABI="$(grep -oPm1 'TARGET_ABI="\\$\\{2:-\\K[^}]+' Jellyfin/build.sh)"
53+
if [ "$SCRIPT_ABI" != "$ABI" ]; then
54+
echo "::error::Target ABI drift: build.sh says $SCRIPT_ABI; csproj says $ABI."
55+
exit 1
56+
fi
57+
58+
# Release-only assembly override: feature branch's source version stays unchanged.
59+
test "$RELEASE_VERSION" = "3.1.1.2"
60+
echo "version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
61+
echo "abi=${ABI}.0" >> "$GITHUB_OUTPUT"
62+
63+
- name: Setup .NET
64+
uses: actions/setup-dotnet@v4
65+
with:
66+
dotnet-version: 8.0.x
67+
68+
- name: Build Jellyfin plugin
69+
id: backend_build
70+
continue-on-error: true
71+
env:
72+
VERSION: ${{ steps.jf_meta.outputs.version }}
73+
run: |
74+
set -o pipefail
75+
rm -rf Jellyfin/backend/bin/Release Jellyfin/backend/obj/Release
76+
rm -rf Jellyfin/tools/verify-plugin/bin/Release Jellyfin/tools/verify-plugin/obj/Release
77+
dotnet publish Jellyfin/backend/Moonfin.Server.csproj \
78+
-c Release \
79+
-o Jellyfin/backend/bin/Release/net8.0/publish \
80+
-p:AssemblyVersion="$VERSION" \
81+
-p:FileVersion="$VERSION" \
82+
-p:Version="$VERSION" \
83+
2>&1 | tee "${{ runner.temp }}/backend-build.log"
84+
dotnet run --project Jellyfin/tools/verify-plugin/VerifyPlugin.csproj \
85+
-c Release -- \
86+
Jellyfin/backend/bin/Release/net8.0/publish/Moonfin.Server.dll "$VERSION" \
87+
2>&1 | tee -a "${{ runner.temp }}/backend-build.log"
88+
89+
- name: Build Emby plugin
90+
id: emby_build
91+
continue-on-error: true
92+
env:
93+
EMBY_VERSION: ${{ steps.jf_meta.outputs.version }}
94+
run: |
95+
set -o pipefail
96+
echo "version=$EMBY_VERSION" >> "$GITHUB_OUTPUT"
97+
echo "zip_name=Moonfin.Emby-${EMBY_VERSION}.zip" >> "$GITHUB_OUTPUT"
98+
# build.sh builds the netstandard2.1 plugin and assembles the drop-in zip.
99+
cd Emby
100+
bash build.sh "$EMBY_VERSION" 2>&1 | tee "${{ runner.temp }}/emby-build.log"
101+
102+
- name: Run tests
103+
id: tests
104+
continue-on-error: true
105+
run: |
106+
set -o pipefail
107+
dotnet test Jellyfin/tests/Moonfin.Server.Tests/Moonfin.Server.Tests.csproj \
108+
-c Release \
109+
2>&1 | tee "${{ runner.temp }}/tests.log"
110+
111+
# These two assert and exit rather than reporting through a test runner.
112+
- name: Run salvage tests
113+
id: salvage_tests
114+
continue-on-error: true
115+
run: |
116+
set -o pipefail
117+
dotnet run --project Jellyfin/tools/salvage-tests -c Release \
118+
2>&1 | tee "${{ runner.temp }}/salvage-tests.log"
119+
120+
- name: Run Emby tests
121+
id: emby_tests
122+
continue-on-error: true
123+
run: |
124+
set -o pipefail
125+
dotnet test Emby/tests/Emby.Plugins.Moonfin.Tests/Emby.Plugins.Moonfin.Tests.csproj \
126+
-c Release \
127+
2>&1 | tee "${{ runner.temp }}/emby-tests.log"
128+
129+
- name: Fail if any step failed
130+
if: >-
131+
steps.backend_build.outcome != 'success' ||
132+
steps.emby_build.outcome != 'success' ||
133+
steps.tests.outcome != 'success' ||
134+
steps.salvage_tests.outcome != 'success' ||
135+
steps.emby_tests.outcome != 'success'
136+
run: exit 1
137+
138+
- name: Package Jellyfin ZIP
139+
if: steps.backend_build.outcome == 'success' && steps.emby_build.outcome == 'success'
140+
id: jf_package
141+
run: |
142+
VERSION="${{ steps.jf_meta.outputs.version }}"
143+
TARGET_ABI="${{ steps.jf_meta.outputs.abi }}"
144+
PLUGIN_GUID="8c5d0e91-4f2a-4b6d-9e3f-1a7c8d9e0f2b"
145+
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
146+
147+
mkdir -p jellyfin-release
148+
cp Jellyfin/backend/bin/Release/net8.0/publish/Moonfin.Server.dll jellyfin-release/
149+
cp Jellyfin/backend/bin/Release/net8.0/publish/SharpCompress.dll jellyfin-release/
150+
151+
if [ -f Jellyfin/frontend/index.html ]; then
152+
mkdir -p jellyfin-release/frontend
153+
cp -R Jellyfin/frontend/. jellyfin-release/frontend/
154+
rm -rf jellyfin-release/frontend/node_modules
155+
rm -f jellyfin-release/frontend/package.json jellyfin-release/frontend/package-lock.json
156+
fi
157+
158+
cat > jellyfin-release/meta.json <<EOF
159+
{
160+
"category": "General",
161+
"changelog": "",
162+
"description": "Moonbase is the Moonfin server plugin for Jellyfin, powering settings sync, the Moonfin Web app at /Moonfin/Web/, a built-in theme editor with custom theme APIs, media bar and ratings integrations, and Seerr proxy/SSO with admin defaults and broadcasts across Moonfin clients.",
163+
"guid": "${PLUGIN_GUID}",
164+
"name": "Moonbase",
165+
"overview": "Moonfin server plugin for Jellyfin with web app hosting, settings sync, theming, and Seerr integrations",
166+
"owner": "RadicalMuffinMan",
167+
"targetAbi": "${TARGET_ABI}",
168+
"timestamp": "${TIMESTAMP}",
169+
"version": "${VERSION}",
170+
"status": "Active",
171+
"autoUpdate": true,
172+
"assemblies": ["Moonfin.Server.dll"]
173+
}
174+
EOF
175+
176+
ZIP_NAME="Moonfin.Server-${VERSION}.zip"
177+
cd jellyfin-release && zip -r "../${ZIP_NAME}" . && cd ..
178+
CHECKSUM=$(md5sum "$ZIP_NAME" | awk '{print toupper($1)}')
179+
echo "zip_name=$ZIP_NAME" >> "$GITHUB_OUTPUT"
180+
echo "checksum=$CHECKSUM" >> "$GITHUB_OUTPUT"
181+
182+
- name: Publish test release
183+
env:
184+
GH_TOKEN: ${{ github.token }}
185+
BUILD_BRANCH: feat/live-tv-channel-groups-emby-tags-experiment-v2
186+
PR_SOURCE_SHA: ae79e2ee744c23b187f47d873db1a65e62f11551
187+
VERSION: ${{ steps.jf_meta.outputs.version }}
188+
TARGET_ABI: ${{ steps.jf_meta.outputs.abi }}
189+
JELLYFIN_ZIP: ${{ steps.jf_package.outputs.zip_name }}
190+
EMBY_ZIP: ${{ steps.emby_build.outputs.zip_name }}
191+
CHECKSUM: ${{ steps.jf_package.outputs.checksum }}
192+
run: |
193+
TAG="test-${VERSION}"
194+
SOURCE_SHA=$(git rev-parse HEAD)
195+
if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then
196+
echo "::error::Release $TAG already exists. Refusing to overwrite."
197+
exit 1
198+
fi
199+
RELEASE_URL="https://github.com/${GITHUB_REPOSITORY}/releases/tag/${TAG}"
200+
REPOSITORY_URL="https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/refs/heads/master/test-manifest.json"
201+
SOURCE_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}/${JELLYFIN_ZIP}"
202+
CHANGELOG="Live TV channel groups v2: Jellyfin M3U and Xtream groups, Emby native channel tags, and handling for ungrouped channels. Built from ${BUILD_BRANCH} (${PR_SOURCE_SHA}); release-only version bump from 3.1.1.1. No feature PR source changes."
203+
204+
# Preserve every existing entry in the Jellyfin test repository.
205+
gh api "repos/${GITHUB_REPOSITORY}/contents/test-manifest.json?ref=master" --jq '.content' \
206+
| base64 --decode > "$RUNNER_TEMP/previous-test-manifest.json"
207+
test -s "$RUNNER_TEMP/previous-test-manifest.json"
208+
test "$(jq -r '.[0].versions[0].version' "$RUNNER_TEMP/previous-test-manifest.json")" = "3.1.1.1" || { echo "::error::Test feed has moved on since 3.1.1.1"; exit 1; }
209+
210+
jq --arg version "$VERSION" --arg abi "$TARGET_ABI" \
211+
--arg checksum "$CHECKSUM" --arg source "$SOURCE_URL" \
212+
--arg changelog "$CHANGELOG" --arg owner "$GITHUB_REPOSITORY_OWNER" \
213+
--arg image "https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/${SOURCE_SHA}/Jellyfin/backend/assets/logo.png" \
214+
--arg timestamp "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
215+
'[.[0] | .owner = $owner | .imageUrl = $image | .versions = ([{
216+
version: $version, targetAbi: $abi, sourceUrl: $source,
217+
checksum: $checksum, changelog: $changelog,
218+
timestamp: $timestamp, dependencies: []
219+
}] + (.versions | map(select(.version != $version))))]' "$RUNNER_TEMP/previous-test-manifest.json" > test-manifest.json
220+
221+
printf '%s\n\nJellyfin test repository:\n%s\n' \
222+
"$CHANGELOG" "$REPOSITORY_URL" > "$RUNNER_TEMP/release-notes.txt"
223+
224+
# Upload everything before making the release available to Jellyfin.
225+
gh release create "$TAG" "$JELLYFIN_ZIP" "Emby/$EMBY_ZIP" test-manifest.json \
226+
--repo "$GITHUB_REPOSITORY" --target "$SOURCE_SHA" \
227+
--title "Moonbase ${VERSION} (test build)" \
228+
--notes-file "$RUNNER_TEMP/release-notes.txt" --prerelease --draft
229+
gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" --draft=false --latest=false
230+
231+
# Keep the repository URL stable while each release keeps its own ZIP and checksum.
232+
FILE_SHA=$(gh api "repos/${GITHUB_REPOSITORY}/contents?ref=master" \
233+
--jq '.[] | select(.name == "test-manifest.json") | .sha')
234+
jq -n --arg message "Update test repository for ${VERSION}" \
235+
--arg content "$(base64 -w 0 test-manifest.json)" --arg sha "$FILE_SHA" \
236+
'{message: $message, branch: "master", content: $content}
237+
+ (if $sha == "" then {} else {sha: $sha} end)' \
238+
> "$RUNNER_TEMP/test-manifest-update.json"
239+
gh api --method PUT "repos/${GITHUB_REPOSITORY}/contents/test-manifest.json" \
240+
--input "$RUNNER_TEMP/test-manifest-update.json" --silent
241+
242+
printf '## Test release published\n\n[Moonbase %s](%s)\n\nJellyfin repository URL:\n\n%s\n' \
243+
"$VERSION" "$RELEASE_URL" "$REPOSITORY_URL" >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)