leanflutter / flutter_distributor

An all-in-one Flutter application packaging and distribution tool, providing you with a one-stop solution to meet various distribution needs.
https://distributor.leanflutter.dev/
MIT License
834 stars 116 forks source link

Why does it seem like it doesn't support environment variables #163

Open chinghoi opened 8 months ago

chinghoi commented 8 months ago

I don't know what else needs to be configured

variables:
  PGYER_API_KEY: $PGYER_API_KEY

In terminal $PGYER_API_KEY is effective, like

image

but

image
ddikman commented 2 months ago

@chinghoi although it won't allow you to reference variables inside the variables array, looking at this code: https://github.com/leanflutter/flutter_distributor/blob/main/packages/flutter_distributor/lib/src/flutter_distributor.dart#L325

It looks as though it will be pulling in the platform variables so if you just remove that one variable, it should work anyway.

However, I see in some places like here: https://github.com/leanflutter/flutter_distributor/blob/main/packages/flutter_distributor/lib/src/flutter_distributor.dart#L156

That they might get included only as a fallback, so if just removing it doesn't work perhaps there is a bug.

cybrox commented 2 months ago

It will definitely pull platform variables. I've been using this config for a long time now:

#distribute_options.yaml
env:
  # GOOGLE_APPLICATION_CREDENTIALS is exported by ./.keys/android/register.sh
  # APPSTORE_USERNAME and APPSTORE_PASSWORD is exported by ./.keys/ios/register.sh

releases:
...

# Makefile

ios_release:
    source .keys/ios/register.sh && \
    flutter_distributor release --name ios --jobs ios-production

...

# register.sh
export APPSTORE_USERNAME=...
export APPSTORE_PASSWORD=...

The reason for this somewhat roundabout setup is that .keys is a submodule with signing keys for multiple apps encrypted by git-secret. But this should work whichever way you set up the platform variables.

tl;dr: It will use your platform env variables. Only use env: to define additional ones.

ddikman commented 2 months ago

Yep, that's how I read it as well. Looking at the problem report the issue would be that $PGYER_API_KEY becomes the value. Just remove the line completely and it should work as @cybrox says.

variables:
  PGYER_API_KEY: $PGYER_API_KEY