mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 11:56:40 +00:00
feat(release): initial attempt at providing automatic builds
This commit is contained in:
47
cmd/github-release/check_cmd.go
Normal file
47
cmd/github-release/check_cmd.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user