mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 13:06:38 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
80a0d55b24
|
|||
|
fd0ec4d772
|
|||
|
c0c809a86a
|
|||
|
cb63806262
|
12
CHANGELOG.md
12
CHANGELOG.md
@@ -2,6 +2,18 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
### [0.6.9](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.8...v0.6.9) (2021-07-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **release:** add bulk edit command to quickly change multiple GitHub releases ([cb63806](https://github.com/jimeh/build-emacs-for-macos/commit/cb638062625d9bc3eee12515067fb09e05a08414))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **plan:** correctly parse --test-release-type flag ([fd0ec4d](https://github.com/jimeh/build-emacs-for-macos/commit/fd0ec4d772dd3da93afc234fb3024220b2099c88))
|
||||||
|
|
||||||
### [0.6.8](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.7...v0.6.8) (2021-07-02)
|
### [0.6.8](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.7...v0.6.8) (2021-07-02)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ func planAction(c *cli2.Context, opts *Options) error {
|
|||||||
GithubToken: c.String("github-token"),
|
GithubToken: c.String("github-token"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.String("test-build-type") == "draft" {
|
if c.String("test-release-type") == "draft" {
|
||||||
planOpts.TestBuildType = plan.Draft
|
planOpts.TestBuildType = plan.Draft
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -60,6 +61,7 @@ func releaseCmd() *cli2.Command {
|
|||||||
Subcommands: []*cli2.Command{
|
Subcommands: []*cli2.Command{
|
||||||
releaseCheckCmd(),
|
releaseCheckCmd(),
|
||||||
releasePublishCmd(),
|
releasePublishCmd(),
|
||||||
|
releaseBulkCmd(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,3 +208,56 @@ func releasePublishAction(
|
|||||||
|
|
||||||
return release.Publish(c.Context, rlsOpts)
|
return release.Publish(c.Context, rlsOpts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func releaseBulkCmd() *cli2.Command {
|
||||||
|
return &cli2.Command{
|
||||||
|
Name: "bulk",
|
||||||
|
Usage: "bulk modify GitHub releases",
|
||||||
|
ArgsUsage: "",
|
||||||
|
Flags: []cli2.Flag{
|
||||||
|
&cli2.StringFlag{
|
||||||
|
Name: "name",
|
||||||
|
Usage: "regexp pattern matching release names to modify",
|
||||||
|
},
|
||||||
|
&cli2.StringFlag{
|
||||||
|
Name: "prerelease",
|
||||||
|
Usage: "change prerelease flag, must be \"true\" or " +
|
||||||
|
"\"false\", otherwise prerelease value is not changed",
|
||||||
|
},
|
||||||
|
&cli2.BoolFlag{
|
||||||
|
Name: "dry-run",
|
||||||
|
Usage: "do not perform any changes",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Action: releaseActionWrapper(releaseBulkAction),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func releaseBulkAction(
|
||||||
|
c *cli2.Context,
|
||||||
|
opts *Options,
|
||||||
|
rOpts *releaseOptions,
|
||||||
|
) error {
|
||||||
|
bulkOpts := &release.BulkOptions{
|
||||||
|
Repository: rOpts.Repository,
|
||||||
|
NamePattern: c.String("name"),
|
||||||
|
DryRun: c.Bool("dry-run"),
|
||||||
|
GithubToken: rOpts.GithubToken,
|
||||||
|
}
|
||||||
|
|
||||||
|
switch c.String("prerelease") {
|
||||||
|
case "true":
|
||||||
|
v := true
|
||||||
|
bulkOpts.Prerelease = &v
|
||||||
|
case "false":
|
||||||
|
v := false
|
||||||
|
bulkOpts.Prerelease = &v
|
||||||
|
case "":
|
||||||
|
default:
|
||||||
|
return errors.New(
|
||||||
|
"--prerelease by me \"true\" or \"false\" when specified",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return release.Bulk(c.Context, bulkOpts)
|
||||||
|
}
|
||||||
|
|||||||
@@ -120,10 +120,12 @@ func Create(ctx context.Context, opts *Options) (*Plan, error) {
|
|||||||
plan.Build.Name += ".test." + testName
|
plan.Build.Name += ".test." + testName
|
||||||
plan.Release.Title = "Test Builds"
|
plan.Release.Title = "Test Builds"
|
||||||
plan.Release.Name = "test-builds"
|
plan.Release.Name = "test-builds"
|
||||||
|
|
||||||
|
plan.Release.Prerelease = true
|
||||||
|
plan.Release.Draft = false
|
||||||
if opts.TestBuildType == Draft {
|
if opts.TestBuildType == Draft {
|
||||||
|
plan.Release.Prerelease = false
|
||||||
plan.Release.Draft = true
|
plan.Release.Draft = true
|
||||||
} else {
|
|
||||||
plan.Release.Prerelease = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
index := strings.LastIndex(diskImage, ".")
|
index := strings.LastIndex(diskImage, ".")
|
||||||
|
|||||||
84
pkg/release/bulk.go
Normal file
84
pkg/release/bulk.go
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
package release
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
|
"github.com/google/go-github/v35/github"
|
||||||
|
"github.com/hashicorp/go-hclog"
|
||||||
|
"github.com/jimeh/build-emacs-for-macos/pkg/gh"
|
||||||
|
"github.com/jimeh/build-emacs-for-macos/pkg/repository"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BulkOptions struct {
|
||||||
|
Repository *repository.Repository
|
||||||
|
NamePattern string
|
||||||
|
Prerelease *bool
|
||||||
|
DryRun bool
|
||||||
|
GithubToken string
|
||||||
|
}
|
||||||
|
|
||||||
|
func Bulk(ctx context.Context, opts *BulkOptions) error {
|
||||||
|
logger := hclog.FromContext(ctx).Named("release")
|
||||||
|
gh := gh.New(ctx, opts.GithubToken)
|
||||||
|
|
||||||
|
nameMatcher, err := regexp.Compile(opts.NamePattern)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
nextPage := 1
|
||||||
|
lastPage := 1
|
||||||
|
|
||||||
|
for nextPage <= lastPage {
|
||||||
|
releases, resp, err := gh.Repositories.ListReleases(
|
||||||
|
ctx, opts.Repository.Owner(), opts.Repository.Name(),
|
||||||
|
&github.ListOptions{
|
||||||
|
Page: nextPage,
|
||||||
|
PerPage: 100,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
nextPage = resp.NextPage
|
||||||
|
lastPage = resp.LastPage
|
||||||
|
|
||||||
|
for _, r := range releases {
|
||||||
|
if !nameMatcher.MatchString(r.GetName()) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Info("match found", "release", r.GetName())
|
||||||
|
|
||||||
|
var changes []interface{}
|
||||||
|
if opts.Prerelease != nil && r.GetPrerelease() != *opts.Prerelease {
|
||||||
|
changes = append(changes, "prerelease", *opts.Prerelease)
|
||||||
|
r.Prerelease = opts.Prerelease
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(changes) > 0 {
|
||||||
|
changes = append(
|
||||||
|
[]interface{}{"release", r.GetName()}, changes...,
|
||||||
|
)
|
||||||
|
logger.Info("modifying", changes...)
|
||||||
|
if !opts.DryRun {
|
||||||
|
_, _, err = gh.Repositories.EditRelease(
|
||||||
|
ctx, opts.Repository.Owner(), opts.Repository.Name(),
|
||||||
|
r.GetID(), r,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if nextPage == 0 || lastPage == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user