From e3da9b508b94fb80ac0448bc44286c4f6881a2aa Mon Sep 17 00:00:00 2001 From: Daniel Playfair Cal Date: Fri, 20 Dec 2019 15:43:17 +1100 Subject: [PATCH] dx: add script to release to git tags --- package.json | 2 ++ scripts/git-release.sh | 22 ++++++++++++++++++++++ yarn.lock | 4 ++++ 3 files changed, 28 insertions(+) create mode 100755 scripts/git-release.sh diff --git a/package.json b/package.json index 14bc2ed0..3945e6a2 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "format": "prettier --write \"**/*.{js,json,md}\"", "lint": "eslint .", "release": "lerna publish --conventional-commits && conventional-github-releaser --preset angular", + "release-to-git": "./scripts/git-release.sh", "test": "jest" }, "devDependencies": { @@ -47,6 +48,7 @@ "eslint-plugin-react": "^7.17.0", "jest": "^24.9.0", "lerna": "^3.19.0", + "npm-publish-git": "git://github.com/hedgepigdaniel/npm-publish-git.git", "prettier": "^1.19.1", "react": "^16.12.0", "react-dom": "^16.12.0", diff --git a/scripts/git-release.sh b/scripts/git-release.sh new file mode 100755 index 00000000..050ea86c --- /dev/null +++ b/scripts/git-release.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -e + +BRANCH=$(git rev-parse --abbrev-ref HEAD) + +yarn run lerna version --conventional-prerelease --preid from-git --no-git-tag-version --no-push --allow-branch $BRANCH --yes +git add . +git commit -m "Publish to git" + +for DIR in $(yarn run -s lerna changed --parseable); do + ( + VERSION=$(cat "${DIR}/package.json" | jq -r '.version') + NAME=$(cat "${DIR}/package.json" | jq -r '.name') + + ( + cd "$DIR" + yarn run prepublishOnly + ) + yarn run npm-publish-git --dir "$DIR" --tag "${NAME}/${BRANCH}/${VERSION}" + ) +done diff --git a/yarn.lock b/yarn.lock index 6e534538..43de92f8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6900,6 +6900,10 @@ npm-pick-manifest@^3.0.0: npm-package-arg "^6.0.0" semver "^5.4.1" +"npm-publish-git@git://github.com/hedgepigdaniel/npm-publish-git.git": + version "0.0.10" + resolved "git://github.com/hedgepigdaniel/npm-publish-git.git#c6ebdd98043ad0b014e537d95a00004ec0951486" + npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f"