rlsbl 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # rlsbl
2
2
 
3
- Release orchestration and project scaffolding CLI for npm and PyPI.
3
+ Release orchestration and project scaffolding CLI for npm, PyPI, and Go.
4
4
 
5
5
  ## Install
6
6
 
@@ -25,7 +25,7 @@ rlsbl release minor
25
25
 
26
26
  ## Commands
27
27
 
28
- All commands work at the top level -- registries are auto-detected from project files (`package.json`, `pyproject.toml`). Use `--registry <npm|pypi>` when you need to target a specific registry.
28
+ All commands work at the top level -- registries are auto-detected from project files (`package.json`, `pyproject.toml`, `go.mod`). Use `--registry <npm|pypi|go>` when you need to target a specific registry.
29
29
 
30
30
  ### scaffold [--force] [--update]
31
31
 
@@ -35,6 +35,7 @@ Scaffolds CI/CD infrastructure and release tooling for all detected registries.
35
35
  rlsbl scaffold
36
36
  rlsbl scaffold --registry npm # target npm only
37
37
  rlsbl scaffold --registry pypi --force # overwrite existing files
38
+ rlsbl scaffold --registry go # target Go only
38
39
  ```
39
40
 
40
41
  Context-aware behavior when files already exist (without `--force`):
@@ -55,7 +56,7 @@ rlsbl release minor
55
56
  rlsbl release major --dry-run --registry npm
56
57
  ```
57
58
 
58
- The version is synced across all detected project files (`package.json`, `pyproject.toml`) regardless of which registry is primary.
59
+ The version is synced across all detected project files (`package.json`, `pyproject.toml`, `VERSION`) regardless of which registry is primary. Go projects use a plain `VERSION` file as the version source.
59
60
 
60
61
  If `scripts/pre-release.sh` exists, it runs before any changes are made. A non-zero exit aborts the release.
61
62
 
@@ -122,7 +123,7 @@ The scaffolded `scripts/pre-push-hook.sh` is installed as a git pre-push hook du
122
123
 
123
124
  How it works:
124
125
 
125
- 1. Detects project type (`package.json` or `pyproject.toml`)
126
+ 1. Detects project type (`package.json`, `pyproject.toml`, or `VERSION`)
126
127
  2. Extracts the current version
127
128
  3. Checks that `CHANGELOG.md` contains a heading `## <version>`
128
129
  4. Blocks the push with an error if the entry is missing
@@ -141,8 +142,9 @@ The first version must be published manually before CI can take over:
141
142
  |---|---|---|
142
143
  | npm | Add an `NPM_TOKEN` secret to your GitHub repo (Settings > Secrets > Actions), then push a release | CI handles subsequent publishes |
143
144
  | PyPI | Run `uv publish` | Set up [Trusted Publishing](https://docs.pypi.org/trusted-publishers/) on pypi.org |
145
+ | Go | Push to GitHub and create a release -- Go modules are published by the tag itself | No secrets needed; `pkg.go.dev` indexes automatically |
144
146
 
145
- After configuration, all subsequent releases are handled by CI when `rlsbl release` creates a GitHub Release.
147
+ After configuration, all subsequent releases are handled by CI when `rlsbl release` creates a GitHub Release. Go projects use GoReleaser in CI (via GitHub Actions) to build cross-platform binaries.
146
148
 
147
149
  ## Requirements
148
150
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rlsbl",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Release orchestration and project scaffolding for npm and PyPI",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -61,7 +61,7 @@ NEXT_STEPS = {
61
61
  "Run rlsbl release [patch|minor|major]",
62
62
  ],
63
63
  "go": [
64
- "Install GoReleaser (https://goreleaser.com/install/)",
64
+ "GoReleaser runs in CI via GitHub Actions (no local install needed)",
65
65
  "Push to GitHub to activate the CI workflow",
66
66
  "Run rlsbl release [patch|minor|major]",
67
67
  ],
@@ -55,19 +55,30 @@ def run_cmd(registry, args, flags):
55
55
  current_version = reg.read_version(".")
56
56
  log(f"Current version: {current_version}")
57
57
 
58
- # Bump type
59
- bump_type = args[0] if args else "patch"
60
- if bump_type not in VALID_BUMP_TYPES:
61
- print(
62
- f'Error: invalid bump type "{bump_type}". Use: {", ".join(VALID_BUMP_TYPES)}',
63
- file=sys.stderr,
64
- )
65
- sys.exit(1)
58
+ # If the current version has never been tagged, release it as-is (bootstrap)
59
+ current_tag = f"v{current_version}"
60
+ current_tag_exists = len(run("git", ["tag", "-l", current_tag])) > 0
61
+
62
+ if not current_tag_exists:
63
+ new_version = current_version
64
+ bump_type = None
65
+ tag = current_tag
66
+ if args:
67
+ log(f"First release: releasing {new_version} as-is (bump type ignored)")
68
+ else:
69
+ log(f"First release: {new_version}")
70
+ else:
71
+ bump_type = args[0] if args else "patch"
72
+ if bump_type not in VALID_BUMP_TYPES:
73
+ print(
74
+ f'Error: invalid bump type "{bump_type}". Use: {", ".join(VALID_BUMP_TYPES)}',
75
+ file=sys.stderr,
76
+ )
77
+ sys.exit(1)
66
78
 
67
- # Compute new version
68
- new_version = bump_version(current_version, bump_type)
69
- tag = f"v{new_version}"
70
- log(f"New version: {new_version} ({bump_type})")
79
+ new_version = bump_version(current_version, bump_type)
80
+ tag = f"v{new_version}"
81
+ log(f"New version: {new_version} ({bump_type})")
71
82
 
72
83
  # Check tag doesn't already exist
73
84
  tag_output = run("git", ["tag", "-l", tag])
@@ -111,7 +122,10 @@ def run_cmd(registry, args, flags):
111
122
  if flags.get("dry-run", False):
112
123
  log("\n--- Dry run summary ---")
113
124
  log(f"Registry: {registry}")
114
- log(f"Bump: {current_version} -> {new_version} ({bump_type})")
125
+ if bump_type:
126
+ log(f"Bump: {current_version} -> {new_version} ({bump_type})")
127
+ else:
128
+ log(f"Version: {new_version} (first release)")
115
129
  log(f"Tag: {tag}")
116
130
  log(f"Branch: {branch}")
117
131
  # Show other version files that would be synced
@@ -144,7 +158,8 @@ def run_cmd(registry, args, flags):
144
158
 
145
159
  # Confirmation prompt (skip with --yes)
146
160
  if not flags.get("yes"):
147
- print(f"\nAbout to release {new_version} ({bump_type}) on {branch}")
161
+ bump_label = f" ({bump_type})" if bump_type else ""
162
+ print(f"\nAbout to release {new_version}{bump_label} on {branch}")
148
163
  print(f" Tag: {tag}")
149
164
  if files_to_commit:
150
165
  print(f" Files: {', '.join(files_to_commit)}")
@@ -159,23 +174,24 @@ def run_cmd(registry, args, flags):
159
174
  print("Aborted.")
160
175
  sys.exit(0)
161
176
 
162
- # Write new version to the primary registry file
163
- if version_file:
164
- reg.write_version(".", new_version)
165
- log(f"Updated version in {version_file}")
177
+ # Write new version to version files (skip if version didn't change, e.g. first release)
178
+ if new_version != current_version:
179
+ if version_file:
180
+ reg.write_version(".", new_version)
181
+ log(f"Updated version in {version_file}")
166
182
 
167
- # Sync version to all other recognized version files
168
- for name, other_reg in REGISTRIES.items():
169
- if name == registry:
170
- continue
171
- if other_reg.check_project_exists("."):
172
- other_file = other_reg.get_version_file()
173
- if other_file:
174
- other_reg.write_version(".", new_version)
175
- log(f"Synced version to {other_file}")
183
+ # Sync version to all other recognized version files
184
+ for name, other_reg in REGISTRIES.items():
185
+ if name == registry:
186
+ continue
187
+ if other_reg.check_project_exists("."):
188
+ other_file = other_reg.get_version_file()
189
+ if other_file:
190
+ other_reg.write_version(".", new_version)
191
+ log(f"Synced version to {other_file}")
176
192
 
177
- # Commit all bumped version files together
178
- if files_to_commit:
193
+ # Commit version file changes (skip if version didn't change, e.g. first release)
194
+ if files_to_commit and new_version != current_version:
179
195
  commit_tool = find_commit_tool()
180
196
  if commit_tool == "safegit":
181
197
  run(commit_tool, ["commit", "-m", tag, "--", *files_to_commit])
@@ -184,7 +200,7 @@ def run_cmd(registry, args, flags):
184
200
  run("git", ["commit", "-m", tag])
185
201
  log(f"Committed: {tag}")
186
202
  else:
187
- log("No version files to commit (version is the git tag)")
203
+ log("No version bump to commit")
188
204
 
189
205
  # Create local git tag
190
206
  run("git", ["tag", tag])
@@ -1,8 +1,7 @@
1
1
  """Go registry adapter for rlsbl.
2
2
 
3
- Go modules are versioned by git tags, not version files. GoReleaser handles
4
- the build/publish step. rlsbl's role: changelog validation, tagging, GitHub
5
- Release creation.
3
+ Go projects use a VERSION file as the source of truth for rlsbl. GoReleaser
4
+ handles the build/publish step triggered by the GitHub Release that rlsbl creates.
6
5
  """
7
6
 
8
7
  import os
@@ -12,28 +11,30 @@ from ..utils import run
12
11
 
13
12
  NAME = "go"
14
13
 
14
+ VERSION_FILE = "VERSION"
15
15
 
16
- def read_version(dir_path):
17
- """Read version from the latest git tag.
18
16
 
19
- Go modules have no version file -- the version IS the git tag.
20
- Returns "0.0.0" if no tags exist yet.
21
- """
22
- try:
23
- tag = run("git", ["describe", "--tags", "--abbrev=0"])
24
- return tag.lstrip("v")
25
- except Exception:
26
- return "0.0.0"
17
+ def read_version(dir_path):
18
+ """Read version from the VERSION file."""
19
+ version_path = os.path.join(dir_path, VERSION_FILE)
20
+ if not os.path.exists(version_path):
21
+ raise FileNotFoundError(f"No {VERSION_FILE} file found. Run 'rlsbl scaffold' first.")
22
+ with open(version_path, "r", encoding="utf-8") as f:
23
+ return f.read().strip()
27
24
 
28
25
 
29
26
  def write_version(dir_path, version):
30
- """No-op: Go versions are git tags, not file fields."""
31
- pass
27
+ """Write the new version to the VERSION file."""
28
+ version_path = os.path.join(dir_path, VERSION_FILE)
29
+ tmp_path = version_path + ".tmp"
30
+ with open(tmp_path, "w", encoding="utf-8") as f:
31
+ f.write(version + "\n")
32
+ os.replace(tmp_path, version_path)
32
33
 
33
34
 
34
35
  def get_version_file():
35
- """Go has no version file -- version is the git tag."""
36
- return None
36
+ """Returns the filename that holds the version for this registry."""
37
+ return VERSION_FILE
37
38
 
38
39
 
39
40
  def get_template_dir():
@@ -73,7 +74,10 @@ def get_template_vars(dir_path):
73
74
  except Exception:
74
75
  pass
75
76
 
76
- version = read_version(dir_path)
77
+ try:
78
+ version = read_version(dir_path)
79
+ except FileNotFoundError:
80
+ version = "0.0.0"
77
81
 
78
82
  return {
79
83
  "name": short_name,
@@ -88,6 +92,7 @@ def get_template_vars(dir_path):
88
92
  def get_template_mappings():
89
93
  """Returns go-specific template mappings (template file -> target path)."""
90
94
  return [
95
+ {"template": "VERSION.tpl", "target": "VERSION"},
91
96
  {"template": "ci.yml.tpl", "target": ".github/workflows/ci.yml"},
92
97
  {"template": "publish.yml.tpl", "target": ".github/workflows/publish.yml"},
93
98
  {"template": "goreleaser.yml.tpl", "target": ".goreleaser.yml"},
package/rlsbl/utils.py CHANGED
@@ -93,11 +93,10 @@ def check_gh_auth():
93
93
  def find_commit_tool():
94
94
  """Detect safegit or fall back to git for committing.
95
95
 
96
- Returns the path/name of the commit tool.
96
+ Returns "safegit" if available on PATH, otherwise "git".
97
97
  """
98
- safegit_path = shutil.which("safegit")
99
- if safegit_path:
100
- return safegit_path
98
+ if shutil.which("safegit"):
99
+ return "safegit"
101
100
  return "git"
102
101
 
103
102
 
@@ -0,0 +1 @@
1
+ {{version}}
@@ -9,6 +9,8 @@ if [ -f package.json ]; then
9
9
  VERSION=$(node -e "console.log(require('./package.json').version)" 2>/dev/null) || exit 0
10
10
  elif [ -f pyproject.toml ]; then
11
11
  VERSION=$(grep -m1 '^version' pyproject.toml | sed 's/.*"\(.*\)".*/\1/') || exit 0
12
+ elif [ -f VERSION ]; then
13
+ VERSION=$(tr -d '[:space:]' < VERSION) || exit 0
12
14
  else
13
15
  exit 0
14
16
  fi
@@ -1,13 +1,27 @@
1
1
  #!/usr/bin/env bash
2
2
  # Pre-release validation hook.
3
3
  # Runs before rlsbl creates a release. Exit non-zero to abort.
4
- # Add your project-specific checks here (e.g., tests, linting, audit).
4
+ # Detects project type and runs appropriate checks automatically.
5
5
 
6
6
  set -euo pipefail
7
7
 
8
8
  echo "Running pre-release checks..."
9
9
 
10
- # Example: run tests if available
11
- # npm test 2>/dev/null || true
10
+ if [ -f go.mod ]; then
11
+ echo "Detected Go project"
12
+ go vet ./...
13
+ go build ./...
14
+ go test ./... -race -short -count=1
15
+ elif [ -f package.json ]; then
16
+ echo "Detected npm project"
17
+ npm test
18
+ elif [ -f pyproject.toml ]; then
19
+ echo "Detected Python project"
20
+ if command -v uv &>/dev/null; then
21
+ uv run pytest
22
+ elif command -v pytest &>/dev/null; then
23
+ pytest
24
+ fi
25
+ fi
12
26
 
13
27
  echo "Pre-release checks passed."