Skip to content
Merged
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
9 changes: 8 additions & 1 deletion lib/dsc-lib-jsonschema/.versions.ps1
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env pwsh

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

Expand Down Expand Up @@ -32,7 +34,12 @@ begin {
param()

process {
$null = git fetch --all --tags
$allOut = git fetch --all --tags *>&1

if ($LASTEXITCODE -ne 0) {
throw "Unable to fetch git tags:`n`t$($allOut -join "`n`t")"
}

git tag -l
| Where-Object -FilterScript {$_ -match '^v\d+(\.\d+){2}$' }
| ForEach-Object -Process { [semver]($_.Substring(1)) }
Expand Down
27 changes: 17 additions & 10 deletions lib/dsc-lib-jsonschema/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,20 +501,27 @@ fn main() {
.expect("env var 'OUT_DIR' not defined");
let dest_path = Path::new(&out_dir).join("recognized_schema_version.rs");

// Update the versions data if needed.
let output = update_versions_data(&script_path);
assert!(
output.status.success(),
"Failed to update versions data via PowerShell script.\nExit code: {:?}\nStdout: {}\nStderr: {}",
output.status.code(),
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
);
let profile = env::var_os("PROFILE")
.expect("env var 'PROFILE' not defined");

// Update the versions data if needed, only on debug builds.
if profile == "debug" {
let output = update_versions_data(&script_path);
assert!(
output.status.success(),
"Failed to update versions data via PowerShell script.\nExit code: {:?}\nStdout: {}\nStderr: {}",
output.status.code(),
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
);
}

let version_data = read_to_string(data_path)
.expect("Failed to read .versions.json file");
let version_info: VersionInfo = serde_json::from_str(&version_data)
.expect("Failed to parse version data from .versions.json");
.expect(format!(
"Failed to parse version data from .versions.json:\n---FILE TEXT START---\n{version_data}\n---FILE TEXT END---\n"
).as_str());
let contents = format_file_content(&version_info);

fs::write(
Expand Down