Skip to content

Commit

Permalink
chore: leverage make upgrade_npmversion script to also update root
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Flitton <[email protected]>
  • Loading branch information
FrankFlitton committed Jul 31, 2023
1 parent fc70a69 commit a0975cd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 33 deletions.
6 changes: 2 additions & 4 deletions .releaserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ function getProdConfiguration() {
'@semantic-release/exec',
{
// eslint-disable-next-line no-template-curly-in-string
prepareCmd:
'node script/semantic-release-npm-prepare.js ${nextRelease.version}',
prepareCmd: 'make update_npmversion VERSION=${nextRelease.version}',
},
],
// make repo tags that match the package.json version
Expand Down Expand Up @@ -71,8 +70,7 @@ function getTestConfiguration() {
'@semantic-release/exec',
{
// eslint-disable-next-line no-template-curly-in-string
prepareCmd:
'node script/semantic-release-npm-prepare.js ${nextRelease.version}',
prepareCmd: 'make update_npmversion VERSION=${nextRelease.version}',
},
],
// make repo tags that match the package.json version
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,4 @@ PLACEHOLDER_NPM := "version": "0.0.0-develop"

.PHONY: update_npmversion
update_npmversion:
echo "Updating client-app version to: $(VERSION)"
grep '$(PLACEHOLDER_NPM)' website/package.json
sed -i 's/$(PLACEHOLDER_NPM)/"version": "$(VERSION)"/g' website/package.json
./script/update_npmversion.sh ${VERSION}
26 changes: 0 additions & 26 deletions script/semantic-release-npm-prepare.js

This file was deleted.

32 changes: 32 additions & 0 deletions script/update_npmversion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# Update npm version in package.json files
#
# Approximating functionality from:
# https://github.com/semantic-release/npm/blob/master/lib/prepare.js#L14
#
# This script will update the package.json version to the version provided by
# the release semantic-release pipeline.
#
# To be used with @semantic-release/exec before @semantic-release/git.
# The version should be consistent with the most recent git tag.
#
# Usage: ./update_npmversion.sh <version>
# Example: ./update_npmversion.sh 1.0.0
#
# Note: for mac users, install GNU SED and add it to your PATH variable
# https://formulae.brew.sh/formula/gnu-sed


# load version from args
VERSION=$1

echo "Updating client-app version to: $VERSION"
WEBSITE_JSON=$(realpath website/package.json)
# replace contents of {"version": "x", ...} with {version: "$VERSION"}
sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/g" $WEBSITE_JSON

echo "Updating root package version to: $VERSION"
ROOT_JSON=$(realpath package.json)
# replace contents of {"version": "x", ...} with {version: "$VERSION"}
sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/g" $ROOT_JSON

0 comments on commit a0975cd

Please sign in to comment.