Skip to content

Commit

Permalink
fix: fix semantic-release dist-tag (#319)
Browse files Browse the repository at this point in the history
Fix semantic-release config so that it correctly adds a dist-tag to the published npm package. Fix
so it commits the updated package.json version
  • Loading branch information
Jeremy Trujillo committed Jun 13, 2018
1 parent cc77b27 commit e12335c
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 9 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package.json
package-lock.json
CHANGELOG.md
/coverage
dist/
6 changes: 5 additions & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
{
"pkgRoot": "dist/cashmere",
"verifyConditions": ["@semantic-release/changelog", "@semantic-release/npm", "@semantic-release/git", "@semantic-release/github"],
"prepare": [
{
"path": "@semantic-release/changelog",
"changelogFile": "CHANGELOG.md"
},
"@semantic-release/npm",
{
"path": "@semantic-release/exec",
"cmd": "./scripts/replace-package-version.sh ${nextRelease.version}"
},
"@semantic-release/git"
],
"verifyConditions": ["@semantic-release/changelog", "@semantic-release/npm", "@semantic-release/git", "@semantic-release/github"],
"publish": [
{
"path": "@semantic-release/npm",
Expand Down
68 changes: 68 additions & 0 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Cashmere documentation website",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"tag": "alpha"
"tag": "beta"
},
"repository": {
"type": "git",
Expand All @@ -23,7 +23,6 @@
"postbuild:lib": "node scripts/postbuild.js",
"build:user": "ng build user-guide --prod",
"build": "npm run build:lib && npm run build:user",
"postpublish": "./scripts/replace-package-version.sh",
"precommit": "lint-staged",
"commitmsg": "commitlint -e $GIT_PARAMS",
"cm": "git-cz",
Expand Down Expand Up @@ -72,6 +71,7 @@
"@commitlint/config-conventional": "^6.1.3",
"@commitlint/travis-cli": "^6.2.0",
"@semantic-release/changelog": "^2.0.2",
"@semantic-release/exec": "^2.2.4",
"@semantic-release/git": "^5.0.0",
"@types/d3": "^5.0.0",
"@types/jasmine": "~2.8.6",
Expand Down
4 changes: 4 additions & 0 deletions projects/cashmere/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"version": "0.0.0-development",
"license": "Apache-2.0",
"description": "Reusable Health Catalyst Components",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"tag": "beta"
},
"repository": {
"type": "Git",
"url": "https://github.com/HealthCatalyst/Fabric.Cashmere"
Expand Down
13 changes: 7 additions & 6 deletions scripts/replace-package-version.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env bash

if [ -z "$1" ]; then
echo "Must pass package version as first argument"
exit 1
fi

# Grab package version set by semantic release
PACKAGE_VERSION=$(cat dist/cashmere/package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
PACKAGE_VERSION=$1

# Replace package.json version with generated version
sed -i "" -E "s/(\"version\":[[:space:]]*\").+(\")/\1${PACKAGE_VERSION}\2/g" package.json

# Update package-lock.json version also
npm install --package-lock-only
sed -i "" -E "s/(\"version\":[[:space:]]*\").+(\")/\1${PACKAGE_VERSION}\2/g" package-lock.json

0 comments on commit e12335c

Please sign in to comment.