versionary 1.10.0 → 1.11.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 +23 -66
- package/dist/release/artifact-rules.d.ts +1 -1
- package/dist/release/artifact-rules.js +13 -9
- package/dist/release/pr.js +2 -2
- package/dist/scm/github-plugin.js +21 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
# Versionary
|
|
1
|
+
# Versionary <picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/jolars/versionary/main/assets/logo/logo-small-dark.png" /><img src="https://raw.githubusercontent.com/jolars/versionary/main/assets/logo/logo-small.png" align="right" width="189" alt="Versionary logo" /></picture>
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
[](https://github.com/jolars/versionary/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/versionary)
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
Versionary is a software-agnostic automated release tool focused on SemVer,
|
|
8
|
+
Conventional Commits, release-PR workflows, and extensibility. Read the
|
|
9
|
+
documentation at <https://versionary.dev/>.
|
|
7
10
|
|
|
8
11
|
## Why this exists
|
|
9
12
|
|
|
@@ -27,9 +30,6 @@ It is built to:
|
|
|
27
30
|
- keep a small, stable core with clear extension points
|
|
28
31
|
- handle trunk-based development and monorepo workflows cleanly
|
|
29
32
|
|
|
30
|
-
> **Status:** early, alpha-stage development. Breaking changes are expected
|
|
31
|
-
> before `1.0.0`.
|
|
32
|
-
|
|
33
33
|
## Quick start
|
|
34
34
|
|
|
35
35
|
Install:
|
|
@@ -55,25 +55,24 @@ npx versionary verify
|
|
|
55
55
|
npx versionary plan
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
Then automate it in CI—see the
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
guides.
|
|
58
|
+
Then automate it in CI—see the [Getting
|
|
59
|
+
started](https://versionary.dev/guide/getting-started) and [GitHub
|
|
60
|
+
Actions](https://versionary.dev/guide/github-actions) guides.
|
|
62
61
|
|
|
63
62
|
## Documentation
|
|
64
63
|
|
|
65
64
|
The full documentation lives at <https://versionary.dev/>:
|
|
66
65
|
|
|
67
66
|
- [Getting started](https://versionary.dev/guide/getting-started)
|
|
68
|
-
- [GitHub Actions setup](https://versionary.dev/guide/github-actions)
|
|
69
|
-
|
|
67
|
+
- [GitHub Actions setup](https://versionary.dev/guide/github-actions) (including
|
|
68
|
+
tokens and permissions)
|
|
70
69
|
- [Release workflows](https://versionary.dev/guide/workflows)
|
|
71
|
-
- [Julia registration with Registrator and
|
|
70
|
+
- [Julia registration with Registrator and
|
|
71
|
+
TagBot](https://versionary.dev/guide/julia)
|
|
72
72
|
- [Monorepos](https://versionary.dev/guide/monorepos)
|
|
73
|
-
- [Conventional Commits](https://versionary.dev/guide/conventional-commits)
|
|
74
|
-
|
|
75
|
-
- Reference:
|
|
76
|
-
[CLI](https://versionary.dev/reference/cli),
|
|
73
|
+
- [Conventional Commits](https://versionary.dev/guide/conventional-commits) and
|
|
74
|
+
[Versioning](https://versionary.dev/guide/versioning)
|
|
75
|
+
- Reference: [CLI](https://versionary.dev/reference/cli),
|
|
77
76
|
[Configuration](https://versionary.dev/reference/configuration),
|
|
78
77
|
[Strategies](https://versionary.dev/reference/strategies)
|
|
79
78
|
|
|
@@ -85,54 +84,7 @@ PR automation, and tags + SCM release metadata (e.g. GitHub Releases).
|
|
|
85
84
|
Out of scope (intentional): publishing artifacts to language registries,
|
|
86
85
|
replacing package-specific publish tooling, and external/user-provided plugin
|
|
87
86
|
loading. Use your CI/CD platform for registry publishing, triggered from release
|
|
88
|
-
outputs or a created release/tag.
|
|
89
|
-
before tagging, including [Julia's Registrator and TagBot workflow](https://versionary.dev/guide/julia).
|
|
90
|
-
|
|
91
|
-
## Contributing
|
|
92
|
-
|
|
93
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md) for the development setup, commands, and
|
|
94
|
-
commit conventions.
|
|
95
|
-
|
|
96
|
-
## Architecture layout (canonical)
|
|
97
|
-
|
|
98
|
-
Runtime code uses a flat `src/` layout with clear module boundaries:
|
|
99
|
-
|
|
100
|
-
- `src/cli/`: command router (`run`, `verify`, `plan`, `changelog`, `pr`, `release`)
|
|
101
|
-
- `src/release/`: release orchestration (plan/changelog/PR/release/state/recovery)
|
|
102
|
-
- `src/strategy/`: strategy contracts, resolver, and built-in implementations
|
|
103
|
-
(`simple`, `node`, `rust`, `r`, `latex`, `python`, `julia`)
|
|
104
|
-
- `src/scm/`: SCM client contracts and provider implementation(s)
|
|
105
|
-
- `src/config/`: config loading and schema validation
|
|
106
|
-
- `src/git/`: git commit/range and repository URL helpers
|
|
107
|
-
- `src/types/`: shared config/plugin-facing types
|
|
108
|
-
|
|
109
|
-
Configuration is loaded from `versionary.jsonc` by default (or
|
|
110
|
-
`versionary.json`). The config schema lives in `src/config/schema.ts`; the
|
|
111
|
-
editor-facing `schemas/config.json` is generated via `pnpm gen:schema`.
|
|
112
|
-
|
|
113
|
-
## Adding a new release strategy
|
|
114
|
-
|
|
115
|
-
New language strategies can be added internally without changing release
|
|
116
|
-
orchestration. A new strategy should implement the `VersionStrategy` contract in
|
|
117
|
-
`src/strategy/types.ts` and be wired in `src/strategy/resolve.ts`.
|
|
118
|
-
|
|
119
|
-
Checklist for new strategies:
|
|
120
|
-
|
|
121
|
-
- define strategy `name`
|
|
122
|
-
- define `getVersionFile(config)` defaults and config override behavior
|
|
123
|
-
- implement `readVersion(cwd, config)` with explicit malformed-file errors
|
|
124
|
-
- implement `writeVersion(cwd, config, version)` returning deterministic updated
|
|
125
|
-
file paths
|
|
126
|
-
- optionally implement `readPackageName(cwd, config)` so monorepo release tags
|
|
127
|
-
can derive from language metadata (similar to Node/Rust/R)
|
|
128
|
-
- optionally implement `propagateDependentPatchImpacts(cwd, packages)` if
|
|
129
|
-
dependency updates in this ecosystem should trigger dependent package patch
|
|
130
|
-
bumps
|
|
131
|
-
- optionally implement `finalizeVersionWrites(cwd, writes, context)` for
|
|
132
|
-
ecosystem post-processing after all target version files are written
|
|
133
|
-
- add focused strategy tests for ecosystem-specific behavior and edge cases
|
|
134
|
-
- add/extend strategy contract tests in `tests/strategy-contract.test.ts`
|
|
135
|
-
- update schema/docs for new `release-type` behavior and defaults
|
|
87
|
+
outputs or a created release/tag.
|
|
136
88
|
|
|
137
89
|
## Install from GitHub
|
|
138
90
|
|
|
@@ -149,6 +101,11 @@ You can install directly from a git ref:
|
|
|
149
101
|
The package runs a `prepare` build during git installation so the `versionary`
|
|
150
102
|
CLI binary is available after install.
|
|
151
103
|
|
|
104
|
+
## Contributing
|
|
105
|
+
|
|
106
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the development setup, commands, and
|
|
107
|
+
commit conventions.
|
|
108
|
+
|
|
152
109
|
## License
|
|
153
110
|
|
|
154
111
|
[MIT](LICENSE)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { VersionaryConfig } from "../types/config.js";
|
|
2
2
|
import type { ReleasePlan } from "./plan.js";
|
|
3
|
-
export declare function applyConfiguredArtifactRules(cwd: string, config: VersionaryConfig, plan: ReleasePlan): string[];
|
|
3
|
+
export declare function applyConfiguredArtifactRules(cwd: string, config: VersionaryConfig, plan: ReleasePlan, releaseDate?: string): string[];
|
|
@@ -162,9 +162,10 @@ function parseRegexPattern(pattern) {
|
|
|
162
162
|
return new RegExp(pattern, "m");
|
|
163
163
|
}
|
|
164
164
|
const REPLACEMENT_TOKEN_PATTERN = /\{\{\s*([A-Za-z]+)\s*\}\}/gu;
|
|
165
|
-
function renderReplacementTemplate(template, version) {
|
|
165
|
+
function renderReplacementTemplate(template, version, releaseDate) {
|
|
166
166
|
const parsed = parseVersion(version);
|
|
167
167
|
const tokens = {
|
|
168
|
+
date: releaseDate,
|
|
168
169
|
version,
|
|
169
170
|
major: String(parsed.major),
|
|
170
171
|
minor: String(parsed.minor),
|
|
@@ -174,6 +175,9 @@ function renderReplacementTemplate(template, version) {
|
|
|
174
175
|
};
|
|
175
176
|
return template.replace(REPLACEMENT_TOKEN_PATTERN, (_whole, name) => {
|
|
176
177
|
const key = name.toLowerCase();
|
|
178
|
+
if (key === "date" && releaseDate === undefined) {
|
|
179
|
+
throw new Error("The {{date}} replacement token requires a release date.");
|
|
180
|
+
}
|
|
177
181
|
const value = tokens[key];
|
|
178
182
|
if (value === undefined) {
|
|
179
183
|
throw new Error(`Unknown replacement token "{{${name}}}". Supported tokens: ${Object.keys(tokens)
|
|
@@ -183,7 +187,7 @@ function renderReplacementTemplate(template, version) {
|
|
|
183
187
|
return value;
|
|
184
188
|
});
|
|
185
189
|
}
|
|
186
|
-
function applyRegexRule(content, pattern, version, expectedMatches, replacementTemplate) {
|
|
190
|
+
function applyRegexRule(content, pattern, version, expectedMatches, replacementTemplate, releaseDate) {
|
|
187
191
|
const regex = parseRegexPattern(pattern);
|
|
188
192
|
const matchFlags = regex.flags.includes("g")
|
|
189
193
|
? regex.flags
|
|
@@ -195,7 +199,7 @@ function applyRegexRule(content, pattern, version, expectedMatches, replacementT
|
|
|
195
199
|
}
|
|
196
200
|
const renderedReplacement = replacementTemplate === undefined
|
|
197
201
|
? undefined
|
|
198
|
-
: renderReplacementTemplate(replacementTemplate, version);
|
|
202
|
+
: renderReplacementTemplate(replacementTemplate, version, releaseDate);
|
|
199
203
|
let updated = content;
|
|
200
204
|
for (let index = matches.length - 1; index >= 0; index -= 1) {
|
|
201
205
|
const match = matches[index];
|
|
@@ -397,12 +401,12 @@ function applyNixRulePreservingFormatting(content, fieldPath, version) {
|
|
|
397
401
|
}
|
|
398
402
|
return `${content.slice(0, target.start)}${target.replacement}${content.slice(target.end)}`;
|
|
399
403
|
}
|
|
400
|
-
function applyArtifactRuleToContent(content, rule, version) {
|
|
404
|
+
function applyArtifactRuleToContent(content, rule, version, releaseDate) {
|
|
401
405
|
if (rule.type === "regex") {
|
|
402
406
|
if (!rule.pattern) {
|
|
403
407
|
throw new Error('regex artifact rules require "pattern".');
|
|
404
408
|
}
|
|
405
|
-
return applyRegexRule(content, rule.pattern, version, rule["expected-matches"] ?? 1, rule.replacement);
|
|
409
|
+
return applyRegexRule(content, rule.pattern, version, rule["expected-matches"] ?? 1, rule.replacement, releaseDate);
|
|
406
410
|
}
|
|
407
411
|
if (rule.type === "json") {
|
|
408
412
|
const parsed = JSON.parse(content);
|
|
@@ -422,7 +426,7 @@ function applyArtifactRuleToContent(content, rule, version) {
|
|
|
422
426
|
function normalizeRelative(base, target) {
|
|
423
427
|
return path.relative(base, target).replaceAll("\\", "/");
|
|
424
428
|
}
|
|
425
|
-
function applyArtifactRulesForPackage(cwd, packagePath, packageConfig, version) {
|
|
429
|
+
function applyArtifactRulesForPackage(cwd, packagePath, packageConfig, version, releaseDate) {
|
|
426
430
|
const rules = packageConfig["extra-files"] ?? [];
|
|
427
431
|
if (rules.length === 0) {
|
|
428
432
|
return [];
|
|
@@ -437,7 +441,7 @@ function applyArtifactRulesForPackage(cwd, packagePath, packageConfig, version)
|
|
|
437
441
|
const existing = fs.readFileSync(targetPath, "utf8");
|
|
438
442
|
let next;
|
|
439
443
|
try {
|
|
440
|
-
next = applyArtifactRuleToContent(existing, rule, version);
|
|
444
|
+
next = applyArtifactRuleToContent(existing, rule, version, releaseDate);
|
|
441
445
|
}
|
|
442
446
|
catch (error) {
|
|
443
447
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -448,7 +452,7 @@ function applyArtifactRulesForPackage(cwd, packagePath, packageConfig, version)
|
|
|
448
452
|
}
|
|
449
453
|
return updated;
|
|
450
454
|
}
|
|
451
|
-
export function applyConfiguredArtifactRules(cwd, config, plan) {
|
|
455
|
+
export function applyConfiguredArtifactRules(cwd, config, plan, releaseDate) {
|
|
452
456
|
const packageConfigs = config.packages ?? {};
|
|
453
457
|
if (!plan.packages || plan.packages.length === 0) {
|
|
454
458
|
return [];
|
|
@@ -462,7 +466,7 @@ export function applyConfiguredArtifactRules(cwd, config, plan) {
|
|
|
462
466
|
if (!packageConfig?.["extra-files"]?.length) {
|
|
463
467
|
continue;
|
|
464
468
|
}
|
|
465
|
-
const files = applyArtifactRulesForPackage(cwd, packagePlan.path, packageConfig, packagePlan.nextVersion);
|
|
469
|
+
const files = applyArtifactRulesForPackage(cwd, packagePlan.path, packageConfig, packagePlan.nextVersion, releaseDate);
|
|
466
470
|
for (const file of files) {
|
|
467
471
|
updated.add(file);
|
|
468
472
|
}
|
package/dist/release/pr.js
CHANGED
|
@@ -417,7 +417,7 @@ export function prepareReleasePr(cwd = process.cwd(), options = {}) {
|
|
|
417
417
|
for (const strategyGroup of writesByStrategy.values()) {
|
|
418
418
|
updatedVersionFiles.push(...(strategyGroup.strategy.finalizeVersionWrites?.(cwd, strategyGroup.writes, finalizeContext) ?? []));
|
|
419
419
|
}
|
|
420
|
-
const updatedArtifactFiles = applyConfiguredArtifactRules(cwd, loaded.config, plan);
|
|
420
|
+
const updatedArtifactFiles = applyConfiguredArtifactRules(cwd, loaded.config, plan, finalizeContext.releaseDate);
|
|
421
421
|
const packageReleaseMetadata = buildPackageReleaseMetadata(cwd, plan, loaded.config);
|
|
422
422
|
const highlightsResult = resolveReleaseHighlights(cwd, plan.changelogFile, plan.changelogFormat);
|
|
423
423
|
const highlights = highlightsResult.highlights;
|
|
@@ -575,7 +575,7 @@ function materializeCandidateChanges(cwd, plan, options) {
|
|
|
575
575
|
for (const strategyGroup of writesByStrategy.values()) {
|
|
576
576
|
updatedVersionFiles.push(...(strategyGroup.strategy.finalizeVersionWrites?.(cwd, strategyGroup.writes, finalizeContext) ?? []));
|
|
577
577
|
}
|
|
578
|
-
const updatedArtifactFiles = applyConfiguredArtifactRules(cwd, loaded.config, plan);
|
|
578
|
+
const updatedArtifactFiles = applyConfiguredArtifactRules(cwd, loaded.config, plan, finalizeContext.releaseDate);
|
|
579
579
|
const packageReleaseMetadata = buildPackageReleaseMetadata(cwd, plan, loaded.config);
|
|
580
580
|
const rootIsReleasing = Boolean(plan.packages?.find((pkg) => pkg.path === ".")?.nextVersion);
|
|
581
581
|
const highlights = rootIsReleasing
|
|
@@ -29,6 +29,25 @@ function parseGitHubError(error) {
|
|
|
29
29
|
const message = error instanceof Error ? error.message : "Unknown GitHub API error";
|
|
30
30
|
return { status, message };
|
|
31
31
|
}
|
|
32
|
+
async function retryGitHubRead(request) {
|
|
33
|
+
for (const delay of [250, 500]) {
|
|
34
|
+
try {
|
|
35
|
+
return await request();
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
const { status } = parseGitHubError(error);
|
|
39
|
+
// Octokit also reports connection failures as 500.
|
|
40
|
+
if (status !== 500 &&
|
|
41
|
+
status !== 502 &&
|
|
42
|
+
status !== 503 &&
|
|
43
|
+
status !== 504) {
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return request();
|
|
50
|
+
}
|
|
32
51
|
function repoRef(repo) {
|
|
33
52
|
return `${repo.owner}/${repo.repo}`;
|
|
34
53
|
}
|
|
@@ -229,14 +248,14 @@ export function createGitHubPlugin() {
|
|
|
229
248
|
const pulls = [];
|
|
230
249
|
try {
|
|
231
250
|
for (let page = 1;; page += 1) {
|
|
232
|
-
const response = await octokit.pulls.list({
|
|
251
|
+
const response = await retryGitHubRead(() => octokit.pulls.list({
|
|
233
252
|
owner: repo.owner,
|
|
234
253
|
repo: repo.repo,
|
|
235
254
|
state: "open",
|
|
236
255
|
base: input.baseBranch,
|
|
237
256
|
per_page: 100,
|
|
238
257
|
page,
|
|
239
|
-
});
|
|
258
|
+
}));
|
|
240
259
|
pulls.push(...response.data);
|
|
241
260
|
if (response.data.length < 100) {
|
|
242
261
|
break;
|