Release/1.0 #1

Merged
k3nny merged 19 commits from release/1.0 into main 2026-07-11 22:11:21 +02:00
2 changed files with 27 additions and 0 deletions
Showing only changes of commit 0dc6d0747d - Show all commits
+8
View File
@@ -33,6 +33,7 @@ func newRootCmd() *cobra.Command {
var ( var (
dryRun bool dryRun bool
noPush bool noPush bool
noRelease bool
noCommit bool noCommit bool
tagOnly bool tagOnly bool
branchOverride string branchOverride string
@@ -62,6 +63,7 @@ func newRootCmd() *cobra.Command {
patternSet: patternSet, patternSet: patternSet,
dryRun: dryRun, dryRun: dryRun,
noPush: noPush, noPush: noPush,
noRelease: noRelease,
noCommit: noCommit, noCommit: noCommit,
tagOnly: tagOnly, tagOnly: tagOnly,
}) })
@@ -70,6 +72,7 @@ func newRootCmd() *cobra.Command {
root.Flags().BoolVar(&dryRun, "dry-run", false, "print next version without making changes") root.Flags().BoolVar(&dryRun, "dry-run", false, "print next version without making changes")
root.Flags().BoolVar(&noPush, "no-push", false, "create commit and tag locally without pushing or creating a GitLab release") root.Flags().BoolVar(&noPush, "no-push", false, "create commit and tag locally without pushing or creating a GitLab release")
root.Flags().BoolVar(&noRelease, "no-release", false, "push commit and tag but skip creating the GitLab release")
root.Flags().BoolVar(&noCommit, "no-commit", false, "update pom.xml but do not commit, tag, or push") root.Flags().BoolVar(&noCommit, "no-commit", false, "update pom.xml but do not commit, tag, or push")
root.Flags().BoolVar(&tagOnly, "tag-only", false, "tag HEAD without updating pom.xml (assumes version was already committed)") root.Flags().BoolVar(&tagOnly, "tag-only", false, "tag HEAD without updating pom.xml (assumes version was already committed)")
root.Flags().StringVar(&branchOverride, "branch", "", "override branch name detection (required in detached HEAD)") root.Flags().StringVar(&branchOverride, "branch", "", "override branch name detection (required in detached HEAD)")
@@ -101,6 +104,7 @@ type options struct {
patternSet bool patternSet bool
dryRun bool dryRun bool
noPush bool noPush bool
noRelease bool
noCommit bool noCommit bool
tagOnly bool tagOnly bool
} }
@@ -264,6 +268,10 @@ func run(o options) error {
fmt.Fprintln(os.Stderr, "info: pushed") fmt.Fprintln(os.Stderr, "info: pushed")
// --- GitLab release --- // --- GitLab release ---
if o.noRelease {
fmt.Printf("released %s\n", nextTag)
return nil
}
if cfg.GitLab.URL == "" || cfg.GitLab.Project == "" { if cfg.GitLab.URL == "" || cfg.GitLab.Project == "" {
fmt.Fprintln(os.Stderr, "warning: GitLab URL or project not configured — skipping release creation") fmt.Fprintln(os.Stderr, "warning: GitLab URL or project not configured — skipping release creation")
fmt.Printf("released %s\n", nextTag) fmt.Printf("released %s\n", nextTag)
+19
View File
@@ -460,6 +460,25 @@ func TestRunSkipGitLab(t *testing.T) {
} }
} }
func TestRunNoRelease(t *testing.T) {
_, dir := setupRepoWithRemote(t)
addFile(t, dir, "x.go", "// fix")
repo, _ := gogit.PlainOpen(dir)
w, _ := repo.Worktree()
w.Add("x.go")
w.Commit("fix: patch something", &gogit.CommitOptions{Author: testSig()})
// --no-release skips GitLab release even when credentials are configured
t.Setenv("CI_SERVER_URL", "https://gitlab.example.com")
t.Setenv("CI_PROJECT_ID", "42")
t.Setenv("GITLAB_TOKEN", "test-token")
err := execCmd(t, "--no-release", "--branch", "release/1.2", "--repo", dir)
if err != nil {
t.Fatalf("--no-release: unexpected error: %v", err)
}
}
func TestRunMissingToken(t *testing.T) { func TestRunMissingToken(t *testing.T) {
_, dir := setupRepoWithRemote(t) _, dir := setupRepoWithRemote(t)
addFile(t, dir, "x.go", "// fix") addFile(t, dir, "x.go", "// fix")