Skip to content

Commit ffe1307

Browse files
committed
feat(bundle): add script to push bundles to code.angularjs.org
Copied over from angular js 1.x.
1 parent f0d0fe0 commit ffe1307

File tree

3 files changed

+403
-0
lines changed

3 files changed

+403
-0
lines changed

tools/code.angularjs.org/publish.sh

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/bash
2+
3+
# Script for updating code.angularjs.org repo from current local build.
4+
5+
echo "#################################"
6+
echo "## Update code.angularjs.org ###"
7+
echo "#################################"
8+
9+
ARG_DEFS=(
10+
"--action=(prepare|publish)"
11+
"--version-number=([0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?)"
12+
)
13+
14+
function init {
15+
TMP_DIR=$(resolveDir ../../tmp)
16+
BUILD_DIR=$(resolveDir ../../dist/bundle)
17+
REPO_DIR=$TMP_DIR/code.angularjs.org
18+
# TODO: replace with version read from the bundle dir.
19+
NEW_VERSION=$VERSION_NUMBER
20+
if [[ "$NEW_VERSION" =~ sha ]]; then
21+
IS_SNAPSHOT_BUILD=true
22+
else
23+
IS_SNAPSHOT_BUILD=
24+
fi
25+
}
26+
27+
function prepare {
28+
29+
echo "-- Cloning code.angularjs.org"
30+
git clone git@github.com:angular/code.angularjs.org.git $REPO_DIR --depth=1
31+
32+
echo "-- Updating code.angularjs.org"
33+
34+
if [[ $IS_SNAPSHOT_BUILD ]]; then
35+
#
36+
# update the snapshot folder
37+
#
38+
rm -rf $REPO_DIR/snapshot-angular2/
39+
mkdir $REPO_DIR/snapshot-angular2
40+
cp -r $BUILD_DIR/* $REPO_DIR/snapshot-angular2/
41+
else
42+
#
43+
# copy the files from the build
44+
#
45+
mkdir $REPO_DIR/$NEW_VERSION
46+
cp -r $BUILD_DIR/* $REPO_DIR/$NEW_VERSION/
47+
fi
48+
49+
#
50+
# commit
51+
#
52+
echo "-- Committing code.angularjs.org"
53+
cd $REPO_DIR
54+
git add -A
55+
git commit -m "v$NEW_VERSION"
56+
}
57+
58+
59+
function _update_code() {
60+
cd $REPO_DIR
61+
62+
echo "-- Pushing code.angularjs.org"
63+
git push origin master
64+
65+
for backend in "$@" ; do
66+
echo "-- Refreshing code.angularjs.org: backend=$backend"
67+
curl http://$backend:8003/gitFetchSite.php
68+
done
69+
}
70+
71+
function publish {
72+
# The TXT record for backends.angularjs.org is a CSV of the IP addresses for
73+
# the currently serving Compute Engine backends.
74+
# code.angularjs.org is served out of port 8003 on these backends.
75+
backends=("$(dig backends.angularjs.org +short TXT | python -c 'print raw_input()[1:-1].replace(",", "\n")')")
76+
_update_code ${backends[@]}
77+
}
78+
79+
source $(dirname $0)/../utils.inc

tools/code.angularjs.org/unpublish.sh

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
# Script for removing specified release dir from code.angularjs.org.
4+
5+
echo "################################################"
6+
echo "## Remove a version from code.angular.js.org ###"
7+
echo "################################################"
8+
9+
ARG_DEFS=(
10+
"--action=(prepare|publish)"
11+
"--version-number=([0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?)"
12+
)
13+
14+
function init {
15+
TMP_DIR=$(resolveDir ../../tmp)
16+
REPO_DIR=$TMP_DIR/code.angularjs.org
17+
echo "code tmp $TMP_DIR"
18+
}
19+
20+
function prepare {
21+
echo "-- Cloning code.angularjs.org"
22+
git clone git@github.com:angular/code.angularjs.org.git $REPO_DIR
23+
24+
#
25+
# Remove the files from the repo
26+
#
27+
echo "-- Removing $VERSION_NUMBER from code.angularjs.org"
28+
cd $REPO_DIR
29+
if [ -d "$VERSION_NUMBER" ]; then
30+
git rm -r $VERSION_NUMBER
31+
echo "-- Committing removal to code.angularjs.org"
32+
git commit -m "removing v$VERSION_NUMBER"
33+
else
34+
echo "-- Version: $VERSION_NUMBER does not exist in code.angularjs.org!"
35+
fi
36+
}
37+
38+
function publish {
39+
cd $REPO_DIR
40+
41+
echo "-- Pushing code.angularjs.org to github"
42+
git push origin master
43+
}
44+
45+
source $(dirname $0)/../utils.inc

0 commit comments

Comments
 (0)