feat(release): initial attempt at providing automatic builds

This commit is contained in:
2021-05-06 02:20:32 +01:00
parent 2054c8c0aa
commit 63289216d7
10 changed files with 811 additions and 6 deletions

View File

@@ -0,0 +1,47 @@
package main
import (
"fmt"
"regexp"
"github.com/urfave/cli/v2"
)
var nonAlphaNum = regexp.MustCompile(`[^\w-_]+`)
var checkCmd = &cli.Command{
Name: "check",
Usage: "Check if GitHub release and asset exists",
UsageText: "github-release [global options] check [options]",
Action: actionHandler(checkAction),
}
func checkAction(c *cli.Context, opts *globalOptions) error {
gh := opts.gh
repo := opts.repo
plan := opts.plan
releaseName := plan.ReleaseName()
fmt.Printf(
"Checking github.com/%s for release: %s\n",
repo.String(), releaseName,
)
release, _, err := gh.Repositories.GetReleaseByTag(
c.Context, repo.Owner, repo.Name, releaseName,
)
if err != nil {
return err
}
filename := plan.ReleaseAsset()
fmt.Printf("checking release for asset: %s\n", filename)
for _, a := range release.Assets {
if a.Name != nil && filename == *a.Name {
return nil
}
}
return fmt.Errorf("release does contain asset: %s", filename)
}