The builder image is now multi-arch (linux/amd64 + linux/arm64). Both variants were tested by running this repo's own CI build steps in each before being pushed as :latest. Jobs therefore no longer need an amd64 host: runs-on moves to ubuntu-latest, which the amd64 runner (draco-x86) and the ARM runner (oracle-a1) both carry, so jobs go to whichever is free instead of queueing behind long jobs on draco. The Dockerfile header now gives the buildx command for the multi-arch image, so a rebuild does not silently go back to amd64-only. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
161 lines
7.5 KiB
YAML
161 lines
7.5 KiB
YAML
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/watchedtogether-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
|
|
# Tags are vX.Y.Z. The fourth version segment is reserved for the Jellyfin generation a
|
|
# package targets: X.Y.Z.11 for 10.11 and X.Y.Z.12 for 12. Jellyfin installs the highest
|
|
# version whose targetAbi it satisfies, so the 12 package must sort above the 10.11 one.
|
|
BASE=$(echo "${VERSION#v}" | cut -d. -f1-3)
|
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
echo "version_number=${BASE}" >> $GITHUB_OUTPUT
|
|
echo "version_1011=${BASE}.11" >> $GITHUB_OUTPUT
|
|
echo "version_12=${BASE}.12" >> $GITHUB_OUTPUT
|
|
echo "Building version: ${VERSION} (${BASE}.11 for Jellyfin 10.11, ${BASE}.12 for Jellyfin 12)"
|
|
|
|
- name: Cache NuGet packages
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.nuget/packages
|
|
key: nuget-${{ hashFiles('**/Jellyfin.Plugin.WatchedTogether.csproj', '**/Jellyfin.Plugin.WatchedTogether.Tests.csproj') }}
|
|
restore-keys: nuget-
|
|
|
|
- name: Restore dependencies
|
|
working-directory: release-${{ github.run_id }}
|
|
run: dotnet restore Jellyfin.Plugin.WatchedTogether.sln
|
|
|
|
- name: Build solution
|
|
working-directory: release-${{ github.run_id }}
|
|
run: dotnet build Jellyfin.Plugin.WatchedTogether.sln --configuration Release --no-restore --no-self-contained /m:1
|
|
|
|
- name: Run tests
|
|
working-directory: release-${{ github.run_id }}
|
|
run: dotnet test Jellyfin.Plugin.WatchedTogether.sln --no-build --configuration Release --verbosity normal
|
|
|
|
- name: Package for Jellyfin 10.11 and 12
|
|
id: jprm
|
|
working-directory: release-${{ github.run_id }}
|
|
run: |
|
|
scripts/package.sh 10.11 "${{ steps.get_version.outputs.version_1011 }}" artifacts
|
|
scripts/package.sh 12 "${{ steps.get_version.outputs.version_12 }}" artifacts
|
|
|
|
ARTIFACT_1011=$(find artifacts -name "*_${{ steps.get_version.outputs.version_1011 }}.zip" -type f -print -quit)
|
|
ARTIFACT_12=$(find artifacts -name "*_${{ steps.get_version.outputs.version_12 }}.zip" -type f -print -quit)
|
|
test -n "${ARTIFACT_1011}" && test -n "${ARTIFACT_12}"
|
|
|
|
echo "artifact_1011=${ARTIFACT_1011}" >> $GITHUB_OUTPUT
|
|
echo "artifact_name_1011=$(basename "${ARTIFACT_1011}")" >> $GITHUB_OUTPUT
|
|
echo "checksum_1011=$(md5sum "${ARTIFACT_1011}" | awk '{print $1}')" >> $GITHUB_OUTPUT
|
|
echo "artifact_12=${ARTIFACT_12}" >> $GITHUB_OUTPUT
|
|
echo "artifact_name_12=$(basename "${ARTIFACT_12}")" >> $GITHUB_OUTPUT
|
|
echo "checksum_12=$(md5sum "${ARTIFACT_12}" | awk '{print $1}')" >> $GITHUB_OUTPUT
|
|
echo "Packages: ${ARTIFACT_1011} ${ARTIFACT_12}"
|
|
|
|
- name: Create Release
|
|
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 }}"
|
|
|
|
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 "Watched Together Jellyfin plugin. Two packages are attached: ${{ steps.jprm.outputs.artifact_name_1011 }} for Jellyfin 10.11 and ${{ steps.jprm.outputs.artifact_name_12 }} for Jellyfin 12. The plugin repository picks the right one automatically." '{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
|
|
|
|
for ARTIFACT in "${{ steps.jprm.outputs.artifact_1011 }}" "${{ steps.jprm.outputs.artifact_12 }}"; do
|
|
echo "Uploading ${ARTIFACT}..."
|
|
curl -f -X POST \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/zip" \
|
|
--data-binary "@${ARTIFACT}" \
|
|
"${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases/${RELEASE_ID}/assets?name=$(basename "${ARTIFACT}")"
|
|
done
|
|
|
|
echo "✅ Release created successfully!"
|
|
|
|
- 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 }}"
|
|
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
DOWNLOAD_BASE="${GITEA_URL}/${REPO_OWNER}/${REPO_NAME}/releases/download/${{ steps.get_version.outputs.version }}"
|
|
|
|
git config user.name "Gitea Actions"
|
|
git config user.email "actions@gitea.tourolle.paris"
|
|
git fetch origin master
|
|
git checkout master
|
|
|
|
# One manifest entry per Jellyfin generation. A server only considers entries whose
|
|
# targetAbi it meets and installs the highest of those, so 10.11 sees only the .11 entry
|
|
# while 12 sees both and takes the .12 one.
|
|
NEW_VERSIONS=$(jq -n \
|
|
--arg ts "${TIMESTAMP}" \
|
|
--arg v12 "${{ steps.get_version.outputs.version_12 }}" \
|
|
--arg url12 "${DOWNLOAD_BASE}/${{ steps.jprm.outputs.artifact_name_12 }}" \
|
|
--arg sum12 "${{ steps.jprm.outputs.checksum_12 }}" \
|
|
--arg v1011 "${{ steps.get_version.outputs.version_1011 }}" \
|
|
--arg url1011 "${DOWNLOAD_BASE}/${{ steps.jprm.outputs.artifact_name_1011 }}" \
|
|
--arg sum1011 "${{ steps.jprm.outputs.checksum_1011 }}" \
|
|
'[
|
|
{version: $v12, changelog: ("Release " + $v12 + " (Jellyfin 12)"), targetAbi: "12.0.0.0", sourceUrl: $url12, checksum: $sum12, timestamp: $ts},
|
|
{version: $v1011, changelog: ("Release " + $v1011 + " (Jellyfin 10.11)"), targetAbi: "10.11.0.0", sourceUrl: $url1011, checksum: $sum1011, timestamp: $ts}
|
|
]')
|
|
|
|
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 ${{ steps.get_version.outputs.version_number }}"
|
|
git push origin master
|
|
|
|
- name: Cleanup
|
|
if: always()
|
|
run: rm -rf release-${{ github.run_id }}
|