Skip to content

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
GSMLG-BOT committed Apr 18, 2024
1 parent 5663a26 commit ad28467
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 71 deletions.
10 changes: 6 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
"github.com/spf13/viper"
)

const defualtFname = ".config/gsmlg/cli.yaml"

var (
cfgFile string
Version string
Expand Down Expand Up @@ -65,7 +67,7 @@ func init() {
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.

rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.gsmlg/cli.yaml)")
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/"+defualtFname+")")

// Cobra also supports local flags, which will only run
// when this action is called directly.
Expand All @@ -85,7 +87,7 @@ func initConfig() {
// Search config in home directory with name ".cli" (without extension).
viper.AddConfigPath(home)
viper.SetConfigType("yaml")
fName := ".gsmlg/cli.yml"
fName := defualtFname
viper.SetConfigName(fName)
cfgFile = filepath.Join(home, fName)
viper.SetConfigFile(cfgFile)
Expand All @@ -102,7 +104,7 @@ func initConfig() {

// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
// fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
}
}

Expand All @@ -118,7 +120,7 @@ func writeConfig() {
// Search config in home directory with name ".cli" (without extension).
viper.AddConfigPath(home)
viper.SetConfigType("yaml")
fName := ".gsmlg/cli.yml"
fName := defualtFname
viper.SetConfigName(fName)
cfgFile = filepath.Join(home, fName)
viper.SetConfigFile(cfgFile)
Expand Down
34 changes: 5 additions & 29 deletions cmd/semanticRelease.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package cmd
import (
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"os/signal"
Expand Down Expand Up @@ -160,29 +159,6 @@ func semanticReleaseCmdHandler(cmd *cobra.Command, args []string) {

exitIfError(hooksExecutor.Init(hooksConfig))

if !conf.NoCI {
logger.Println("running CI condition...")
conditionConfig := map[string]string{
"token": conf.Token,
"defaultBranch": repoInfo.DefaultBranch,
"private": fmt.Sprintf("%t", repoInfo.Private),
}
mergeConfigWithDefaults(conditionConfig, conf.CIConditionOpts)

err = ci.RunCondition(conditionConfig)
if err != nil {
herr := hooksExecutor.NoRelease(&hooks.NoReleaseConfig{
Reason: hooks.NoReleaseReason_CONDITION,
Message: err.Error(),
})
if herr != nil {
logger.Printf("there was an error executing the hooks plugins: %s", herr.Error())
}
exitIfError(err, 66)
}

}

logger.Println("getting latest release...")
matchRegex := ""
match := strings.TrimSpace(conf.Match)
Expand Down Expand Up @@ -245,18 +221,18 @@ func semanticReleaseCmdHandler(cmd *cobra.Command, args []string) {
if conf.Changelog != "" {
oldFile := make([]byte, 0)
if conf.PrependChangelog {
oldFileData, err := ioutil.ReadFile(conf.Changelog)
oldFileData, err := os.ReadFile(conf.Changelog)
if err == nil {
oldFile = append([]byte("\n"), oldFileData...)
}
}
changelogData := append([]byte(changelogRes), oldFile...)
exitIfError(ioutil.WriteFile(conf.Changelog, changelogData, 0644))
exitIfError(os.WriteFile(conf.Changelog, changelogData, 0644))
}

if conf.Dry {
if conf.VersionFile {
exitIfError(ioutil.WriteFile(".version-unreleased", []byte(newVer), 0644))
exitIfError(os.WriteFile(".version-unreleased", []byte(newVer), 0644))
}
exitIfError(errors.New("DRY RUN: no release was created"), 0)
}
Expand All @@ -272,11 +248,11 @@ func semanticReleaseCmdHandler(cmd *cobra.Command, args []string) {
exitIfError(prov.CreateRelease(newRelease))

if conf.Ghr {
exitIfError(ioutil.WriteFile(".ghr", []byte(fmt.Sprintf("-u %s -r %s v%s", repoInfo.Owner, repoInfo.Repo, newVer)), 0644))
exitIfError(os.WriteFile(".ghr", []byte(fmt.Sprintf("-u %s -r %s v%s", repoInfo.Owner, repoInfo.Repo, newVer)), 0644))
}

if conf.VersionFile {
exitIfError(ioutil.WriteFile(".version", []byte(newVer), 0644))
exitIfError(os.WriteFile(".version", []byte(newVer), 0644))
}

if len(conf.UpdateFiles) == 0 && len(conf.FilesUpdaterPlugins) > 0 {
Expand Down
86 changes: 48 additions & 38 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,61 +1,71 @@
module github.com/gsmlg-dev/gsmlg-cli

go 1.18
go 1.22

toolchain go1.22.1

require (
github.com/Masterminds/semver/v3 v3.1.1
github.com/go-semantic-release/semantic-release/v2 v2.24.0
github.com/gsmlg-dev/gsmlg-golang v1.4.1
github.com/spf13/cobra v1.5.0
github.com/spf13/viper v1.12.0
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467
github.com/Masterminds/semver/v3 v3.2.1
github.com/go-semantic-release/semantic-release/v2 v2.30.0
github.com/gsmlg-dev/gsmlg-golang v1.5.2
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.2
golang.org/x/term v0.19.0
)

require (
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cavaliergopher/grab/v3 v3.0.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-semantic-release/plugin-registry v1.26.1 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-github/v45 v45.2.0 // indirect
github.com/google/go-github/v59 v59.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/hashicorp/go-hclog v1.2.1 // indirect
github.com/hashicorp/go-plugin v1.4.4 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/klauspost/compress v1.15.7 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/schollz/progressbar/v3 v3.8.6 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/schollz/progressbar/v3 v3.14.2 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.38.0 // indirect
go.uber.org/automaxprocs v1.5.1 // indirect
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect
golang.org/x/oauth2 v0.0.0-20220628200809-02e64fa58f26 // indirect
golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220628213854-d9e0b6570c03 // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
github.com/valyala/fasthttp v1.52.0 // indirect
go.uber.org/automaxprocs v1.5.3 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.19.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit ad28467

Please sign in to comment.