forked from appsmithorg/appsmith
-
Notifications
You must be signed in to change notification settings - Fork 0
273 lines (226 loc) · 9.27 KB
/
github-release.yml
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
name: Appsmith Github Release Workflow
# This workflow builds Docker images for server and client, and then pushes them to Docher Hub.
# The docker-tag with which this push happens in the release tag (e.g., v1.2.3 etc.).
# In addition to the above tag, unless the git-tag matches `*beta*`, we also push to the `latest` docker-tag.
# This workflow does NOT run tests.
# This workflow is automatically triggered when a relese is created on GitHub.
on:
# Ref: <https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#release>.
release:
types:
# Unlike the `released` event, the `published` event triggers for pre-releases as well.
- released
jobs:
prelude:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.get_version.outputs.tag }}
is_beta: ${{ steps.get_version.outputs.is_beta }}
steps:
- name: Environment details
run: |
echo "PWD: $PWD"
echo "GITHUB_REF: $GITHUB_REF"
echo "GITHUB_SHA: $GITHUB_SHA"
echo "GITHUB_EVENT_NAME: $GITHUB_EVENT_NAME"
- name: Get the version
id: get_version
run: |
tag="${GITHUB_REF#refs/tags/}"
echo "::set-output name=tag::$tag"
if [[ $tag == *"beta"* ]]; then
echo "::set-output name=is_beta::true"
else
echo "::set-output name=is_beta::false"
fi
buildClient:
needs:
- prelude
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/client
shell: bash
steps:
# Checkout the code
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js 14.15.4
uses: actions/setup-node@v1
with:
node-version: "14.15.4"
# Retrieve npm dependencies from cache. After a successful run, these dependencies are cached again
- name: Cache npm dependencies
uses: actions/cache@v2
env:
cache-name: cache-yarn-dependencies
with:
# npm dependencies are stored in `~/.m2` on Linux/macOS
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install dependencies
run: yarn install
- name: Create the bundle
env:
REACT_APP_ENVIRONMENT: 'PRODUCTION'
REACT_APP_FUSIONCHARTS_LICENSE_KEY: '${{ secrets.APPSMITH_FUSIONCHARTS_LICENSE_KEY }}'
REACT_APP_SEGMENT_CE_KEY: '${{ secrets.APPSMITH_SEGMENT_CE_KEY }}'
REACT_APP_VERSION_ID: '${{ needs.prelude.outputs.tag }}'
REACT_APP_INTERCOM_APP_ID: '${{ secrets.APPSMITH_INTERCOM_ID }}'
run: |
REACT_APP_VERSION_RELEASE_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" \
yarn build
ls -l build
# Upload the build artifact so that it can be used by the test & deploy job in the workflow
- name: Upload react build bundle
uses: actions/upload-artifact@v2
with:
name: client-build
path: app/client/build/
buildServer:
needs:
- prelude
defaults:
run:
working-directory: app/server
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK 1.11
uses: actions/setup-java@v1
with:
java-version: "11.0.10"
# Retrieve maven dependencies from cache. After a successful run, these dependencies are cached again
- name: Cache maven dependencies
uses: actions/cache@v2
env:
cache-name: cache-maven-dependencies
with:
# maven dependencies are stored in `~/.m2` on Linux/macOS
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Test and Build package
working-directory: app/server
run: |
mvn --batch-mode versions:set \
-DnewVersion=${{ needs.prelude.outputs.tag }} \
-DgenerateBackupPoms=false \
-DprocessAllModules=true
./build.sh -DskipTests
ls -l dist
- name: Upload server build bundle
uses: actions/upload-artifact@v2
with:
name: server-build
path: app/server/dist/
buildRts:
needs:
- prelude
defaults:
run:
working-directory: app/rts
runs-on: ubuntu-latest
steps:
# Checkout the code
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js 14.15.4
uses: actions/setup-node@v1
with:
node-version: "14.15.4"
- name: Build
run: |
./build.sh
ls -l dist
# Upload the build artifact so that it can be used by the test & deploy job in the workflow
- name: Upload RTS build bundle
uses: actions/upload-artifact@v2
with:
name: rts-build
path: app/rts/dist/
- name: Upload RTS dependencies bundle
uses: actions/upload-artifact@v2
with:
name: rts-build-deps
path: app/rts/node_modules/
package:
needs: [prelude, buildClient, buildServer, buildRts]
runs-on: ubuntu-latest
steps:
- name: Checkout the merged commit from PR and base branch
uses: actions/checkout@v2
- name: Download the client build artifact
uses: actions/download-artifact@v2
with:
name: client-build
path: app/client/build
- name: Download the server build artifact
uses: actions/download-artifact@v2
with:
name: server-build
path: app/server/dist
- name: Download the rts build artifact
uses: actions/download-artifact@v2
with:
name: rts-build
path: app/rts/dist
- name: Download the rts dependencies artifact
uses: actions/download-artifact@v2
with:
name: rts-build-deps
path: app/rts/node_modules/
- name: Build and push client image
working-directory: app/client
run: |
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
docker build -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:${{needs.prelude.outputs.tag}} .
docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:${{needs.prelude.outputs.tag}}
# Only build & tag with latest if the tag doesn't contain beta
if [[ ! ${{needs.prelude.outputs.tag}} == *"beta"* ]]; then
docker build -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:latest .
docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:latest
fi
- name: Build and push server image
working-directory: app/server
run: |
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
docker build --build-arg APPSMITH_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }} -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:${{needs.prelude.outputs.tag}} .
docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:${{needs.prelude.outputs.tag}}
# Only build & tag with latest if the tag doesn't contain beta
if [[ ! ${{needs.prelude.outputs.tag}} == *"beta"* ]]; then
docker build --build-arg APPSMITH_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }} -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:latest .
docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:latest
fi
- name: Build and push RTS image
working-directory: app/rts
run: |
docker build -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-rts:${{needs.prelude.outputs.tag}} .
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-rts:${{needs.prelude.outputs.tag}}
# Only build & tag with latest if the tag doesn't contain beta
if [[ ! ${{needs.prelude.outputs.tag}} == *"beta"* ]]; then
docker build -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-rts:latest .
docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-rts:latest
fi
- name: Build and push fat image
run: |
docker build \
--build-arg APPSMITH_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }} \
--tag ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-ce:${{needs.prelude.outputs.tag}} \
.
# Only build & tag with latest if the tag doesn't contain beta
if [[ ! ${{needs.prelude.outputs.tag}} == *"beta"* ]]; then
docker build --tag ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-ce:latest .
docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-ce:latest
fi
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
docker push --all-tags ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-ce