From a8d39689256ce71697d8b2f95fdf8926a967d815 Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Fri, 14 Nov 2025 20:26:52 +0100 Subject: [PATCH] gitea ci workflows --- .gitea/workflows/build.yaml | 59 ++++++++++++++++++++ .gitea/workflows/release.yaml | 100 ++++++++++++++++++++++++++++++++++ .gitea/workflows/test.yaml | 46 ++++++++++++++++ 3 files changed, 205 insertions(+) create mode 100644 .gitea/workflows/build.yaml create mode 100644 .gitea/workflows/release.yaml create mode 100644 .gitea/workflows/test.yaml diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..bfb68d0 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,59 @@ +name: '๐Ÿ—๏ธ Build Plugin' + +on: + push: + branches: + - master + paths-ignore: + - '**/*.md' + pull_request: + branches: + - master + paths-ignore: + - '**/*.md' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' + + - name: Restore dependencies + run: dotnet restore + + - name: Build solution + run: dotnet build --configuration Release --no-restore + + - name: Run tests + run: dotnet test --no-build --configuration Release --verbosity normal + + - name: Install JPRM + run: | + pip install --user jprm + + - name: Build Jellyfin Plugin + id: jprm + run: | + # Build plugin using JPRM + python -m jprm --verbosity=debug plugin build ./ + + # Find the generated zip file + ARTIFACT=$(find . -name "*.zip" -type f -print -quit) + echo "artifact=${ARTIFACT}" >> $GITHUB_OUTPUT + echo "Found artifact: ${ARTIFACT}" + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: jellyfin-srfplay-plugin + path: ${{ steps.jprm.outputs.artifact }} + retention-days: 30 + if-no-files-found: error diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml new file mode 100644 index 0000000..a32d4df --- /dev/null +++ b/.gitea/workflows/release.yaml @@ -0,0 +1,100 @@ +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 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' + + - 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: Update build.yaml with version + run: | + VERSION="${{ steps.get_version.outputs.version_number }}" + sed -i "s/^version:.*/version: \"${VERSION}\"/" build.yaml + cat build.yaml + + - name: Restore dependencies + run: dotnet restore + + - name: Build solution + run: dotnet build --configuration Release --no-restore + + - name: Run tests + run: dotnet test --no-build --configuration Release --verbosity normal + + - name: Install JPRM + run: | + pip install --user jprm + + - name: Build Jellyfin Plugin + id: jprm + run: | + # Build plugin using JPRM + python -m jprm --verbosity=debug plugin build ./ + + # Find the generated zip file + ARTIFACT=$(find . -name "*.zip" -type f -print -quit) + ARTIFACT_NAME=$(basename "${ARTIFACT}") + echo "artifact=${ARTIFACT}" >> $GITHUB_OUTPUT + echo "artifact_name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT + echo "Found artifact: ${ARTIFACT}" + + - name: Generate changelog + id: changelog + run: | + # Get commits since last tag + PREV_TAG=$(git tag --sort=-creatordate | grep -v "${{ steps.get_version.outputs.version }}" | head -n 1) + if [ -z "$PREV_TAG" ]; then + CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges) + else + CHANGELOG=$(git log ${PREV_TAG}..${{ steps.get_version.outputs.version }} --pretty=format:"- %s (%h)" --no-merges) + fi + + # Save to file for release notes + echo "## What's Changed" > RELEASE_NOTES.md + echo "" >> RELEASE_NOTES.md + echo "${CHANGELOG}" >> RELEASE_NOTES.md + echo "" >> RELEASE_NOTES.md + echo "**Full Changelog**: ${PREV_TAG}...${{ steps.get_version.outputs.version }}" >> RELEASE_NOTES.md + + - name: Create Release + uses: actions/gitea-release-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ steps.get_version.outputs.version }} + name: Release ${{ steps.get_version.outputs.version }} + body_path: RELEASE_NOTES.md + draft: false + prerelease: false + files: | + ${{ steps.jprm.outputs.artifact }} + build.yaml diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml new file mode 100644 index 0000000..3aa6905 --- /dev/null +++ b/.gitea/workflows/test.yaml @@ -0,0 +1,46 @@ +name: '๐Ÿงช Test Plugin' + +on: + push: + branches: + - master + - develop + paths-ignore: + - '**/*.md' + pull_request: + branches: + - master + - develop + paths-ignore: + - '**/*.md' + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' + + - name: Restore dependencies + run: dotnet restore + + - name: Build solution + run: dotnet build --configuration Debug --no-restore + + - name: Run tests + run: dotnet test --no-build --configuration Debug --verbosity normal --logger "trx;LogFileName=test-results.trx" + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-results + path: '**/test-results.trx' + retention-days: 7