package publish import ( "log/slog" "path" "regexp" ) func (p *Provider) GetShaSums() (ShaSums, error) { return GetShaSumContents(p.DistPath, p.RepoName, p.Version) } type ShaSums []ShaSum type ShaSum struct { Sum string Path string } func GetShaSumContents(distPath, repoName, version string) (ShaSums, error) { shaSumFileName := repoName + "_" + version + "_SHA256SUMS" shaSumPath := path.Join(distPath, shaSumFileName) shaSumLine, err := ReadFile(shaSumPath) if err != nil { return nil, err } regEx := regexp.MustCompile(`([0-9a-fA-F]+)\s+(.+)`) shaSums := ShaSums{} for _, line := range shaSumLine { matches := regEx.FindAllStringSubmatch(line, -1) if len(matches) < 1 { slog.Warn("unable to parse SHA sum line", "line", line) continue } shaSums = append(shaSums, ShaSum{Sum: matches[0][1], Path: matches[0][2]}) } return shaSums, nil }