Skip to content

Commit 0db783b

Browse files
committed
update build script to default to anonymous CFS and strip release binaries
1 parent c75e1d7 commit 0db783b

File tree

9 files changed

+61
-24
lines changed

9 files changed

+61
-24
lines changed

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
registry-auth = true
44

55
[registries]
6-
POWERSHELL = { index = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell~force-auth/Cargo/index/" }
6+
POWERSHELL = { index = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/Cargo/index/" }
77

88
[registry]
99
global-credential-providers = ["cargo:token"]

build.ps1

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ param(
1515
[switch]$UseX64MakeAppx,
1616
[switch]$UseCratesIO,
1717
[switch]$UpdateLockFile,
18-
[switch]$Audit
18+
[switch]$Audit,
19+
[switch]$UseCFSAuth
1920
)
2021

2122
if ($GetPackageVersion) {
@@ -191,25 +192,26 @@ if (!$SkipBuild) {
191192
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = $null
192193
$env:CARGO_REGISTRIES_CRATESIO_INDEX = $null
193194

194-
if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) {
195-
throw "Azure CLI not found"
196-
}
195+
if ($UseCFSAuth -or $null -ne $env:TF_BUILD) {
196+
if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) {
197+
throw "Azure CLI not found"
198+
}
197199

198-
if ($null -ne (Get-Command az -ErrorAction Ignore)) {
199-
Write-Host "Getting token"
200-
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
201-
if ($LASTEXITCODE -ne 0) {
202-
Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access."
203-
$env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/Cargo/index/"
204-
} else {
205-
$header = "Bearer $accessToken"
206-
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
207-
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
200+
if ($null -ne (Get-Command az -ErrorAction Ignore)) {
201+
Write-Host "Getting token"
202+
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
203+
if ($LASTEXITCODE -ne 0) {
204+
Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access."
205+
} else {
206+
$header = "Bearer $accessToken"
207+
$env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell~force-auth/Cargo/index/"
208+
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
209+
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
210+
}
211+
}
212+
else {
213+
Write-Warning "Azure CLI not found, proceeding with anonymous access."
208214
}
209-
}
210-
else {
211-
Write-Warning "Azure CLI not found, proceeding with anonymous access."
212-
$env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/Cargo/index/"
213215
}
214216
}
215217

dsc_lib/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ name = "dsc_lib"
33
version = "3.0.0"
44
edition = "2021"
55

6+
[profile.release]
7+
strip = true
8+
# optimize for size
9+
opt-level = 2
10+
# enable link time optimization to remove dead code
11+
lto = true
12+
613
[dependencies]
714
base64 = "0.22"
815
chrono = "0.4"

osinfo/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ name = "osinfo"
33
version = "0.1.0"
44
edition = "2021"
55

6-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
6+
[profile.release]
7+
strip = true
8+
# optimize for size
9+
opt-level = 2
10+
# enable link time optimization to remove dead code
11+
lto = true
712

813
[dependencies]
914
os_info = { version = "3.7" }

registry/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ opt-level = 2
1010
# enable link time optimization to remove dead code
1111
lto = true
1212

13-
[profile.dev]
14-
lto = true
15-
1613
[dependencies]
1714
clap = { version = "4.5", features = ["derive"] }
1815
crossterm = "0.28"

runcommandonset/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ name = "runcommandonset"
33
version = "0.1.0"
44
edition = "2021"
55

6-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
6+
[profile.release]
7+
strip = true
8+
# optimize for size
9+
opt-level = 2
10+
# enable link time optimization to remove dead code
11+
lto = true
712

813
[dependencies]
914
clap = { version = "4.4", features = ["derive"] }

security_context_lib/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ name = "security_context_lib"
33
version = "0.1.0"
44
edition = "2021"
55

6+
[profile.release]
7+
strip = true
8+
# optimize for size
9+
opt-level = 2
10+
# enable link time optimization to remove dead code
11+
lto = true
12+
613
[target.'cfg(target_os = "windows")'.dependencies]
714
is_elevated = "0.1"
815

tree-sitter-dscexpression/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ include = [
1919
[lib]
2020
path = "bindings/rust/lib.rs"
2121

22+
[profile.release]
23+
strip = true
24+
# optimize for size
25+
opt-level = 2
26+
# enable link time optimization to remove dead code
27+
lto = true
28+
2229
[dependencies]
2330
tree-sitter-rust = "0.23"
2431
tree-sitter = "0.24"

y2j/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ name = "y2j"
33
version = "1.0.0"
44
edition = "2021"
55

6+
[profile.release]
7+
strip = true
8+
# optimize for size
9+
opt-level = 2
10+
# enable link time optimization to remove dead code
11+
lto = true
12+
613
[dependencies]
714
serde_json = { version = "1.0.0", features = ["preserve_order"] }
815
serde_yaml = { version = "0.9.3" }

0 commit comments

Comments
 (0)