You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid branch reachability checks such as `git tag --merged` in the first version because they require commit history and defeat shallow-checkout performance. Tags are global refs, not branch-local refs. If the business rule needs branch-specific versions, encode the release line into the tag prefix or branch name instead of trying to infer it from commit reachability.
141
141
142
+
### Snapshot version strategy
143
+
144
+
Snapshots should be treated as ephemeral CI artifact versions, not permanent version reservations. The script should not scan tags, create tags, or update a central counter just to produce a snapshot. For performance, generate snapshots from the next release base plus GitLab CI's already-available unique identifiers.
145
+
146
+
Recommended snapshot format for SemVer-compatible consumers:
If a target package ecosystem requires Maven-style snapshots, support a template override:
160
+
161
+
```bash
162
+
--snapshot-template '{base_version}-SNAPSHOT'
163
+
```
164
+
165
+
Default behavior:
166
+
167
+
-`snapshot` mode never creates a tag.
168
+
-`snapshot` mode never increments or reserves the patch/RC counter.
169
+
- Snapshot uniqueness comes from `CI_PIPELINE_IID` plus `CI_COMMIT_SHORT_SHA`.
170
+
- Snapshot ordering is good enough for CI artifacts because `CI_PIPELINE_IID` is monotonic inside a GitLab project.
171
+
- Module name should be part of the artifact path or package coordinates, not necessarily part of the SemVer string.
172
+
173
+
Base version rules:
174
+
175
+
| Branch/mode | Base version | Snapshot output example |
176
+
| --- | --- | --- |
177
+
|`main` / `snapshot`| next patch from latest stable |`1.4.8-snapshot.732.a1b2c3d4`|
178
+
| feature branch / `snapshot`| next patch from latest stable |`1.4.8-snapshot.feature-login.732.a1b2c3d4` if branch slug is enabled |
179
+
|`release/1.5` / `snapshot`| target release line |`1.5.0-snapshot.732.a1b2c3d4`|
180
+
| after existing `1.5.0-rc.2`| next RC base without reserving it |`1.5.0-rc.3.snapshot.732.a1b2c3d4`|
181
+
182
+
Important: if strict SemVer precedence matters, avoid publishing snapshots to the same channel as immutable releases/RCs. SemVer prerelease ordering can be surprising for mixed labels like `rc.3.snapshot.732`. The safest operational rule is: snapshots go to a snapshot/dev repository or package channel; releases and RCs go to release channels.
183
+
184
+
If the business requires per-module sequential snapshot numbers, do not derive that from Git tags. Use one of these explicit state stores instead:
185
+
186
+
1. GitLab project/group variable per module, updated only by a serialized release/snapshot job.
187
+
2. GitLab Generic Package Registry state file such as `version-state/<module>/state.json`.
188
+
3. A small external version service.
189
+
190
+
For the first implementation, avoid stateful snapshot counters. Use `CI_PIPELINE_IID` for unique snapshots and keep state only for immutable releases/RCs.
191
+
142
192
### Branch/mode strategy
143
193
144
194
Support both auto-detection and explicit mode:
@@ -165,6 +215,7 @@ Modes:
165
215
|`auto`| Detect from branch pattern |`1.4.8` or `1.5.0-rc.1`|
Use `CI_PIPELINE_IID` and `CI_COMMIT_SHORT_SHA` by default when CLI flags are not provided. If they are missing outside CI, fall back to `0` and the local Git short SHA, or fail with a clear message when Git is unavailable.
@@ -1063,5 +1211,7 @@ These are worth confirming before coding if the script will be used across many
1063
1211
3. Should the script ever create Git tags, or only calculate the next version?
1064
1212
4. Should module names allow slashes, for example `services/api`, or should they be simple slugs only?
1065
1213
5. Should version files be updated, for example `pyproject.toml`, `package.json`, or `__init__.py`, or should CI consume the generated version without editing files?
1214
+
6. Should snapshots use strict SemVer prerelease style, Maven-style `-SNAPSHOT`, or an ecosystem-specific template?
1215
+
7. Should snapshots be unique only per pipeline, or is a per-module sequential snapshot counter required?
1066
1216
1067
1217
Recommended first implementation: calculate only, do not tag, do not edit version files. This keeps the script safe, reusable, and easy to test. Add mutation features only after version calculation is trusted.
0 commit comments