From 01007dee28c4a7c531e17d05b35b5b8f342226cc Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Wed, 28 Jul 2021 15:37:13 -0500 Subject: [PATCH 01/12] =?UTF-8?q?Refactored=20logs=20to=20use=20a=20logs/?= =?UTF-8?q?=20folder=20and=20also=20roll=20over=20after=2010MB.=20?= =?UTF-8?q?=E2=80=A6=20(#448)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Changed - Changed: Log files now roll (kavita, kavita1, etc) up to 5 files, each with a max of 10MB each. After all 5 files fill up, they will roll over. (Closes #446 ) ============================= * Refactored logs to use a logs/ folder and also roll over after 10MB. A maximum of 5 logs will persist (50MB of log data). * Updated entrypoint to accommodate rolling logs Co-authored-by: Chris Plaatjes --- API/Services/Tasks/BackupService.cs | 19 +++++++++-------- API/appsettings.Development.json | 6 +++--- entrypoint.sh | 33 ++++++++++++----------------- 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/API/Services/Tasks/BackupService.cs b/API/Services/Tasks/BackupService.cs index a5b115c3f..e04e5373f 100644 --- a/API/Services/Tasks/BackupService.cs +++ b/API/Services/Tasks/BackupService.cs @@ -20,6 +20,7 @@ namespace API.Services.Tasks private readonly ILogger _logger; private readonly IDirectoryService _directoryService; private readonly string _tempDirectory = Path.Join(Directory.GetCurrentDirectory(), "temp"); + private readonly string _logDirectory = Path.Join(Directory.GetCurrentDirectory(), "logs"); private readonly IList _backupFiles; @@ -28,7 +29,7 @@ namespace API.Services.Tasks _unitOfWork = unitOfWork; _logger = logger; _directoryService = directoryService; - + var maxRollingFiles = config.GetMaxRollingFiles(); var loggingSection = config.GetLoggingFileName(); var files = LogFiles(maxRollingFiles, loggingSection); @@ -53,7 +54,7 @@ namespace API.Services.Tasks var fi = new FileInfo(logFileName); var files = maxRollingFiles > 0 - ? _directoryService.GetFiles(Directory.GetCurrentDirectory(), $@"{fi.Name}{multipleFileRegex}\.log") + ? _directoryService.GetFiles(_logDirectory, $@"{Path.GetFileNameWithoutExtension(fi.Name)}{multipleFileRegex}\.log") : new[] {"kavita.log"}; return files; } @@ -63,17 +64,17 @@ namespace API.Services.Tasks { _logger.LogInformation("Beginning backup of Database at {BackupTime}", DateTime.Now); var backupDirectory = Task.Run(() => _unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.BackupDirectory)).Result.Value; - + _logger.LogDebug("Backing up to {BackupDirectory}", backupDirectory); if (!DirectoryService.ExistOrCreate(backupDirectory)) { _logger.LogError("Could not write to {BackupDirectory}; aborting backup", backupDirectory); return; } - + var dateString = DateTime.Now.ToShortDateString().Replace("/", "_"); var zipPath = Path.Join(backupDirectory, $"kavita_backup_{dateString}.zip"); - + if (File.Exists(zipPath)) { _logger.LogInformation("{ZipFile} already exists, aborting", zipPath); @@ -83,7 +84,7 @@ namespace API.Services.Tasks var tempDirectory = Path.Join(_tempDirectory, dateString); DirectoryService.ExistOrCreate(tempDirectory); DirectoryService.ClearDirectory(tempDirectory); - + _directoryService.CopyFilesToDirectory( _backupFiles.Select(file => Path.Join(Directory.GetCurrentDirectory(), file)).ToList(), tempDirectory); try @@ -142,10 +143,10 @@ namespace API.Services.Tasks _logger.LogError(ex, "There was an issue deleting {FileName}", file.Name); } } - + } _logger.LogInformation("Finished cleanup of Database backups at {Time}", DateTime.Now); } - + } -} \ No newline at end of file +} diff --git a/API/appsettings.Development.json b/API/appsettings.Development.json index 35e9218b9..9d93e100a 100644 --- a/API/appsettings.Development.json +++ b/API/appsettings.Development.json @@ -17,10 +17,10 @@ "Microsoft.AspNetCore.Hosting.Internal.WebHost": "Information" }, "File": { - "Path": "kavita.log", + "Path": "logs/kavita.log", "Append": "True", - "FileSizeLimitBytes": 0, - "MaxRollingFiles": 0 + "FileSizeLimitBytes": 10485760, + "MaxRollingFiles": 5 } }, "Port": 5000 diff --git a/entrypoint.sh b/entrypoint.sh index 3a5328354..0db3d824a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -46,6 +46,20 @@ else ln -s /kavita/data/cache /kavita/cache fi +if [ -d /kavita/data/logs ] +then + if [ -d /kavita/logs ] + then + unlink /kavita/logs + ln -s /kavita/data/logs /kavita/logs + else + ln -s /kavita/data/logs /kavita/logs + fi +else + mkdir /kavita/data/logs + ln -s /kavita/data/logs /kavita/logs +fi + if [ -d /kavita/data/stats ] then if [ -d /kavita/stats ] @@ -60,25 +74,6 @@ else ln -s /kavita/data/stats /kavita/stats fi -# Checks for the log file - -if test -f "/kavita/data/logs/kavita.log" -then - rm /kavita/kavita.log - ln -s /kavita/data/logs/kavita.log /kavita/ -else - if [ -d /kavita/data/logs ] - then - echo "" > /kavita/data/logs/kavita.log || true - ln -s /kavita/data/logs/kavita.log /kavita/ - else - mkdir /kavita/data/logs - echo "" > /kavita/data/logs/kavita.log || true - ln -s /kavita/data/logs/kavita.log /kavita/ - fi - -fi - chmod +x ./Kavita ./Kavita From fd6fa2fce48e6e28c6358a79380ec63f8aeab31c Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Thu, 29 Jul 2021 19:57:06 -0500 Subject: [PATCH 02/12] Bugfix/in progress (#452) # Fixed - Fixed: Fixed an issue in In Progress where it would not pull the series with correct pagination due to the unique situation with the query. All series that are in progress should now return. ============================ * Fixed In Progress not showing for all series due to pagination bug * Version bump --- API/Controllers/SeriesController.cs | 11 ++++- API/Data/SeriesRepository.cs | 71 ++++++++++++++------------- API/Extensions/FilterDtoExtensions.cs | 7 +-- API/Interfaces/ISeriesRepository.cs | 2 +- Kavita.Common/Kavita.Common.csproj | 2 +- 5 files changed, 52 insertions(+), 41 deletions(-) diff --git a/API/Controllers/SeriesController.cs b/API/Controllers/SeriesController.cs index b739b62bd..7bf59c7e0 100644 --- a/API/Controllers/SeriesController.cs +++ b/API/Controllers/SeriesController.cs @@ -168,8 +168,17 @@ namespace API.Controllers [HttpPost("in-progress")] public async Task>> GetInProgress(FilterDto filterDto, [FromQuery] UserParams userParams, [FromQuery] int libraryId = 0) { + // NOTE: This has to be done manually like this due to the DisinctBy requirement var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername()); - return Ok((await _unitOfWork.SeriesRepository.GetInProgress(user.Id, libraryId, userParams, filterDto)).DistinctBy(s => s.Name)); + var results = await _unitOfWork.SeriesRepository.GetInProgress(user.Id, libraryId, userParams, filterDto); + + var listResults = results.DistinctBy(s => s.Name).Skip((userParams.PageNumber - 1) * userParams.PageSize) + .Take(userParams.PageSize).ToList(); + var pagedList = new PagedList(listResults, listResults.Count, userParams.PageNumber, userParams.PageSize); + + Response.AddPaginationHeader(pagedList.CurrentPage, pagedList.PageSize, pagedList.TotalCount, pagedList.TotalPages); + + return Ok(pagedList); } [Authorize(Policy = "RequireAdminRole")] diff --git a/API/Data/SeriesRepository.cs b/API/Data/SeriesRepository.cs index afaf17f5b..7a608882a 100644 --- a/API/Data/SeriesRepository.cs +++ b/API/Data/SeriesRepository.cs @@ -323,7 +323,6 @@ namespace API.Data var allQuery = _context.Series .Where(s => userLibraries.Contains(s.LibraryId) && formats.Contains(s.Format)) - .AsNoTracking() .OrderByDescending(s => s.Created) .ProjectTo(_mapper.ConfigurationProvider) .AsNoTracking(); @@ -333,7 +332,6 @@ namespace API.Data var query = _context.Series .Where(s => s.LibraryId == libraryId && formats.Contains(s.Format)) - .AsNoTracking() .OrderByDescending(s => s.Created) .ProjectTo(_mapper.ConfigurationProvider) .AsNoTracking(); @@ -349,48 +347,55 @@ namespace API.Data /// Pagination information /// Optional (default null) filter on query /// - public async Task> GetInProgress(int userId, int libraryId, UserParams userParams, FilterDto filter) + public async Task> GetInProgress(int userId, int libraryId, UserParams userParams, FilterDto filter) { var formats = filter.GetSqlFilter(); + IList userLibraries; + if (libraryId == 0) + { + userLibraries = _context.Library + .Include(l => l.AppUsers) + .Where(library => library.AppUsers.Any(user => user.Id == userId)) + .AsNoTracking() + .Select(library => library.Id) + .ToList(); + } + else + { + userLibraries = new List() {libraryId}; + } + var series = _context.Series - .Where(s => formats.Contains(s.Format)) + .Where(s => formats.Contains(s.Format) && userLibraries.Contains(s.LibraryId)) .Join(_context.AppUserProgresses, s => s.Id, progress => progress.SeriesId, (s, progress) => new { Series = s, PagesRead = _context.AppUserProgresses.Where(s1 => s1.SeriesId == s.Id).Sum(s1 => s1.PagesRead), progress.AppUserId, LastModified = _context.AppUserProgresses.Where(p => p.Id == progress.Id).Max(p => p.LastModified) - }).AsNoTracking(); - if (libraryId == 0) - { - var userLibraries = _context.Library - .Include(l => l.AppUsers) - .Where(library => library.AppUsers.Any(user => user.Id == userId)) - .AsNoTracking() - .Select(library => library.Id) - .ToList(); - series = series.Where(s => s.AppUserId == userId - && s.PagesRead > 0 - && s.PagesRead < s.Series.Pages - && userLibraries.Contains(s.Series.LibraryId) - && formats.Contains(s.Series.Format)); - } - else - { - series = series.Where(s => s.AppUserId == userId - && s.PagesRead > 0 - && s.PagesRead < s.Series.Pages - && s.Series.LibraryId == libraryId - && formats.Contains(s.Series.Format)); - } - - var retSeries = series - .OrderByDescending(s => s.LastModified) - .Select(s => s.Series) - .ProjectTo(_mapper.ConfigurationProvider) + }) .AsNoTracking(); - return await PagedList.CreateAsync(retSeries, userParams.PageNumber, userParams.PageSize); + + + var retSeries = series.Where(s => s.AppUserId == userId + && s.PagesRead > 0 + && s.PagesRead < s.Series.Pages + /*&& userLibraries.Contains(s.Series.LibraryId)*/ + /* && formats.Contains(s.Series.Format) */) + .OrderByDescending(s => s.LastModified) + .Select(s => s.Series) + .ProjectTo(_mapper.ConfigurationProvider) + .AsNoTracking(); + + // var retSeries = series + // .OrderByDescending(s => s.LastModified) + // .Select(s => s.Series) + // .ProjectTo(_mapper.ConfigurationProvider) + // .AsNoTracking(); + // BUG: Pagination does not work for this query as when we pull the data back, we get multiple rows of the same series + return await retSeries.ToListAsync(); + //return await PagedList.CreateAsync(retSeries, userParams.PageNumber, userParams.PageSize); } public async Task GetSeriesMetadata(int seriesId) diff --git a/API/Extensions/FilterDtoExtensions.cs b/API/Extensions/FilterDtoExtensions.cs index 1b6689d49..7e5a818ec 100644 --- a/API/Extensions/FilterDtoExtensions.cs +++ b/API/Extensions/FilterDtoExtensions.cs @@ -7,7 +7,7 @@ namespace API.Extensions { public static class FilterDtoExtensions { - private static IList _allFormats = Enum.GetValues(); + private static readonly IList AllFormats = Enum.GetValues(); public static IList GetSqlFilter(this FilterDto filter) { @@ -19,10 +19,7 @@ namespace API.Extensions (MangaFormat) format }; } - else - { - return _allFormats; - } + return AllFormats; } } } diff --git a/API/Interfaces/ISeriesRepository.cs b/API/Interfaces/ISeriesRepository.cs index bedbf8b56..399bf4f1a 100644 --- a/API/Interfaces/ISeriesRepository.cs +++ b/API/Interfaces/ISeriesRepository.cs @@ -58,7 +58,7 @@ namespace API.Interfaces Task GetVolumeCoverImageAsync(int volumeId); Task GetSeriesCoverImageAsync(int seriesId); - Task> GetInProgress(int userId, int libraryId, UserParams userParams, FilterDto filter); + Task> GetInProgress(int userId, int libraryId, UserParams userParams, FilterDto filter); Task> GetRecentlyAdded(int libraryId, int userId, UserParams userParams, FilterDto filter); Task GetSeriesMetadata(int seriesId); Task> GetSeriesDtoForCollectionAsync(int collectionId, int userId, UserParams userParams); diff --git a/Kavita.Common/Kavita.Common.csproj b/Kavita.Common/Kavita.Common.csproj index b4bc5f86a..d099ff6ea 100644 --- a/Kavita.Common/Kavita.Common.csproj +++ b/Kavita.Common/Kavita.Common.csproj @@ -4,7 +4,7 @@ net5.0 kavitareader.com Kavita - 0.4.3.6 + 0.4.3.7 en From 8676b81821f34a88fd0b80e90bf5bac2010d7d44 Mon Sep 17 00:00:00 2001 From: Robbie Davis Date: Fri, 30 Jul 2021 08:56:03 -0400 Subject: [PATCH 03/12] Adding version bump workflow --- .github/workflows/version-bump.yml | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/version-bump.yml diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml new file mode 100644 index 000000000..94d2bb880 --- /dev/null +++ b/.github/workflows/version-bump.yml @@ -0,0 +1,41 @@ +name: Bump .Net Version + +on: + push: + branches: [ version-bump ] + +jobs: + bump: + name: Version bump + runs-on: windows-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: version-bump + + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.100 + + - name: Install dependencies + run: dotnet restore + + - name: Build + run: dotnet build --configuration Release --no-restore + + - name: Bump versions + uses: SiqiLu/dotnet-bump-version@master + with: + version_files: Kavita.Common/Kavita.Common.csproj + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Merge bump branch -> pr branch + uses: devmasx/merge-branch@v1.3.1 + with: + type: now + from_branch: version-bump + target_branch: ${{ github.event.inputs.branch }} + github_token: ${{ secrets.GITHUB_TOKEN }} From 1ec8f6235fee9b1da14c940c6e381eb886f770aa Mon Sep 17 00:00:00 2001 From: Robbie Davis Date: Fri, 30 Jul 2021 09:30:55 -0400 Subject: [PATCH 04/12] Updating version-bump.yml --- .github/workflows/version-bump.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index 94d2bb880..f7c02f11c 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -2,7 +2,8 @@ name: Bump .Net Version on: push: - branches: [ version-bump ] + branches: + - 'version-bump' jobs: bump: From 2f8af9f8e69a72b1b01b38af605688c17b6a8b45 Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Fri, 30 Jul 2021 09:02:17 -0500 Subject: [PATCH 05/12] Fixed the In progress API returning back series that didn't belong (#453) * Fixed the In progress API returning back series that had another users progress on them. Added SplitQuery which speeds up query significantly. * Try out putting PR body into notification --- .github/workflows/nightly-docker.yml | 10 +++++----- API/Data/SeriesRepository.cs | 19 +++++-------------- Kavita.Common/Kavita.Common.csproj | 2 +- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/.github/workflows/nightly-docker.yml b/.github/workflows/nightly-docker.yml index 680015afe..9df2375cb 100644 --- a/.github/workflows/nightly-docker.yml +++ b/.github/workflows/nightly-docker.yml @@ -28,7 +28,7 @@ jobs: echo 'Copying back to Kavita wwwroot' rsync -a dist/ ../../API/wwwroot/ - + cd ../ || exit - name: Get csproj Version @@ -38,14 +38,14 @@ jobs: proj-path: Kavita.Common/Kavita.Common.csproj - name: Echo csproj version - run: echo "${{steps.get-version.outputs.assembly-version}}" + run: echo "${{steps.get-version.outputs.assembly-version}}" - name: Compile dotnet app uses: actions/setup-dotnet@v1 with: dotnet-version: '5.0.x' - run: ./monorepo-build.sh - + - name: Trigger Sentry workflow uses: benc-uk/workflow-dispatch@v1 with: @@ -77,12 +77,12 @@ jobs: - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} - + - name: Notify Discord uses: rjstone/discord-webhook-notify@v1 with: severity: info - description: + description: ${{ github.event.body }} details: 'https://hub.docker.com/r/kizaing/kavita/tags?page=1&ordering=last_updated' text: A new nightly build has been released for docker. webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }} diff --git a/API/Data/SeriesRepository.cs b/API/Data/SeriesRepository.cs index 7a608882a..92d19042b 100644 --- a/API/Data/SeriesRepository.cs +++ b/API/Data/SeriesRepository.cs @@ -370,32 +370,23 @@ namespace API.Data .Join(_context.AppUserProgresses, s => s.Id, progress => progress.SeriesId, (s, progress) => new { Series = s, - PagesRead = _context.AppUserProgresses.Where(s1 => s1.SeriesId == s.Id).Sum(s1 => s1.PagesRead), + PagesRead = _context.AppUserProgresses.Where(s1 => s1.SeriesId == s.Id && s1.AppUserId == userId).Sum(s1 => s1.PagesRead), progress.AppUserId, - LastModified = _context.AppUserProgresses.Where(p => p.Id == progress.Id).Max(p => p.LastModified) + LastModified = _context.AppUserProgresses.Where(p => p.Id == progress.Id && p.AppUserId == userId).Max(p => p.LastModified) }) .AsNoTracking(); - - var retSeries = series.Where(s => s.AppUserId == userId && s.PagesRead > 0 - && s.PagesRead < s.Series.Pages - /*&& userLibraries.Contains(s.Series.LibraryId)*/ - /* && formats.Contains(s.Series.Format) */) + && s.PagesRead < s.Series.Pages) .OrderByDescending(s => s.LastModified) .Select(s => s.Series) .ProjectTo(_mapper.ConfigurationProvider) + .AsSplitQuery() .AsNoTracking(); - // var retSeries = series - // .OrderByDescending(s => s.LastModified) - // .Select(s => s.Series) - // .ProjectTo(_mapper.ConfigurationProvider) - // .AsNoTracking(); - // BUG: Pagination does not work for this query as when we pull the data back, we get multiple rows of the same series + // Pagination does not work for this query as when we pull the data back, we get multiple rows of the same series. See controller for pagination code return await retSeries.ToListAsync(); - //return await PagedList.CreateAsync(retSeries, userParams.PageNumber, userParams.PageSize); } public async Task GetSeriesMetadata(int seriesId) diff --git a/Kavita.Common/Kavita.Common.csproj b/Kavita.Common/Kavita.Common.csproj index d099ff6ea..fbba64189 100644 --- a/Kavita.Common/Kavita.Common.csproj +++ b/Kavita.Common/Kavita.Common.csproj @@ -4,7 +4,7 @@ net5.0 kavitareader.com Kavita - 0.4.3.7 + 0.4.3.8 en From e3cfbadd9d454d76bb3840a4dae8c8f13ac30858 Mon Sep 17 00:00:00 2001 From: Robbie Davis Date: Mon, 2 Aug 2021 08:22:33 -0400 Subject: [PATCH 06/12] Feature/version bump test (#449) ## Changes - Reconfigured Github workflow for better visibility - Added automated version bump on merge push to Develop branch --- .github/workflows/nightly-docker.yml | 6 +- .github/workflows/sonar-scan.yml | 150 ++++++++++++++++++++++++++- .github/workflows/stable-docker.yml | 8 +- .github/workflows/version-bump.yml | 42 -------- 4 files changed, 155 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/version-bump.yml diff --git a/.github/workflows/nightly-docker.yml b/.github/workflows/nightly-docker.yml index 9df2375cb..45621456a 100644 --- a/.github/workflows/nightly-docker.yml +++ b/.github/workflows/nightly-docker.yml @@ -1,9 +1,7 @@ name: Build Nightly Docker on: - push: - branches: - - 'develop' + workflow_dispatch: jobs: docker: @@ -13,6 +11,8 @@ jobs: - name: Check Out Repo uses: actions/checkout@v2 + with: + ref: develop - name: NodeJS to Compile WebUI uses: actions/setup-node@v2.1.5 diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index b6dfdf351..3955b7cb4 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -9,7 +9,35 @@ on: jobs: build: - name: Build and Scan + name: Build .Net + runs-on: windows-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.100 + + - name: Install dependencies + run: dotnet restore + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 1.11 + + - uses: actions/upload-artifact@v2 + with: + name: csproj + path: Kavita.Common/Kavita.Common.csproj + + test: + name: Install Sonar & Test + needs: build runs-on: windows-latest steps: - name: Checkout Repo @@ -52,7 +80,7 @@ jobs: New-Item -Path .\.sonar\scanner -ItemType Directory dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner - - name: Build and analyze + - name: Sonar Scan env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} @@ -64,3 +92,121 @@ jobs: - name: Test run: dotnet test --no-restore --verbosity normal + + bump: + name: Create branch for bump if Develop push + runs-on: ubuntu-latest + needs: [ build, test ] + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} + steps: + - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 + + - name: Get csproj Version + uses: naminodarie/get-net-sdk-project-versions-action@v1 + id: get-version + with: + proj-path: Kavita.Common/Kavita.Common.csproj + + - name: Get branch name + id: branch-name + uses: tj-actions/branch-names@v4.5 + + - name: Echo branch name + run: echo "${{ steps.branch-name.outputs.current_branch }}" + + - name: Echo csproj version + run: echo "${{steps.get-version.outputs.assembly-version}}" + + - name: Create Branch + uses: peterjgrainger/action-create-branch@v2.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + branch: "version-bump" + + version: + name: Bump version if Develop push + needs: [ bump ] + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} + steps: + + - name: Download a single artifact + uses: actions/download-artifact@v2 + with: + name: csproj + + - name: Get csproj Version + uses: naminodarie/get-net-sdk-project-versions-action@v1 + id: get-version + with: + proj-path: Kavita.Common.csproj + + - name: Get branch name + id: branch-name + uses: tj-actions/branch-names@v4.5 + + - uses: actions/checkout@v2 + with: + ref: version-bump + fetch-depth: 0 + + - name: Create local changes for reference + run: | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git pull origin version-bump-${{steps.get-version.outputs.assembly-version}} + git commit --allow-empty -m "Trigger Build" + + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: version-bump-${{steps.get-version.outputs.assembly-version}} + + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.100 + + - name: Install dependencies + run: dotnet restore + + - name: Build + run: dotnet build --configuration Release --no-restore + + - name: Bump versions + uses: SiqiLu/dotnet-bump-version@master + with: + version_files: Kavita.Common/Kavita.Common.csproj + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Merge bump branch -> pr branch + uses: devmasx/merge-branch@v1.3.1 + with: + type: now + from_branch: version-bump-${{ github.event.inputs.version }} + target_branch: develop + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Trigger Docker Nightly + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: Build Nightly Docker + token: ${{ secrets.REPO_GHA_PAT }} + + stable: + name: Trigger Stable Docker if Main push + needs: [ build, test ] + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} + steps: + + - name: If Push to Main, Trigger Docker Stable + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: Build Stable Docker + token: ${{ secrets.REPO_GHA_PAT }} \ No newline at end of file diff --git a/.github/workflows/stable-docker.yml b/.github/workflows/stable-docker.yml index cbf5c14c6..9f4dc8363 100644 --- a/.github/workflows/stable-docker.yml +++ b/.github/workflows/stable-docker.yml @@ -1,9 +1,7 @@ name: Build Stable Docker on: - push: - branches: - - 'main' + workflow_dispatch: jobs: docker: @@ -12,6 +10,8 @@ jobs: - name: Check Out Repo uses: actions/checkout@v2 + with: + ref: main - name: NodeJS to Compile WebUI uses: actions/setup-node@v2.1.5 @@ -99,7 +99,7 @@ jobs: uses: rjstone/discord-webhook-notify@v1 with: severity: info - description: + description: ${{ github.event.body }} details: 'https://hub.docker.com/r/kizaing/kavita/tags?page=1&ordering=last_updated' text: A new stable build has been released for docker. webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }} \ No newline at end of file diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml deleted file mode 100644 index f7c02f11c..000000000 --- a/.github/workflows/version-bump.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Bump .Net Version - -on: - push: - branches: - - 'version-bump' - -jobs: - bump: - name: Version bump - runs-on: windows-latest - steps: - - name: Checkout Repo - uses: actions/checkout@v2 - with: - fetch-depth: 0 - ref: version-bump - - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 5.0.100 - - - name: Install dependencies - run: dotnet restore - - - name: Build - run: dotnet build --configuration Release --no-restore - - - name: Bump versions - uses: SiqiLu/dotnet-bump-version@master - with: - version_files: Kavita.Common/Kavita.Common.csproj - github_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Merge bump branch -> pr branch - uses: devmasx/merge-branch@v1.3.1 - with: - type: now - from_branch: version-bump - target_branch: ${{ github.event.inputs.branch }} - github_token: ${{ secrets.GITHUB_TOKEN }} From 514547a2b2459f53eae1b22e986f70971ab92b8a Mon Sep 17 00:00:00 2001 From: Robbie Davis Date: Mon, 2 Aug 2021 08:34:45 -0400 Subject: [PATCH 07/12] Updating workflow --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 3955b7cb4..a3538cec4 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -123,7 +123,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - branch: "version-bump" + branch: "version-bump-${{steps.get-version.outputs.assembly-version}}" version: name: Bump version if Develop push From 84c88fdf3d36e571819815af2c5c8bd7f8e53664 Mon Sep 17 00:00:00 2001 From: Robbie Davis Date: Mon, 2 Aug 2021 08:46:01 -0400 Subject: [PATCH 08/12] Workflow fixes --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index a3538cec4..c8b7f1edc 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -149,7 +149,7 @@ jobs: - uses: actions/checkout@v2 with: - ref: version-bump + ref: version-bump-${{steps.get-version.outputs.assembly-version}} fetch-depth: 0 - name: Create local changes for reference From 74dc6fd5dc300317ae99318f80d7e8ffd18fce5f Mon Sep 17 00:00:00 2001 From: Robbie Davis Date: Mon, 2 Aug 2021 08:55:26 -0400 Subject: [PATCH 09/12] Updating workflow, removing branch creation --- .github/workflows/sonar-scan.yml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index c8b7f1edc..fddfa4cc5 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -152,19 +152,6 @@ jobs: ref: version-bump-${{steps.get-version.outputs.assembly-version}} fetch-depth: 0 - - name: Create local changes for reference - run: | - git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git pull origin version-bump-${{steps.get-version.outputs.assembly-version}} - git commit --allow-empty -m "Trigger Build" - - - name: Push changes - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: version-bump-${{steps.get-version.outputs.assembly-version}} - - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: @@ -182,14 +169,6 @@ jobs: version_files: Kavita.Common/Kavita.Common.csproj github_token: ${{ secrets.GITHUB_TOKEN }} - - name: Merge bump branch -> pr branch - uses: devmasx/merge-branch@v1.3.1 - with: - type: now - from_branch: version-bump-${{ github.event.inputs.version }} - target_branch: develop - github_token: ${{ secrets.GITHUB_TOKEN }} - - name: Trigger Docker Nightly if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} uses: benc-uk/workflow-dispatch@v1 From 912469de12545814807528b83d7221cade79074a Mon Sep 17 00:00:00 2001 From: Robbie Davis Date: Mon, 2 Aug 2021 09:54:57 -0400 Subject: [PATCH 10/12] Feature/version bump (#456) ** Changes - Workflow changes --- .github/workflows/sonar-scan.yml | 72 ++++++------------------------ Kavita.Common/Kavita.Common.csproj | 2 +- 2 files changed, 15 insertions(+), 59 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index fddfa4cc5..fef98472e 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -2,7 +2,7 @@ name: .NET Build Test and Sonar Scan on: push: - branches: [ main, develop ] + branches: '**' pull_request: branches: [ main, develop ] types: [opened, synchronize, reopened] @@ -93,63 +93,14 @@ jobs: - name: Test run: dotnet test --no-restore --verbosity normal - bump: - name: Create branch for bump if Develop push - runs-on: ubuntu-latest - needs: [ build, test ] - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} - steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 - - - name: Get csproj Version - uses: naminodarie/get-net-sdk-project-versions-action@v1 - id: get-version - with: - proj-path: Kavita.Common/Kavita.Common.csproj - - - name: Get branch name - id: branch-name - uses: tj-actions/branch-names@v4.5 - - - name: Echo branch name - run: echo "${{ steps.branch-name.outputs.current_branch }}" - - - name: Echo csproj version - run: echo "${{steps.get-version.outputs.assembly-version}}" - - - name: Create Branch - uses: peterjgrainger/action-create-branch@v2.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - branch: "version-bump-${{steps.get-version.outputs.assembly-version}}" - version: - name: Bump version if Develop push - needs: [ bump ] + name: Bump version on Develop push + needs: [ build, test ] runs-on: ubuntu-latest if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} steps: - - - name: Download a single artifact - uses: actions/download-artifact@v2 - with: - name: csproj - - - name: Get csproj Version - uses: naminodarie/get-net-sdk-project-versions-action@v1 - id: get-version - with: - proj-path: Kavita.Common.csproj - - - name: Get branch name - id: branch-name - uses: tj-actions/branch-names@v4.5 - - uses: actions/checkout@v2 with: - ref: version-bump-${{steps.get-version.outputs.assembly-version}} fetch-depth: 0 - name: Setup .NET Core @@ -167,10 +118,16 @@ jobs: uses: SiqiLu/dotnet-bump-version@master with: version_files: Kavita.Common/Kavita.Common.csproj - github_token: ${{ secrets.GITHUB_TOKEN }} + github_token: ${{ secrets.REPO_GHA_PAT }} - - name: Trigger Docker Nightly - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} + develop: + name: Trigger Nightly Docker if Develop push + needs: [ build, test, version ] + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} + steps: + + - name: If Push to Develop, Trigger Docker Stable uses: benc-uk/workflow-dispatch@v1 with: workflow: Build Nightly Docker @@ -180,12 +137,11 @@ jobs: name: Trigger Stable Docker if Main push needs: [ build, test ] runs-on: ubuntu-latest - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} steps: - name: If Push to Main, Trigger Docker Stable - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} uses: benc-uk/workflow-dispatch@v1 with: workflow: Build Stable Docker - token: ${{ secrets.REPO_GHA_PAT }} \ No newline at end of file + token: ${{ secrets.REPO_GHA_PAT }} diff --git a/Kavita.Common/Kavita.Common.csproj b/Kavita.Common/Kavita.Common.csproj index fbba64189..530819ef9 100644 --- a/Kavita.Common/Kavita.Common.csproj +++ b/Kavita.Common/Kavita.Common.csproj @@ -19,4 +19,4 @@ - + \ No newline at end of file From dcafdd1ef1bdd33ecb637b09161cfda524e36086 Mon Sep 17 00:00:00 2001 From: Robbie Davis Date: Mon, 2 Aug 2021 11:28:24 -0400 Subject: [PATCH 11/12] Feature/version bump (#457) ## Changes - Unprotected dev branch - Added automated version bump on pushes to develop (merge PRs) From 12390639ecdb5ec7582d6d694be348c730376d1c Mon Sep 17 00:00:00 2001 From: therobbiedavis Date: Mon, 2 Aug 2021 15:35:50 +0000 Subject: [PATCH 12/12] Bump versions by dotnet-bump-version. --- Kavita.Common/Kavita.Common.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kavita.Common/Kavita.Common.csproj b/Kavita.Common/Kavita.Common.csproj index 530819ef9..d8d7e51af 100644 --- a/Kavita.Common/Kavita.Common.csproj +++ b/Kavita.Common/Kavita.Common.csproj @@ -4,7 +4,7 @@ net5.0 kavitareader.com Kavita - 0.4.3.8 + 0.4.3.9 en