feat: support LiquidJS templates in strategy properties#66
Merged
Conversation
Property values are now rendered through the template engine with the
same context available to version and tag templates. This allows
properties like:
properties:
previousVersion: "{{ commitInfo.previousSemVerReleaseVersion }}"
baseVersion: "{{ commitInfo.previousSemVerReleaseVersion | semver_inc: 'minor' }}"
Static string values continue to work as before.
Closes #64
There was a problem hiding this comment.
Pull request overview
Adds LiquidJS template rendering for strategy properties, aligning them with existing version/tag templating so users can compute output values from commitInfo, versionInfo, env, etc.
Changes:
- Render
StrategyConfig.propertiesvalues through LiquidJS for tagged, semVer, and snapshot version results. - Introduce helper to render properties with a shared template context per result type.
- Add tests and documentation updates demonstrating templated properties.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/version/versionStrategy.ts | Adds per-result template contexts and renders properties via LiquidJS before returning strategy results. |
| src/version/versionStrategy.test.ts | Adds coverage ensuring properties render correctly for tagged/semVer/snapshot contexts and static values remain unchanged. |
| docs/templates.md | Extends example to include a templated property. |
| docs/configuration.md | Updates properties descriptions to note LiquidJS template support and link to templates docs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
35
to
39
| return { | ||
| version: tag, | ||
| tags: this.uniqueTags(this.config.tags.tagged, { | ||
| ...this.templateContext(context, commitInfo), | ||
| version: tag, | ||
| }), | ||
| ...this.config.properties, | ||
| tags: this.uniqueTags(this.config.tags.tagged, tplContext), | ||
| ...this.renderProperties(tplContext), | ||
| }; |
Comment on lines
55
to
59
| return { | ||
| version: stringVersion, | ||
| tags: this.uniqueTags(this.config.tags.semVer, { | ||
| ...this.templateContext(context, commitInfo), | ||
| version: stringVersion, | ||
| semVer: version, | ||
| }), | ||
| ...this.config.properties, | ||
| tags: this.uniqueTags(this.config.tags.semVer, tplContext), | ||
| ...this.renderProperties(tplContext), | ||
| }; |
Comment on lines
115
to
119
| return { | ||
| version: version, | ||
| tags: this.uniqueTags(this.config.tags.snapshot, { | ||
| ...templateContext, | ||
| version, | ||
| prefix, | ||
| suffix, | ||
| branchIdentifier, | ||
| commitIdentifier, | ||
| }), | ||
| ...this.config.properties, | ||
| tags: this.uniqueTags(this.config.tags.snapshot, snapshotTplContext), | ||
| ...this.renderProperties(snapshotTplContext), | ||
| }; |
Comment on lines
+134
to
+140
| private renderProperties(context: any): Record<string, string> { | ||
| return Object.fromEntries( | ||
| Object.entries(this.config.properties).map(([key, value]) => [ | ||
| key, | ||
| templateEngine.parseAndRenderSync(value, context), | ||
| ]), | ||
| ); |
Properties are now spread before version/tags, so the canonical fields always take precedence. Also tightens renderProperties context type from any to Record<string, unknown>.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Example:
Test plan
Closes #64