From f13046681afff99be5c5695f893d3befdfaa570e Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Thu, 12 May 2022 23:59:26 +0200 Subject: [PATCH 1/2] Add gitversion on builds --- .dockerignore | 1 - .github/ISSUE_TEMPLATE/bug-report.md | 20 ------------ .github/ISSUE_TEMPLATE/bug-report.yml | 7 ++++ .github/ISSUE_TEMPLATE/feature-request.md | 18 ----------- .github/ISSUE_TEMPLATE/feature-request.yml | 3 ++ .github/workflows/build.yml | 32 +++++++++++++------ .github/workflows/docker.yml | 1 + .github/workflows/robot.yml | 1 + .github/workflows/tests.yml | 2 ++ Dockerfile | 2 ++ GitVersion.yml | 5 +++ deployment/PKGBUILD | 37 +++++++--------------- deployment/PKGBUILD.github | 24 -------------- deployment/kyoo-windows.iss | 2 +- deployment/kyoo.spec | 6 ++-- src/Directory.Build.props | 4 +++ src/Kyoo.Database/Extensions.cs | 2 +- src/Kyoo.Host.Generic/Application.cs | 11 ++++++- 18 files changed, 75 insertions(+), 103 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug-report.md create mode 100644 .github/ISSUE_TEMPLATE/bug-report.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature-request.md create mode 100644 .github/ISSUE_TEMPLATE/feature-request.yml create mode 100644 GitVersion.yml delete mode 100644 deployment/PKGBUILD.github diff --git a/.dockerignore b/.dockerignore index 81f5dbe2..f09d195d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,3 @@ -.git **/build **/dist src/Kyoo.WebApp/Front/nodes_modules diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md deleted file mode 100644 index 959bd1a2..00000000 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Bug Report -about: Create a bug report to help improve Kyoo -title: "[BUG] " -labels: bug ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. - -**Expected Behavior** -A clear and concise description of what you expected to happen. - -**Environment:** - - Platform [e.g. Windows / Linux] - - Action Version [e.g. v0.0.1 or a git commit's SHA] diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 00000000..880c64d3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,7 @@ +name: Bug Report +description: Create a bug report to help improve Kyoo +labels: [bug] +body: + - type: input + attributes: + label: "Kyoo's version" diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md deleted file mode 100644 index 19432212..00000000 --- a/.github/ISSUE_TEMPLATE/feature-request.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -name: Feature Request -about: Suggest a new feature for Kyoo (don't forget to check projects first) -title: "[FEATURE] " -labels: enhancement ---- - -**Is your feature request related to a problem? If yes, please describe.** -A clear and concise description of what the problem is. - -**Describe the feature you'd like** -A clear and concise description of what you want Kyoo to have. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml new file mode 100644 index 00000000..8f7866ec --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -0,0 +1,3 @@ +name: Feature Request +description: Suggest a new feature for Kyoo (don't forget to check projects first) +labels: [enhancement] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a42ed529..a2dbbf99 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,10 +19,13 @@ jobs: - os: macOS-latest runtime: osx-x64 artifact: macos + outputs: + version: ${{ steps.gitversion.outputs.majorMinorPatch }} steps: - uses: actions/checkout@v1 with: submodules: recursive + fetch-depth: 0 - name: Setup .NET uses: actions/setup-dotnet@v1 with: @@ -75,11 +78,23 @@ jobs: *.zip *.tar.gz + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0.9.13 + with: + versionSpec: '5.x' + - name: Determine Version + id: gitversion + uses: gittools/actions/gitversion/execute@v0.9.13 + with: + useConfigFile: true + windows_release: name: Create windows release runs-on: windows-latest needs: build if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'tags') }} + env: + version: ${{ needs.build.outputs.version }} steps: - uses: actions/checkout@v1 - name: Download windows build @@ -96,7 +111,7 @@ jobs: innosetup.exe /VERYSILENT /SUPPRESSMSGBOXES /Log=log.txt || (cat log.txt && exit 1) - name: Create windows installer shell: bash - run: iscc -Dkyoo=$(realpath dist_win) -O./ -Fkyoo-windows deployment/kyoo-windows.iss + run: iscc -Dkyoo=$(realpath dist_win) -Dversion=${version} -O./ -Fkyoo-windows deployment/kyoo-windows.iss - uses: actions/upload-artifact@v2 with: name: kyoo_windows_installer @@ -108,8 +123,8 @@ jobs: needs: build if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'tags') }} env: - description: "A media browser" - version: v0.0.1 #${{ github.ref }} + description: "A portable and vast media library solution." + version: ${{ needs.build.outputs.version }} steps: - uses: actions/checkout@v1 - name: Download linux build @@ -119,6 +134,7 @@ jobs: path: artifact - name: Unzip the published files. run: mkdir dist && tar -C dist -xzf artifact/kyoo_linux.tar.gz + - name: Create the package structure run: | sudo mkdir -p pkg/usr/lib/ @@ -140,17 +156,19 @@ jobs: run: | mkdir out sudo rm -rf pkg/DEBIAN - rpmbuild -bb --buildroot $(pwd)/out --build-in-place --define "_rpmdir $(pwd)/rpm" deployment/kyoo.spec + rpmbuild -bb --buildroot $(pwd)/out --build-in-place --define "_rpmdir $(pwd)/rpm" --define "version_ ${version}" deployment/kyoo.spec + - name: Prepare arch package run: | mkdir deployment/output - mv deployment/PKGBUILD.github deployment/PKGBUILD + sed -i s/\$version/${version}/ deployment/PKGBUILD #doing the substitution here since the pkgbuild is run in a docker without env cp -a pkg/usr deployment/output/usr - uses: edlanglois/pkgbuild-action@v1 id: makepkg with: pkgdir: deployment namcapDisable: true + - uses: actions/upload-artifact@v2 with: name: kyoo_rpm @@ -164,7 +182,3 @@ jobs: name: kyoo_arch path: ${{steps.makepkg.outputs.pkgfile0}} -# new-version: -# if: startsWith(github.ref, 'refs/tags/v') -# runs-on: ubuntu-latest - diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c68715f0..8807730b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -9,6 +9,7 @@ jobs: - uses: actions/checkout@v2 with: submodules: recursive + fetch-depth: 0 - name: Docker meta id: meta uses: crazy-max/ghaction-docker-meta@v2 diff --git a/.github/workflows/robot.yml b/.github/workflows/robot.yml index 0fe10f6d..ad34a02b 100644 --- a/.github/workflows/robot.yml +++ b/.github/workflows/robot.yml @@ -9,6 +9,7 @@ jobs: - uses: actions/checkout@v2 with: submodules: recursive + fetch-depth: 0 - name: Build the app run: docker-compose build diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 84322bc5..1cbe0283 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,6 +19,8 @@ jobs: --health-retries 5 steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Restore dependencies run: dotnet restore - name: Build diff --git a/Dockerfile b/Dockerfile index cced5bb6..8f758351 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,8 @@ RUN yarn install --frozen-lockfile RUN yarn run build --configuration production FROM mcr.microsoft.com/dotnet/sdk:6.0 as builder +WORKDIR /kyoo +COPY .git/ ./.git/ COPY . . RUN dotnet publish -c Release -o /opt/kyoo '-p:SkipWebApp=true;SkipTranscoder=true;CheckCodingStyle=false' src/Kyoo.Host.Console diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 00000000..122fa7e4 --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,5 @@ +mode: Mainline +branches: {} +ignore: + sha: [] +merge-message-formats: {} diff --git a/deployment/PKGBUILD b/deployment/PKGBUILD index 5446499f..7cef4c58 100644 --- a/deployment/PKGBUILD +++ b/deployment/PKGBUILD @@ -1,41 +1,28 @@ # Maintainer: Zoe Roux -pkgname=kyoo +pkgname=kyoo-bin pkgver=1.0.0 pkgrel=1 epoch= -pkgdesc="A media browser." +pkgdesc="A portable and vast media library solution." arch=("i686" "x86_64" "armv6h") url="https://github.com/AnonymusRaccoon/Kyoo" license=("GPLv3") groups=() -depends=("dotnet-runtime>=5" "aspnet-runtime>=5" "ffmpeg") -makedepends=("dotnet-sdk>=5" "cmake" "gcc" "make" "npm" "git") -source=("git+https://github.com/AnonymusRaccoon/Kyoo" #tag=v${pkgver} - "kyoo.service" - "kyoo.sysusers" - "kyoo.tmpfiles") -sha256sums=("SKIP" "SKIP" "SKIP" "SKIP") +depends=("ffmpeg") +makedepends=() +# The output folder is needed but we can't use directory in the source array. +source=() +sha256sums=() +options=('staticlibs') - -prepare() { - # cd "Kyoo-$pkgver" - cd "Kyoo" - # This is necessary since submodules paths are relative and PKGBUILD remote are the local directory. - git remote set-url origin https://github.com/AnonymusRaccoon/Kyoo - git submodule update --init --recursive +pkgver() { + echo $version # The version is available as an environment variable. } build() { - # cd "Kyoo-$pkgver" - cd "Kyoo" - export DOTNET_CLI_TELEMETRY_OPTOUT=1 - dotnet publish -c Release -o "$srcdir/output" Kyoo.Host.Console + cp -a "$srcdir/../output" "$srcdir" } package() { - mkdir -p "$pkgdir/usr/lib" - cp -r --no-preserve ownership "$srcdir/output" "$pkgdir/usr/lib/kyoo" - install -Dm 644 kyoo.service -t "$pkgdir/usr/lib/systemd/system/" - install -Dm 644 kyoo.sysusers "$pkgdir/usr/lib/sysusers.d/kyoo.conf" - install -Dm 644 kyoo.tmpfiles "$pkgdir/usr/lib/tmpfiles.d/kyoo.conf" + cp -a "$srcdir/output/." "$pkgdir" } diff --git a/deployment/PKGBUILD.github b/deployment/PKGBUILD.github deleted file mode 100644 index e464dfc8..00000000 --- a/deployment/PKGBUILD.github +++ /dev/null @@ -1,24 +0,0 @@ -# Maintainer: Zoe Roux -pkgname=kyoo-bin -pkgver=1.0.0 -pkgrel=1 -epoch= -pkgdesc="A media browser." -arch=("i686" "x86_64" "armv6h") -url="https://github.com/AnonymusRaccoon/Kyoo" -license=("GPLv3") -groups=() -depends=("ffmpeg") -makedepends=() -# The output folder is needed but we can't use directory in the source array. -source=() -sha256sums=() -options=('staticlibs') - -build() { - cp -a "$srcdir/../output" "$srcdir" -} - -package() { - cp -a "$srcdir/output/." "$pkgdir" -} diff --git a/deployment/kyoo-windows.iss b/deployment/kyoo-windows.iss index 1986eb0d..87bbb976 100644 --- a/deployment/kyoo-windows.iss +++ b/deployment/kyoo-windows.iss @@ -1,7 +1,7 @@ [Setup] AppId={{31A61284-7939-46BC-B584-D2279A6EEEE8} AppName=Kyoo -AppVersion=1.0 +AppVersion={#version} AppPublisher=SDG AppPublisherURL=https://github.com/AnonymusRaccoon/Kyoo AppSupportURL=https://github.com/AnonymusRaccoon/Kyoo diff --git a/deployment/kyoo.spec b/deployment/kyoo.spec index b59e907e..9c6d2c70 100644 --- a/deployment/kyoo.spec +++ b/deployment/kyoo.spec @@ -1,9 +1,9 @@ %define _build_id_links none Name: kyoo -Version: 0.0.1 -Release: 1 -Summary: A media browser +Version: %{version_} +Release: 1%{?dist} +Summary: A portable and vast media library solution. URL: https://github.com/AnonymusRaccoon/Kyoo License: GPL-3.0 BuildArch: x86_64 diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 31fdbf88..aa0df66e 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -33,6 +33,10 @@ + + all + runtime; build; native; contentfiles; analyzers + diff --git a/src/Kyoo.Database/Extensions.cs b/src/Kyoo.Database/Extensions.cs index 8c205caa..f7f75850 100644 --- a/src/Kyoo.Database/Extensions.cs +++ b/src/Kyoo.Database/Extensions.cs @@ -36,7 +36,7 @@ namespace Kyoo.Database { static string ToDbProperty(string key) { - return key switch + return key.ToUpperInvariant() switch { "USER" => "USER ID", _ => key diff --git a/src/Kyoo.Host.Generic/Application.cs b/src/Kyoo.Host.Generic/Application.cs index 1dce4573..e9dc7d6f 100644 --- a/src/Kyoo.Host.Generic/Application.cs +++ b/src/Kyoo.Host.Generic/Application.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Reflection; using System.Threading; using System.Threading.Tasks; using Autofac; @@ -44,7 +45,7 @@ namespace Kyoo.Host.Generic /// Hosts of kyoo (main functions) generally only create a new /// and return . /// - public class Application : IApplication + public class Application : IApplication, IDisposable { /// /// The environment in witch Kyoo will run (ether "Production" or "Development"). @@ -202,6 +203,7 @@ namespace Kyoo.Host.Generic try { _logger.Information("Running as {Name}", Environment.UserName); + _logger.Information("Version: {Version}", Assembly.GetExecutingAssembly().GetName().Version.ToString(3)); _logger.Information("Data directory: {DataDirectory}", GetDataDirectory()); await host.RunAsync(cancellationToken); } @@ -309,5 +311,12 @@ namespace Kyoo.Host.Generic .Enrich.WithThreadId() .Enrich.FromLogContext(); } + + /// + public void Dispose() + { + _tokenSource.Dispose(); + GC.SuppressFinalize(this); + } } } From fc67a19915877870d54d32c708107eed4a362cd2 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 13 May 2022 18:27:49 +0200 Subject: [PATCH 2/2] Remove PR template --- .github/PULL_REQUEST_TEMPLATE.md | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 665f3f19..00000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,20 +0,0 @@ -## Proposed changes - -Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. -If it fixes a bug or resolves a feature request, be sure to link to that issue. - -## Information - - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - - [ ] New public API added - - [ ] Non-breaking changes - -## Checklist - - - [ ] I have added tests that prove my fix is effective or that my feature works - - [ ] I have added necessary documentation (if appropriate) - -## Further comments - -If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did -and what alternatives you considered, etc... -