Skip to content

Commit

Permalink
Merge pull request #17 from uzzu/change-dotenv-file
Browse files Browse the repository at this point in the history
Add changing dotenv file feature
  • Loading branch information
uzzu authored Sep 23, 2021
2 parents 10b0dd4 + 1fefcf4 commit 66a2266
Show file tree
Hide file tree
Showing 21 changed files with 673 additions and 59 deletions.
55 changes: 30 additions & 25 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,33 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 11
- name: Gradle clean
run: |
./gradlew clean
- name: Gradle build
run: |
./gradlew build
- name: Gradle publish to mavenLocal
run: |
./gradlew publishToMavenLocal
- name: Run basic example
run: |
cd examples/basic
./gradlew clean --refresh-dependencies
- name: Upload build report
uses: actions/[email protected]
with:
name: build_reports
path: plugin/build/reports
- name: Checkout
uses: actions/checkout@v2
- name: Setup JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 11
- name: Gradle clean
run: |
./gradlew clean
- name: Gradle build
run: |
./gradlew build
- name: Gradle publish to mavenLocal
run: |
./gradlew publishToMavenLocal
- name: Run basic example
run: |
cd examples/basic
./gradlew clean --refresh-dependencies
- name: Run change file example
run: |
cd examples/change_file
./gradlew clean --refresh-dependencies
ENV_FILE=.env.staging ./gradlew clean
- name: Upload build report
uses: actions/[email protected]
with:
name: build_reports
path: plugin/build/reports
62 changes: 33 additions & 29 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
name: Publish
on:
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 11
- name: Set env
run: |
echo 'GRADLE_PUBLISH_KEY=${{ secrets.GRADLE_PUBLISH_KEY }}' >> $GITHUB_ENV
echo 'GRADLE_PUBLISH_SECRET=${{ secrets.GRADLE_PUBLISH_SECRET }}' >> $GITHUB_ENV
- name: Gradle clean
run: |
./gradlew clean
- name: Gradle build
run: |
./gradlew build
- name: Gradle publish to mavenLocal
run: |
./gradlew publishToMavenLocal
- name: Run basic example
run: |
cd examples/basic
./gradlew clean --refresh-dependencies
pushd
- name: publish
run: |
PUBLISH_PRODUCTION=1 ./gradlew publishPlugins
- name: Checkout
uses: actions/checkout@v2
- name: Setup JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 11
- name: Set env
run: |
echo 'GRADLE_PUBLISH_KEY=${{ secrets.GRADLE_PUBLISH_KEY }}' >> $GITHUB_ENV
echo 'GRADLE_PUBLISH_SECRET=${{ secrets.GRADLE_PUBLISH_SECRET }}' >> $GITHUB_ENV
- name: Gradle clean
run: |
./gradlew clean
- name: Gradle build
run: |
./gradlew build
- name: Gradle publish to mavenLocal
run: |
./gradlew publishToMavenLocal
- name: Run basic example
run: |
cd examples/basic
./gradlew clean --refresh-dependencies
- name: Run change file example
run: |
cd examples/change_file
./gradlew clean --refresh-dependencies
ENV_FILE=.env.staging ./gradlew clean
- name: publish
run: |
PUBLISH_PRODUCTION=1 ./gradlew publishPlugins
7 changes: 6 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pull-request-build

on: [pull_request]
on: [ pull_request ]

jobs:
build:
Expand Down Expand Up @@ -36,6 +36,11 @@ jobs:
run: |
cd examples/basic
./gradlew clean --refresh-dependencies
- name: Run change file example
run: |
cd examples/change_file
./gradlew clean --refresh-dependencies
ENV_FILE=.env.staging ./gradlew clean
- name: Upload build report
uses: actions/[email protected]
with:
Expand Down
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- Update Gradle to 6.9
- Update Kotlin to 1.4.20
- Add changing `.env` file feature
- If environment variable `ENV_FILE` is set, The plugin read a file specified `ENV_FILE` instead of `.env` file.

## Changed

- Update Gradle to 6.6
- Update Kotlin to 1.3.72

## [1.1.0] - 2020-04-21

### Added

- `(Map<String, String>) env.allVariables` to get all environment variables includes variables specified in `.env` files. [#5](https://github.com/uzzu/dotenv-gradle/pull/5)
- `(Map<String, String>) env.allVariables` to get all environment variables includes variables specified in `.env`
files. [#5](https://github.com/uzzu/dotenv-gradle/pull/5)

## [1.0.2] - 2020-02-12

Expand All @@ -26,9 +33,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [1.0.1] - 2020-02-12

### Fixed

- Fix gradle plugin metadata.

## [1.0.0] - 2020-02-12

### Added

- Initial release.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ println(env.BAZ.orElse("default baz")) // => baz

If a `.env.template` file exists, this plugin refer it to create a environemnt variable properties in the `env` extension.

### [Optional] Change a file to read instead of `.env` file.

If environment variable `ENV_FILE` is set, The plugin read a file specified `ENV_FILE` instead of `.env` file.

[See example](/examples/change_file)

### Others
- All APIs of `env` extension consider `.env` file.
- If the same variable name value is defined in both the `.env` file and the system environment variable, the system environment variable takes precedence.
Expand Down
1 change: 1 addition & 0 deletions examples/change_file/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FOO=default
1 change: 1 addition & 0 deletions examples/change_file/.env.staging
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FOO=staging
1 change: 1 addition & 0 deletions examples/change_file/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FOO=
6 changes: 6 additions & 0 deletions examples/change_file/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

5 changes: 5 additions & 0 deletions examples/change_file/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build
6 changes: 6 additions & 0 deletions examples/change_file/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Change file example

Run the following command to confirm that the DotEnv file to be loaded has changed.

- `./gradlew clean`
- `ENV_FILE=.env.staging ./gradlew clean`
6 changes: 6 additions & 0 deletions examples/change_file/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
plugins {
base
id("co.uzzu.dotenv.gradle") version "1.1.0"
}

println(env.FOO.value)
Binary file not shown.
5 changes: 5 additions & 0 deletions examples/change_file/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 66a2266

Please sign in to comment.