Skip to content

Commit 164777a

Browse files
Add dynamic placeholder replacement in functions.tmdl (#1)
Introduce a new workflow step in `publish-abcclassification.yml` to replace placeholders for package ID and version in the `functions.tmdl` file. Updated `functions.tmdl` to use placeholders (`__PLACEHOLDER_PACKAGE_ID__` and `__PLACEHOLDER_PACKAGE_VERSION__`) instead of hardcoded values for `DAXLIB_PackageId` and `DAXLIB_PackageVersion`. This ensures metadata is dynamically updated during workflow execution.
1 parent 3416802 commit 164777a

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

.github/workflows/publish-abcclassification.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ jobs:
9999
- name: Copy package files
100100
run: cp -rv source-repo/src/${{ env.DAXPATTERN_NAME }}/* "fork-repo/${{ steps.package.outputs.folder }}/"
101101

102+
# Replace the package ID and version placeholders in functions.tmdl
103+
- name: Replace placeholders
104+
working-directory: fork-repo
105+
run: |
106+
FUNCTIONS_FILE="${{ steps.package.outputs.folder }}/lib/functions.tmdl"
107+
sed -i "s/__PLACEHOLDER_DAXLIB_PACKAGEID__/${{ steps.package.outputs.name }}/g" "${FUNCTIONS_FILE}"
108+
sed -i "s/__PLACEHOLDER_DAXLIB_PACKAGEVERSION__/${{ steps.package.outputs.version }}/g" "${FUNCTIONS_FILE}"
109+
102110
# Commit changes. If there are no changes, this will fail and stop the workflow
103111
- name: Git commit changes
104112
working-directory: fork-repo

src/AbcClassification/lib/functions.tmdl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ function 'DaxPatterns.AbcClassification.ComputeInAbcClass' = ```
3636
)
3737
RETURN Result
3838
```
39-
annotation DAXLIB_PackageId = DaxPatterns.AbcClassification
39+
annotation DAXLIB_PackageId = __PLACEHOLDER_PACKAGE_ID__
4040

41-
annotation DAXLIB_PackageVersion = 0.1.3
41+
annotation DAXLIB_PackageVersion = __PLACEHOLDER_PACKAGE_VERSION__
4242

4343
/// Return the items filtered by ABC classes
4444
/// Implement Dynamic ABC Classification pattern from DAX Patterns
@@ -110,6 +110,6 @@ function 'DaxPatterns.AbcClassification.ItemsInClass' = ```
110110
)
111111
RETURN Result
112112
```
113-
annotation DAXLIB_PackageId = DaxPatterns.AbcClassification
113+
annotation DAXLIB_PackageId = __PLACEHOLDER_PACKAGE_ID__
114114

115-
annotation DAXLIB_PackageVersion = 0.1.3
115+
annotation DAXLIB_PackageVersion = __PLACEHOLDER_PACKAGE_VERSION__

0 commit comments

Comments
 (0)