| 163 | } |
| 164 | |
| 165 | func runCompileUpdateCheck(ctx context.Context, client *http.Client) (*compileUpdateNotification, error) { |
| 166 | currentVersion := GetVersion() |
| 167 | if !workflow.IsReleasedVersion(currentVersion) { |
| 168 | compileUpdateCheckLog.Print("Not a released version, skipping update check") |
| 169 | return nil, nil |
| 170 | } |
| 171 | |
| 172 | latestVersion, err := fetchLatestReleaseTag(ctx, client) |
| 173 | if err != nil { |
| 174 | return nil, err |
| 175 | } |
| 176 | if latestVersion == "" { |
| 177 | return nil, nil |
| 178 | } |
| 179 | |
| 180 | latestTagExists, err := downloadReleaseProbeFile(ctx, client, latestVersion) |
| 181 | if err != nil { |
| 182 | return nil, err |
| 183 | } |
| 184 | if !latestTagExists { |
| 185 | compileUpdateCheckLog.Printf("Latest release tag %s did not expose the probe file; skipping", latestVersion) |
| 186 | return nil, nil |
| 187 | } |
| 188 | |
| 189 | currentTagExists, err := downloadReleaseProbeFile(ctx, client, currentVersion) |
| 190 | if err != nil { |
| 191 | return nil, err |
| 192 | } |
| 193 | if !currentTagExists { |
| 194 | return &compileUpdateNotification{ |
| 195 | Kind: compileUpdateNotificationRemovedTag, |
| 196 | CurrentVersion: currentVersion, |
| 197 | LatestVersion: latestVersion, |
| 198 | }, nil |
| 199 | } |
| 200 | |
| 201 | if !isMinorVersionBehind(currentVersion, latestVersion) { |
| 202 | return nil, nil |
| 203 | } |
| 204 | |
| 205 | return &compileUpdateNotification{ |
| 206 | Kind: compileUpdateNotificationMinorBehind, |
| 207 | CurrentVersion: currentVersion, |
| 208 | LatestVersion: latestVersion, |
| 209 | }, nil |
| 210 | } |
| 211 | |
| 212 | func fetchLatestReleaseTag(ctx context.Context, client *http.Client) (string, error) { |
| 213 | req, err := http.NewRequestWithContext(ctx, http.MethodHead, compileUpdateCheckLatestReleaseURL, nil) |