Skip to content

Commit 4862a50

Browse files
committed
fix: harden release channels for main promotion
1 parent e28720a commit 4862a50

3 files changed

Lines changed: 23 additions & 10 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ jobs:
120120
artifact-configuration-slug: zipped-app
121121
github-artifact-id: ${{ steps.windows-artifact.outputs.artifact-id }}
122122
wait-for-completion: true
123+
wait-for-completion-timeout-in-seconds: 3600
123124
output-artifact-directory: bin
124125

125126
- name: Make stable installer and portable archive
@@ -150,6 +151,7 @@ jobs:
150151
artifact-configuration-slug: zipped-installer
151152
github-artifact-id: ${{ steps.installer-artifact.outputs.artifact-id }}
152153
wait-for-completion: true
154+
wait-for-completion-timeout-in-seconds: 3600
153155
output-artifact-directory: bin-signed
154156

155157
- name: Upload stable release files

loader/Main/Config.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,18 @@ public static bool SuperLowSpecMode
8888

8989
public static string UpdateChannel
9090
{
91-
get => string.Equals(Get("UpdateChannel"), "dev", StringComparison.OrdinalIgnoreCase)
92-
? "dev"
93-
: "stable";
91+
get => ResolveUpdateChannel(Get("UpdateChannel"), Updater.BuildChannel);
9492
set => Set("UpdateChannel", string.Equals(value, "dev", StringComparison.OrdinalIgnoreCase)
9593
? "dev"
9694
: "stable");
9795
}
9896

97+
internal static string ResolveUpdateChannel(string configured, string buildChannel)
98+
{
99+
var channel = string.IsNullOrEmpty(configured) ? buildChannel : configured;
100+
return string.Equals(channel, "dev", StringComparison.OrdinalIgnoreCase) ? "dev" : "stable";
101+
}
102+
99103
static string GetPath(string subpath)
100104
{
101105
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, subpath);

loader/Main/Updater.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ static class Updater
2222
const string USER_AGENT = "PenguLoader-Updater/1.0";
2323

2424
static bool _checking;
25+
internal static string BuildChannel => ReadBuildInfo().Channel;
2526

2627
class Update
2728
{
@@ -167,7 +168,9 @@ static async Task<Update> FetchUpdate()
167168
if (channel == "dev")
168169
{
169170
var releases = serializer.Deserialize<GitHubRelease[]>(await DownloadString(ReleasesApiUrl));
170-
release = releases.FirstOrDefault(item => item.prerelease && !item.draft);
171+
release = releases.FirstOrDefault(item => item.prerelease && !item.draft
172+
&& item.assets != null
173+
&& item.assets.Any(candidate => candidate.name.EndsWith("-dev-windows.zip", StringComparison.OrdinalIgnoreCase)));
171174
}
172175
else
173176
{
@@ -228,6 +231,11 @@ static BuildInfo ReadBuildInfo()
228231
if (File.Exists(path))
229232
value = File.ReadAllText(path).Trim();
230233

234+
return ParseBuildInfo(value);
235+
}
236+
237+
static BuildInfo ParseBuildInfo(string value)
238+
{
231239
var parts = value.Split('+');
232240
Version version;
233241

@@ -277,14 +285,13 @@ internal static bool SelfTest()
277285
Commit = "abcdef12",
278286
Channel = "stable"
279287
};
280-
var dev = new BuildInfo
281-
{
282-
Version = new Version(1, 3, 0),
283-
Commit = "12345678",
284-
Channel = "dev"
285-
};
288+
var dev = ParseBuildInfo("1.3.0+12345678+dev");
286289

287290
return ParseVersion("v1.2.3-dev.42") == new Version(1, 2, 3)
291+
&& dev.Version == new Version(1, 3, 0)
292+
&& dev.Channel == "dev"
293+
&& Config.ResolveUpdateChannel("", dev.Channel) == "dev"
294+
&& Config.ResolveUpdateChannel("stable", dev.Channel) == "stable"
288295
&& !ShouldUpdate(stable, new Version(1, 2, 3), "abcdef1234567890", "stable")
289296
&& ShouldUpdate(stable, new Version(1, 2, 3), "1234567890abcdef", "stable")
290297
&& ShouldUpdate(stable, new Version(1, 1, 0), "1234567890abcdef", "dev")

0 commit comments

Comments
 (0)