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
50 changes: 48 additions & 2 deletions .github/workflows/stac_cli_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,32 @@ jobs:
if: runner.os != 'Windows'
working-directory: packages/stac_cli
shell: bash
env:
STAC_BASE_API_URL: ${{ secrets.STAC_BASE_API_URL }}
STAC_GOOGLE_CLIENT_ID: ${{ secrets.STAC_GOOGLE_CLIENT_ID }}
STAC_GOOGLE_CLIENT_SECRET: ${{ secrets.STAC_GOOGLE_CLIENT_SECRET }}
STAC_FIREBASE_API_KEY: ${{ secrets.STAC_FIREBASE_API_KEY }}
run: |
# Preflight: abort if any required secret is missing
missing=0
for var in STAC_BASE_API_URL STAC_GOOGLE_CLIENT_ID STAC_GOOGLE_CLIENT_SECRET STAC_FIREBASE_API_KEY; do
if [[ -z "${!var}" ]]; then
echo "✗ Error: Required secret $var is empty or not set" >&2
missing=1
fi
done
if [[ $missing -ne 0 ]]; then
echo "Aborting: one or more required secrets are missing" >&2
exit 1
fi

mkdir -p build
echo "Compiling for ${{ matrix.arch }} (${{ matrix.name }})..."
dart compile exe bin/stac_cli.dart \
-D STAC_BASE_API_URL="$STAC_BASE_API_URL" \
-D STAC_GOOGLE_CLIENT_ID="$STAC_GOOGLE_CLIENT_ID" \
-D STAC_GOOGLE_CLIENT_SECRET="$STAC_GOOGLE_CLIENT_SECRET" \
-D STAC_FIREBASE_API_KEY="$STAC_FIREBASE_API_KEY" \
-o build/stac
echo "✓ Binary compiled successfully"
ls -lh build/stac
Expand All @@ -94,9 +116,33 @@ jobs:
if: runner.os == 'Windows'
working-directory: packages/stac_cli
shell: pwsh
env:
STAC_BASE_API_URL: ${{ secrets.STAC_BASE_API_URL }}
STAC_GOOGLE_CLIENT_ID: ${{ secrets.STAC_GOOGLE_CLIENT_ID }}
STAC_GOOGLE_CLIENT_SECRET: ${{ secrets.STAC_GOOGLE_CLIENT_SECRET }}
STAC_FIREBASE_API_KEY: ${{ secrets.STAC_FIREBASE_API_KEY }}
run: |
# Preflight: abort if any required secret is missing
$missing = 0
foreach ($var in @('STAC_BASE_API_URL', 'STAC_GOOGLE_CLIENT_ID', 'STAC_GOOGLE_CLIENT_SECRET', 'STAC_FIREBASE_API_KEY')) {
$val = [Environment]::GetEnvironmentVariable($var)
if ([string]::IsNullOrWhiteSpace($val)) {
Write-Error "✗ Error: Required secret $var is empty or not set"
$missing = 1
}
}
if ($missing -ne 0) {
Write-Error "Aborting: one or more required secrets are missing"
exit 1
}

New-Item -ItemType Directory -Force -Path build | Out-Null
dart compile exe bin/stac_cli.dart -o build/stac.exe
dart compile exe bin/stac_cli.dart `
-D STAC_BASE_API_URL="$env:STAC_BASE_API_URL" `
-D STAC_GOOGLE_CLIENT_ID="$env:STAC_GOOGLE_CLIENT_ID" `
-D STAC_GOOGLE_CLIENT_SECRET="$env:STAC_GOOGLE_CLIENT_SECRET" `
-D STAC_FIREBASE_API_KEY="$env:STAC_FIREBASE_API_KEY" `
-o build/stac.exe

- name: Package artifact (Linux/macOS)
if: runner.os != 'Windows'
Expand Down Expand Up @@ -212,7 +258,7 @@ jobs:
--notes "Automated release for stac_cli $VERSION"
echo "✓ Created release $TAG"
else
echo "Release $TAG already exists, updating..."
echo "Release $TAG already exists, updating..."
fi

# Upload all artifacts
Expand Down
4 changes: 2 additions & 2 deletions examples/counter_example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -787,14 +787,14 @@ packages:
path: "../../packages/stac"
relative: true
source: path
version: "1.3.1"
version: "1.4.0"
stac_core:
dependency: "direct overridden"
description:
path: "../../packages/stac_core"
relative: true
source: path
version: "1.3.0"
version: "1.4.0"
stac_framework:
dependency: "direct overridden"
description:
Expand Down
4 changes: 2 additions & 2 deletions examples/movie_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -715,14 +715,14 @@ packages:
path: "../../packages/stac"
relative: true
source: path
version: "1.3.1"
version: "1.4.0"
stac_core:
dependency: "direct overridden"
description:
path: "../../packages/stac_core"
relative: true
source: path
version: "1.3.0"
version: "1.4.0"
stac_framework:
dependency: "direct overridden"
description:
Expand Down
4 changes: 2 additions & 2 deletions examples/stac_gallery/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -779,14 +779,14 @@ packages:
path: "../../packages/stac"
relative: true
source: path
version: "1.3.1"
version: "1.4.0"
stac_core:
dependency: "direct overridden"
description:
path: "../../packages/stac_core"
relative: true
source: path
version: "1.3.0"
version: "1.4.0"
stac_framework:
dependency: "direct overridden"
description:
Expand Down
19 changes: 19 additions & 0 deletions packages/stac_cli/lib/src/config/env.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,34 @@ class EnvConfig {
});
}

const Map<String, String> _compiledEnvMap = {
'STAC_BASE_API_URL': String.fromEnvironment('STAC_BASE_API_URL'),
'STAC_GOOGLE_CLIENT_ID': String.fromEnvironment('STAC_GOOGLE_CLIENT_ID'),
'STAC_GOOGLE_CLIENT_SECRET': String.fromEnvironment(
'STAC_GOOGLE_CLIENT_SECRET',
),
'STAC_FIREBASE_API_KEY': String.fromEnvironment('STAC_FIREBASE_API_KEY'),
};
Comment thread
divyanshub024 marked this conversation as resolved.

String? _env(String key, {String? defaultValue, bool required = false}) {
// 1. Primary: compile-time configuration injected via `dart compile exe -D...`
final compiled = _compiledEnvMap[key];
if (compiled != null && compiled.isNotEmpty) {
return compiled;
}

// 2. Fallback to dynamically provided constants (.env or OS environment)
final raw = _resolvedEnvironment[key];
if (raw != null) {
final trimmed = raw.trim();
if (trimmed.isNotEmpty) return trimmed;
}

// 3. Fallback to defaults
if (defaultValue != null && defaultValue.isNotEmpty) {
return defaultValue;
}

if (required) {
throw StateError('Missing required environment variable: $key');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/stac_cli/lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/stac_cli/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ packages:
path: "../stac_core"
relative: true
source: path
version: "1.3.0"
version: "1.4.0"
stac_logger:
dependency: "direct overridden"
description:
Expand Down
2 changes: 1 addition & 1 deletion packages/stac_cli/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: stac_cli
description: A CLI tool for managing Stac SDUI (Server-Driven UI) projects and converting Dart to JSON.
version: 1.5.0
version: 1.5.1
repository: https://github.com/StacDev/stac
homepage: https://stac.dev/

Expand Down