forked from ajv-validator/ajv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish-bundles
executable file
·37 lines (26 loc) · 1004 Bytes
/
publish-bundles
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
#!/usr/bin/env bash
set -e
if [[ $GITHUB_REF == refs/tags/v* ]]; then
npm run bundle
echo "About to publish $GITHUB_REF to ajv-dist..."
git config --global user.name "$GIT_USER_NAME"
git config --global user.email "$GIT_USER_EMAIL"
git clone https://"${GH_TOKEN_PUBLIC}"@github.com/ajv-validator/ajv-dist.git ../ajv-dist
rm -rf ../ajv-dist/dist
mkdir ../ajv-dist/dist
cp ./bundle/*.* ../ajv-dist/dist
cd ../ajv-dist
VERSION=${GITHUB_REF#refs/tags/v}
sed -E "s/\"version\": \"([^\"]*)\"/\"version\": \"$VERSION\"/" package.json > new_package.json
mv new_package.json package.json
if [[ $(git status --porcelain) ]]; then
echo "Changes detected. Updating master branch..."
git add -A
git commit -m "$VERSION: updated by ajv workflow https://github.com/ajv-validator/ajv/actions/runs/$GITHUB_RUN_ID"
git push --quiet origin master > /dev/null 2>&1
fi
echo "Publishing tag..."
git tag "v$VERSION"
git push --tags > /dev/null 2>&1
echo "Done"
fi