mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 13:06:38 +00:00
48 lines
976 B
Go
48 lines
976 B
Go
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)
|
|
}
|