Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
github-down should only download latest release
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay committed Aug 20, 2022
1 parent 967c76b commit 1477f21
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/Squirrel.CommandLine/SquirrelHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ public static int Main(string[] args)
packageCommands,
"",
"[ Package Deployment / Syncing ]",
{ "s3-down", "Download releases from S3 compatible API", new SyncS3Options(), o => Download(new S3Repository(o)) },
{ "s3-up", "Upload releases to S3 compatible API", new SyncS3Options(), o => Upload(new S3Repository(o)) },
{ "http-down", "Download releases from an HTTP source", new SyncHttpOptions(), o => Download(new SimpleWebRepository(o)) },
{ "github-down", "Download releases from GitHub", new SyncGithubOptions(), o => Download(new GitHubRepository(o)) },
{ "http-down", "Download latest release from HTTP", new SyncHttpOptions(), o => Download(new SimpleWebRepository(o)) },
{ "s3-down", "Download latest release from S3 API", new SyncS3Options(), o => Download(new S3Repository(o)) },
{ "s3-up", "Upload releases to S3 API", new SyncS3Options(), o => Upload(new S3Repository(o)) },
{ "github-down", "Download latest release from GitHub", new SyncGithubOptions(), o => Download(new GitHubRepository(o)) },
};

if (verbose) {
Expand Down
25 changes: 18 additions & 7 deletions src/Squirrel.CommandLine/Sync/GitHubRepository.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Squirrel.SimpleSplat;
using Squirrel.Sources;
Expand Down Expand Up @@ -33,16 +34,26 @@ public async Task DownloadRecentPackages()
return;
}

Log.Info($"Found {latestReleaseEntries.Length} assets in latest release ({source.Release.Name}).");
Log.Info($"Found {latestReleaseEntries.Length} assets in RELEASES file for GitHub version {source.Release.Name}.");

foreach (var entry in latestReleaseEntries) {
var localFile = Path.Combine(releaseDirectoryInfo.FullName, entry.Filename);
if (File.Exists(localFile)) {
Log.Info($"File '{entry.Filename}' exists on disk, skipping download.");
var releasesToDownload = latestReleaseEntries
.Where(x => !x.IsDelta)
.OrderByDescending(x => x.Version)
.Take(1)
.Select(x => new {
Obj = x,
LocalPath = Path.Combine(releaseDirectoryInfo.FullName, x.Filename),
Filename = x.Filename,
});

foreach (var entry in releasesToDownload) {
if (File.Exists(entry.LocalPath)) {
Log.Warn($"File '{entry.Filename}' exists on disk, skipping download.");
continue;
}

Log.Info($"Downloading {entry.Filename}...");
await source.DownloadReleaseEntry(entry, localFile, (p) => { });
await source.DownloadReleaseEntry(entry.Obj, entry.LocalPath, (p) => { });
}

ReleaseEntry.BuildReleasesFile(releaseDirectoryInfo.FullName);
Expand Down

0 comments on commit 1477f21

Please sign in to comment.