Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ jobs:
- name: check open-rpc specs titles
run: yarn script:openrpc:titles

- name: check daml release version alignment
run: yarn script:verify:daml-release-version

- name: prettier code
run: yarn run prettier . --check

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"script:fetch:canton": "tsx ./scripts/src/fetch-canton.ts",
"script:fetch:splice": "tsx ./scripts/src/fetch-splice.ts",
"script:fetch:localnet": "tsx ./scripts/src/fetch-localnet.ts",
"script:verify:daml-release-version": "tsx ./scripts/src/verify-daml-release-version.ts",
"script:openrpc:titles": "tsx ./scripts/src/schema-title-validation.ts",
"script:validate:package": "tsx ./scripts/src/package-and-verify-wallet-sdk.ts",
"script:test:examples": "yarn node --trace-uncaught --enable-source-maps --import tsx ./scripts/src/test-example-scripts.ts",
Expand Down
98 changes: 98 additions & 0 deletions scripts/src/verify-daml-release-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import * as fs from 'fs'
import * as path from 'path'
import * as yaml from 'js-yaml'
import * as process from 'process'
import {
DAML_RELEASE_VERSION,
error,
getAllFilesWithExtension,
info,
repoRoot,
success,
warn,
} from './lib/utils.js'

const DAMLJS_PATH = path.join(repoRoot, 'damljs')

type DamlYaml = {
'sdk-version'?: string
}

function main() {
console.log(
info(
`Checking daml.yaml sdk-version values against DAML_RELEASE_VERSION=${DAML_RELEASE_VERSION}`
)
)

const damlYamlFiles = getAllFilesWithExtension(DAMLJS_PATH, '.yaml').filter(
(filePath) => path.basename(filePath) === 'daml.yaml'
)

if (damlYamlFiles.length === 0) {
console.warn(warn(`No daml.yaml files found under ${DAMLJS_PATH}.`))
return
}

let mismatchCount = 0

for (const filePath of damlYamlFiles) {
const relativePath = path.relative(repoRoot, filePath)

try {
const contents = fs.readFileSync(filePath, 'utf8')
const parsed = yaml.load(contents) as DamlYaml | null
const sdkVersion = parsed?.['sdk-version']

if (sdkVersion === undefined) {
console.log(
info(
`${relativePath}: sdk-version key is missing; skipping check for this file`
)
)
continue
}

if (`${sdkVersion}` !== DAML_RELEASE_VERSION) {
console.error(
error(
`${relativePath}: sdk-version=${sdkVersion} does not match DAML_RELEASE_VERSION=${DAML_RELEASE_VERSION}`
)
)
mismatchCount++
continue
}

console.log(
success(
`${relativePath}: sdk-version=${sdkVersion} matches DAML_RELEASE_VERSION`
)
)
} catch (e) {
console.error(
error(
`${relativePath}: failed to parse daml.yaml (${e instanceof Error ? e.message : String(e)})`
)
)
mismatchCount++
}
}

if (mismatchCount > 0) {
console.log(
error(
`${mismatchCount} daml.yaml file(s) have sdk-version values that do not match DAML_RELEASE_VERSION=${DAML_RELEASE_VERSION}`
)
)
process.exit(1)
}

console.log(
success('All daml.yaml files are aligned with DAML_RELEASE_VERSION.')
)
}

main()