Skip to content

Commit

Permalink
update build script to default to anonymous CFS and strip release bin…
Browse files Browse the repository at this point in the history
…aries
  • Loading branch information
SteveL-MSFT committed Oct 28, 2024
1 parent c75e1d7 commit 0db783b
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
registry-auth = true

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

[registry]
global-credential-providers = ["cargo:token"]
Expand Down
38 changes: 20 additions & 18 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ param(
[switch]$UseX64MakeAppx,
[switch]$UseCratesIO,
[switch]$UpdateLockFile,
[switch]$Audit
[switch]$Audit,
[switch]$UseCFSAuth
)

if ($GetPackageVersion) {
Expand Down Expand Up @@ -191,25 +192,26 @@ if (!$SkipBuild) {
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = $null
$env:CARGO_REGISTRIES_CRATESIO_INDEX = $null

if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) {
throw "Azure CLI not found"
}
if ($UseCFSAuth -or $null -ne $env:TF_BUILD) {
if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) {
throw "Azure CLI not found"
}

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

Expand Down
7 changes: 7 additions & 0 deletions dsc_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ name = "dsc_lib"
version = "3.0.0"
edition = "2021"

[profile.release]
strip = true
# optimize for size
opt-level = 2
# enable link time optimization to remove dead code
lto = true

[dependencies]
base64 = "0.22"
chrono = "0.4"
Expand Down
7 changes: 6 additions & 1 deletion osinfo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ name = "osinfo"
version = "0.1.0"
edition = "2021"

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

[dependencies]
os_info = { version = "3.7" }
Expand Down
3 changes: 0 additions & 3 deletions registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ opt-level = 2
# enable link time optimization to remove dead code
lto = true

[profile.dev]
lto = true

[dependencies]
clap = { version = "4.5", features = ["derive"] }
crossterm = "0.28"
Expand Down
7 changes: 6 additions & 1 deletion runcommandonset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ name = "runcommandonset"
version = "0.1.0"
edition = "2021"

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

[dependencies]
clap = { version = "4.4", features = ["derive"] }
Expand Down
7 changes: 7 additions & 0 deletions security_context_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ name = "security_context_lib"
version = "0.1.0"
edition = "2021"

[profile.release]
strip = true
# optimize for size
opt-level = 2
# enable link time optimization to remove dead code
lto = true

[target.'cfg(target_os = "windows")'.dependencies]
is_elevated = "0.1"

Expand Down
7 changes: 7 additions & 0 deletions tree-sitter-dscexpression/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ include = [
[lib]
path = "bindings/rust/lib.rs"

[profile.release]
strip = true
# optimize for size
opt-level = 2
# enable link time optimization to remove dead code
lto = true

[dependencies]
tree-sitter-rust = "0.23"
tree-sitter = "0.24"
Expand Down
7 changes: 7 additions & 0 deletions y2j/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ name = "y2j"
version = "1.0.0"
edition = "2021"

[profile.release]
strip = true
# optimize for size
opt-level = 2
# enable link time optimization to remove dead code
lto = true

[dependencies]
serde_json = { version = "1.0.0", features = ["preserve_order"] }
serde_yaml = { version = "0.9.3" }
Expand Down

0 comments on commit 0db783b

Please sign in to comment.