Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
Fastlane environment mgmt (#668)
Browse files Browse the repository at this point in the history
* move .env files back into source control minus secrets

* load secrets into .env files at build time and cleanup after

* auto generated docs

* ignore fastlane .env

* update to latest version

* move a few more things to secrets
  • Loading branch information
dsamojlenko authored Jul 14, 2020
1 parent d8a59fa commit 06282e1
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 36 deletions.
18 changes: 18 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
APP_ID_IOS=app.covidshield
APP_ID_ANDROID=app.covidshield

APP_VERSION_NAME=1.0
APP_VERSION_CODE=47

SUBMIT_URL=https://submission.covidshield.app
RETRIEVE_URL=https://retrieval.covidshield.app

HMAC_KEY=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

TEST_MODE=true
MOCK_SERVER=false

MCC_CODE=302

TRANSMISSION_RISK_LEVEL=4
MINIMUM_FETCH_INTERVAL=15
18 changes: 18 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
APP_ID_IOS=app.covidshield
APP_ID_ANDROID=app.covidshield

APP_VERSION_NAME=1.0
APP_VERSION_CODE=47

SUBMIT_URL=https://submission.covidshield.app
RETRIEVE_URL=https://retrieval.covidshield.app

HMAC_KEY=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

TEST_MODE=true
MOCK_SERVER=false

MCC_CODE=302

TRANSMISSION_RISK_LEVEL=4
MINIMUM_FETCH_INTERVAL=15
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
#
.DS_Store


.env.production

# Xcode
#
build/
Expand Down Expand Up @@ -93,7 +90,6 @@ ios/Generated.xcconfig
android/app/google-services.json
.env.local
.env.secrets
.env

# generated files
ios/assets
1 change: 1 addition & 0 deletions fastlane/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
55 changes: 51 additions & 4 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,59 @@ before_all do
# Load root-level shared .env
Dotenv.overload '../.env'

load_secrets

# Pull all tags
git_pull(only_tags: true)
end

after_all do
clean_env
end

private_lane :ensure_clean_env do
env_status = sh("cd ../ && git status .env .env.production --porcelain")
clean = env_status.empty?

UI.user_error!("You should not have local changes to .env or .env.production") unless clean
end

private_lane :clean_env do
sh("cd ../ && git checkout .env .env.production")
end

private_lane :ensure_secrets_file_exists do
file_exists = File.exist? File.expand_path "../.env.secrets"

UI.user_error!("You appear to be missing a .env.secrets file") unless file_exists
end

private_lane :load_secrets do
ensure_secrets_file_exists
ensure_clean_env

# Merge secrets with the default .env file
production = Dotenv.parse("../.env.production")
debug = Dotenv.parse("../.env")
secrets = Dotenv.parse('../.env.secrets')

production.merge!(secrets)
debug.merge!(secrets)

production_env = "../.env.production"
debug_env = "../.env"

File.open(production_env, 'w') do |file|
production.each{ |k, v| file.write("#{k}=#{v}\n") }
end

File.open(debug_env, 'w') do |file|
debug.each{ |k, v| file.write("#{k}=#{v}\n") }
end
end

desc "Creates a Github Release"
lane :create_github_release do |options|
private_lane :create_github_release do |options|
UI.user_error!("platform is missing") unless options[:platform]
upload_assets = options[:upload_assets] ? options[:upload_assets] : []

Expand All @@ -26,7 +73,7 @@ lane :create_github_release do |options|
end

desc "Returns a default changelog."
lane :default_changelog do |options|
private_lane :default_changelog do |options|
format = (options[:simple] ? "- %b" : "- %b [%s]")

changelog = changelog_from_git_commits(
Expand All @@ -39,13 +86,13 @@ lane :default_changelog do |options|
clean
end

lane :ensure_keystore_properties do
private_lane :ensure_keystore_properties do
file_exists = File.exist? File.expand_path "../android/keystore.properties"

UI.user_error!("keystore.properties file is missing!") unless file_exists
end

lane :ensure_build_directory do
private_lane :ensure_build_directory do
UI.message("Checking for build directories")

unless File.directory?('../build/ios')
Expand Down
28 changes: 0 additions & 28 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,6 @@ Install _fastlane_ using
or alternatively using `brew install fastlane`

# Available Actions
### create_github_release
```
fastlane create_github_release
```
Creates a Github Release
### default_changelog
```
fastlane default_changelog
```
Returns a default changelog.
### ensure_keystore_properties
```
fastlane ensure_keystore_properties
```

### ensure_build_directory
```
fastlane ensure_build_directory
```

### test
```
fastlane test
```


----

## iOS
### ios beta
```
Expand Down

0 comments on commit 06282e1

Please sign in to comment.