Skip to content

Commit

Permalink
fix: Print right environment to .env on build
Browse files Browse the repository at this point in the history
  • Loading branch information
schw4rzlicht committed Jun 16, 2020
1 parent 2c3145d commit a3b1f80
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 21 deletions.
10 changes: 10 additions & 0 deletions .ci/generate-dotenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

if [[ "$1" = "undefined" ]]
then
echo "Posting production to .env" # DEBUG
echo "NODE_ENV=production" > .env
else
echo "Posting staging to .env" # DEBUG
echo "NODE_ENV=staging" > .env
fi
18 changes: 18 additions & 0 deletions .ci/notify-sentry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -a
source .env
set +a

curl -sL https://sentry.io/get-cli/ | bash

export SENTRY_RELEASE=$1

echo "Content of SENTRY_RELEASE: $SENTRY_RELEASE" # DEBUG
echo "Content of NODE_ENV: $NODE_ENV" # DEBUG

sentry-cli releases new -p $SENTRY_PROJECT $SENTRY_RELEASE
sentry-cli releases set-commits $SENTRY_RELEASE --auto
sentry-cli releases files $SENTRY_RELEASE upload-sourcemaps dist
sentry-cli releases finalize $SENTRY_RELEASE
sentry-cli releases deploys $SENTRY_RELEASE new -e $NODE_ENV
6 changes: 4 additions & 2 deletions .releaserc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ plugins:
- changelogFile: docs/CHANGELOG.md
- "@semantic-release/npm"
- - "@semantic-release/git"
- message: "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
assets:
- assets:
- package.json
- package-lock.json
- docs/CHANGELOG.md
- - "@semantic-release/exec"
- prepare: ".ci/generate-dotenv.sh ${nextRelease.channel}"
success: ".ci/notify-sentry.sh ${nextRelease.version}"
19 changes: 2 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,10 @@ node_js:
jobs:
include:
- stage: release
if: tag IS blank
deploy:
provider: script
skip_cleanup: true
script: npx semantic-release
on:
all_branches: true
- stage: notifySentry
if: tag IS present
deploy:
provider: script
skip_cleanup: true
script: |
curl -sL https://sentry.io/get-cli/ | bash
export SENTRY_RELEASE=$TRAVIS_TAG
sentry-cli releases new -p $SENTRY_PROJECT $SENTRY_RELEASE
sentry-cli releases set-commits $SENTRY_RELEASE --auto
sentry-cli releases files $SENTRY_RELEASE upload-sourcemaps dist
sentry-cli releases finalize $SENTRY_RELEASE
sentry-cli releases deploys $SENTRY_RELEASE new -e $SENTRY_ENVIRONMENT
# Debug in next line: " && cat .env"
script: npx semantic-release && cat .env
on:
all_branches: true
14 changes: 14 additions & 0 deletions package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"buildYamlConfigSample": "json2yaml ./config.json.sample > ./config.yml.sample",
"validateConfig": "npm run validateConfigSchema && ajv validate -s src/resources/config.schema.json -d config.json.sample",
"validateConfigSchema": "ajv compile -s src/resources/**.schema.json",
"prepublishOnly": "echo \"{ \\\"dsn\\\": \\\"$SENTRY_DSN\\\" }\" > sentry.json && echo \"NODE_ENV=production\" > .env"
"prepublishOnly": "echo \"{ \\\"dsn\\\": \\\"$SENTRY_DSN\\\" }\" > sentry.json"
},
"author": {
"name": "Julian Rabe",
Expand Down Expand Up @@ -49,14 +49,15 @@
},
"devDependencies": {
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/exec": "^5.0.0",
"@semantic-release/git": "^9.0.0",
"@types/bluebird-global": "^3.5.12",
"@types/humanize-duration": "^3.18.0",
"@types/jest": "^25.2.3",
"@types/lodash": "^4.14.152",
"@types/node-ipc": "^9.1.3",
"@types/semver": "^7.2.0",
"@types/source-map-support": "^0.5.1",
"@types/bluebird-global": "^3.5.12",
"ajv-cli": "~3.1.0",
"jest": "^26.0.1",
"json2yaml": "^1.1.0",
Expand Down

0 comments on commit a3b1f80

Please sign in to comment.