109 lines
3.9 KiB
YAML
Raw Permalink Normal View History

2024-10-06 19:03:15 +02:00
name: "Build Plugin"
2022-06-10 16:19:07 -05:00
on:
push:
2024-10-18 12:39:56 +02:00
branches:
2024-11-05 13:11:27 +00:00
- '*' # Triggers on any branch push
2024-04-19 21:41:03 -04:00
paths-ignore:
2024-10-06 19:03:15 +02:00
- "**/README.md"
- ".github/ISSUE_TEMPLATE/**"
- "docs/**"
- "images/**"
- "manifest.json"
2022-06-10 16:19:07 -05:00
2024-03-01 11:40:05 -05:00
permissions:
contents: write
2024-03-29 20:40:49 +01:00
packages: write
2024-03-01 11:40:05 -05:00
2022-06-10 16:19:07 -05:00
jobs:
build:
2024-04-10 07:26:03 -04:00
if: ${{ ! startsWith(github.event.head_commit.message, 'v0.') }}
2022-06-10 16:19:07 -05:00
runs-on: ubuntu-latest
steps:
2024-10-06 19:03:15 +02:00
- name: Sanitize head_ref
run: |
# Get the branch name and sanitize it
SANITIZED_BRANCH_NAME=$(echo "${{ github.head_ref }}" | sed 's/[^a-zA-Z0-9.-]/_/g')
# Export it as an environment variable
echo "SANITIZED_BRANCH_NAME=$SANITIZED_BRANCH_NAME" >> $GITHUB_ENV
- uses: actions/checkout@v4
2024-10-18 12:39:56 +02:00
- name: Read version from VERSION.txt
id: read-version
run: |
MAIN_VERSION=$(cat VERSION.txt)
echo "MAIN_VERSION=${MAIN_VERSION}"
echo "MAIN_VERSION=$MAIN_VERSION" >> $GITHUB_ENV
- name: Check for BETA file
id: check-beta
run: |
if [ -f "BETA" ]; then
echo "IS_BETA=true" >> $GITHUB_ENV
else
echo "IS_BETA=false" >> $GITHUB_ENV
fi
2024-10-06 19:03:15 +02:00
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Minify HTML
run: |
npx html-minifier-terser --collapse-boolean-attributes --collapse-whitespace --remove-comments --remove-optional-tags --remove-redundant-attributes --remove-script-type-attributes --remove-tag-whitespace --use-short-doctype --minify-css true --minify-js true -o IntroSkipper/Configuration/configPage.html IntroSkipper/Configuration/configPage.html
npx terser IntroSkipper/Configuration/inject.js -o IntroSkipper/Configuration/inject.js -c -m
npx terser IntroSkipper/Configuration/visualizer.js -o IntroSkipper/Configuration/visualizer.js -c -m
2024-10-06 19:03:15 +02:00
2024-10-18 12:39:56 +02:00
- name: Restore Beta dependencies
if: ${{env.IS_BETA == 'true' }}
2024-10-11 19:11:42 +02:00
run: |
dotnet nuget add source --username ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name jellyfin-pre "https://nuget.pkg.github.com/jellyfin/index.json"
dotnet tool install --global dotnet-outdated-tool
dotnet outdated -pre Always -u -inc Jellyfin
2024-10-06 19:03:15 +02:00
2024-10-18 12:39:56 +02:00
- name: Restore dependencies
if: ${{env.IS_BETA == 'false' }}
run: dotnet restore
2024-10-06 19:03:15 +02:00
- name: Embed version info
run: |
GITHUB_SHA=${{ github.sha }}
sed -i "s/string\.Empty/\"$GITHUB_SHA\"/g" IntroSkipper/Helper/Commit.cs
2024-10-06 19:03:15 +02:00
- name: Retrieve commit identification
run: |
GIT_HASH=$(git rev-parse --short HEAD)
echo "GIT_HASH=${GIT_HASH}" >> $GITHUB_ENV
- name: Build
run: dotnet build --no-restore
- name: Upload artifact
uses: actions/upload-artifact@v4.3.6
with:
name: IntroSkipper-${{ env.GIT_HASH }}.dll
path: IntroSkipper/bin/Debug/net8.0/IntroSkipper.dll
2024-10-06 19:03:15 +02:00
if-no-files-found: error
- name: Create archive
2024-11-05 13:11:27 +00:00
if: startsWith(github.ref_name, '10.') # only do a preview release on 10.x branches
run: zip -j "intro-skipper-${{ env.GIT_HASH }}.zip" IntroSkipper/bin/Debug/net8.0/IntroSkipper.dll
2024-10-06 19:03:15 +02:00
- name: Create/replace the preview release and upload artifacts
2024-11-05 13:11:27 +00:00
if: startsWith(github.ref_name, '10.') # only do a preview release on 10.x branches
2024-10-06 19:03:15 +02:00
run: |
2024-10-18 12:39:56 +02:00
gh release delete "${{ env.MAIN_VERSION }}/preview" --cleanup-tag --yes || true
gh release create "${{ env.MAIN_VERSION }}/preview" "intro-skipper-${{ env.GIT_HASH }}.zip" --prerelease --title "intro-skipper-${{ env.GIT_HASH }}" --notes "This is a prerelease version." --target ${{ env.MAIN_VERSION }}
2024-10-06 19:03:15 +02:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}