Skip to content

Commit 1cb17da

Browse files
cliedemanchristophwitzko
authored andcommitted
feat: Add allow-no-changes flag
Returns exit code 0 if no changes are found
1 parent ad23932 commit 1cb17da

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

cmd/semantic-release/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,12 @@ func cliHandler(c *cli.Context) error {
128128
logger.Println("calculating new version...")
129129
newVer := semrel.GetNewVersion(conf, commits, release)
130130
if newVer == nil {
131-
exitIfError(errors.New("no change"), 65)
131+
if conf.AllowNoChanges {
132+
logger.Println("no change")
133+
os.Exit(0)
134+
} else {
135+
exitIfError(errors.New("no change"), 65)
136+
}
132137
}
133138
logger.Println("new version: " + newVer.String())
134139

pkg/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type (
2525
BetaRelease *BetaRelease
2626
Match string
2727
AllowInitialDevelopmentVersions bool
28+
AllowNoChanges bool
2829
GitLab bool
2930
GitLabBaseURL string
3031
GitLabProjectID string
@@ -51,6 +52,7 @@ func NewConfig(c *cli.Context) (*Config, error) {
5152
TravisCom: c.Bool("travis-com"),
5253
Match: c.String("match"),
5354
AllowInitialDevelopmentVersions: c.Bool("allow-initial-development-versions"),
55+
AllowNoChanges: c.Bool("allow-no-changes"),
5456
GitLab: c.Bool("gitlab"),
5557
GitLabBaseURL: c.String("gitlab-base-url"),
5658
GitLabProjectID: c.String("gitlab-project-id"),

pkg/config/flags.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,9 @@ var CliFlags = []cli.Flag{
7878
Name: "allow-initial-development-versions",
7979
Usage: "semantic-release will start your initial development release at 0.1.0",
8080
},
81+
&cli.BoolFlag{
82+
Name: "allow-no-changes",
83+
Value: false,
84+
Usage: "Exit with code 0 if no changes are found, useful if semantic-release is automatically run",
85+
},
8186
}

0 commit comments

Comments
 (0)