-
Notifications
You must be signed in to change notification settings - Fork 5
/
publish.sh
executable file
·67 lines (56 loc) · 2.13 KB
/
publish.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
set -e
my_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
oldVersion=$(node -p "require('./package.json').version")
pkgVersion=$(cat ./next-version.txt)
branch=$1
npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN"
echo "Old version: $oldVersion"
echo "Publishing version $pkgVersion - $branch"
echo "pkgVersion: $pkgVersion"
npm version $pkgVersion --no-git-tag-version --allow-same-version --no-commit-hooks --workspace-update=false
npx lerna version $pkgVersion --no-git-tag-version --no-push --yes
echo "Package version updated to $pkgVersion"
echo "-----------------------------------"
# replace old versions in files
find . -type f \( -name '*.js' -or -name '*.ts' -or -name '*.tsx' -or -name '*.json' -or -name 'README.md' \) -not -path '*node_modules*' -not -path '*.next*' -exec grep -l "$oldVersion" {} \; | xargs perl -pi -e "s/$oldVersion/$pkgVersion/g"
# test main packages cli and runtime
yarn install --frozen-lockfile --ignore-scripts
yarn buildall
yarn test
#
# yarn examplecli
## todo fix this by hoisting the repo https://github.com/graphql-compose/graphql-compose-examples/tree/master/examples/northwind
## testing other packages
# todo fix "example-usage" "try-clients" remote server hasura apps
#allPkgs=( "integration-tests" )
#for pkg in "${allPkgs[@]}"
#do
# echo "-----------------------------------"
# echo "Building and Testing $pkg"
# cd $my_dir/demo-apps/$pkg
# yarn install --frozen-lockfile --ignore-scripts
# yarn build
# yarn gen
# yarn test
#done
cd $my_dir
echo "Updating repo..."
command cp -rf CHANGELOG.md LICENSE README.md $my_dir/runtime/
command cp -rf CHANGELOG.md LICENSE README.md $my_dir/cli/
git add .
git commit -m "chore(release): update packages to $pkgVersion [skip ci]"
if [[ $branch == "master" ]]; then
git pull origin $branch --ff-only
git push
echo "Repo pushed."
fi
cd $my_dir/runtime
runtimeVersion=$(node -p -e "require('./package.json').version")
echo "runtimeVersion: $runtimeVersion"
npm publish --access public
cd $my_dir/cli
cliVersion=$(node -p -e "require('./package.json').version")
echo "cliVersion: $cliVersion"
npm publish --access public
echo "Done."