Skip to content

Commit b4f169b

Browse files
authored
feat(infra): Add release script (#4582)
1 parent f217939 commit b4f169b

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

release.sh

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#! /bin/bash
2+
3+
#
4+
# Uncomment the appropriate line below to publish to the correct Heroku app
5+
#
6+
# HEROKU_APP_NAME=core-patch-doc-site
7+
# HEROKU_APP_NAME=core-main-doc-site
8+
# HEROKU_APP_NAME=upcoming-doc-site
9+
# HEROKU_APP_NAME=design-system-site-prod
10+
11+
incorrect_selection() {
12+
echo "Incorrect selection! Try again."
13+
}
14+
15+
until [ "$selection" = "0" ]; do
16+
clear
17+
echo "Where would you like to publish?"
18+
echo ""
19+
echo " 1 - Upcoming"
20+
echo " 2 - Core patch"
21+
echo " 3 - Core main"
22+
echo " 4 - Production"
23+
echo " 0 - Exit"
24+
echo ""
25+
echo -n " Enter selection: "
26+
read selection
27+
echo ""
28+
case $selection in
29+
1 ) clear ; HEROKU_APP_NAME=upcoming-doc-site ; robots_index=false ; break ;;
30+
2 ) clear ; HEROKU_APP_NAME=core-patch-doc-site ; robots_index=false ; break ;;
31+
3 ) clear ; HEROKU_APP_NAME=core-main-doc-site ; robots_index=false ; break ;;
32+
4 ) clear ; HEROKU_APP_NAME=design-system-site-prod ; robots_index=true ; break ;;
33+
0 ) clear ; exit ;;
34+
* ) clear ; incorrect_selection ;;
35+
esac
36+
done
37+
38+
#
39+
# Do some cleanup & prep
40+
#
41+
rm -rf .dist/
42+
rm -rf __release/
43+
mkdir -p __release/
44+
45+
#
46+
# Update CanIUse database
47+
#
48+
npx browserslist@latest --update-db
49+
50+
#
51+
# Build framework
52+
#
53+
npm run build-dist
54+
55+
# # tar -cvf design-system-dist.tar .dist/
56+
# cd .dist && zip -r dist . && mv dist.zip ../ && cd ..
57+
58+
#
59+
# Tweak postcss.config.js file to remove deprecated syntax
60+
# :: not modifying file permanently until we fully migrate
61+
#
62+
sed -i.bak 's/require(\(.*\))/\1/' postcss.config.js
63+
64+
#
65+
# Change directory for site build
66+
#
67+
cd __release
68+
69+
# Clone site repository, main branch HEAD
70+
git clone --single-branch --branch main [email protected]:salesforce-ux/design-system-site.git .
71+
72+
#
73+
# Update CanIUse database
74+
#
75+
npx browserslist@latest --update-db
76+
77+
# perform Node modules install
78+
npm ci --prefer-offline
79+
80+
# Create directories for assets
81+
mkdir -p assets/styles
82+
mkdir -p .generated/metadata
83+
84+
# Copy necessary files from framework
85+
cp -R ../design-tokens design-tokens
86+
cp -R ../design-tokens ../.dist/
87+
cp -R ../assets/styles assets/styles
88+
cp -R ../.generated/metadata .generated/metadata
89+
90+
#
91+
# Build static site
92+
SLDS__FRAMEWORK__PATH=../.dist SLDS__ROBOTS__INDEX=${robots_index} npm run build # when releasing to public site we enable indexing
93+
94+
# Create tarball of site
95+
tar -czf site-release.tar.gz .www/ Procfile app.json config/nginx.conf.erb heroku-start.sh
96+
97+
# install the needed Heroku CLI plugin (https://github.com/heroku/heroku-builds)
98+
heroku plugins:install heroku-builds
99+
100+
# Install nginx buildpack if not already present in Heroku app
101+
# heroku buildpacks -a ${HEROKU_APP_NAME} | grep "https://github.com/salesforce-ux/heroku-buildpack-nginx.git#dse" || heroku buildpacks:set https://github.com/salesforce-ux/heroku-buildpack-nginx.git#dse -a ${HEROKU_APP_NAME}
102+
# Publish the tarball to the Heroku app
103+
heroku builds:create --source-tar site-release.tar.gz -a ${HEROKU_APP_NAME}
104+
105+
# Exit back to parent directory and clean-up after ourselves
106+
cd ..
107+
# rm -rf __release/

0 commit comments

Comments
 (0)