-
Notifications
You must be signed in to change notification settings - Fork 4
197 lines (184 loc) · 7.21 KB
/
build.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
name: casanet dashboard app CI CD
on: [push, workflow_dispatch]
env:
SKIP_PREFLIGHT_CHECK: "true"
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Prepare dependencies
run: |
npm i -g yarn
yarn install --frozen-lockfile
- name: Bomb Version # Auto Update patch in main branch
id: bomb_version
if: github.ref == 'refs/heads/main'
run: |
npm run patch_version
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo $PACKAGE_VERSION
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
- name: Commit and push changes # Commit version update
if: github.ref == 'refs/heads/main'
uses: devops-infra/action-commit-push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_message: Bomb version to ${{ steps.bomb_version.outputs.PACKAGE_VERSION }} [ci skip]"
- name: Configure DEV MODE # Set assets to build for DEV mode
if: github.ref != 'refs/heads/main'
run: |
npm run dev_mode
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 11
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Bundle Android APP
env:
REACT_APP_API_URL: '${{ secrets.API_URL }}'
REACT_APP_MOCK_API_URL: '${{ secrets.API_URL_DEMO }}'
REACT_APP_V3_URL: '${{ secrets.V3_URL_APP }}'
REACT_APP_LIGHTWEIGHT_URL: '${{ secrets.LIGHTWEIGHT_URL }}'
CASANET_KEY_STORE: '${{ secrets.CASANET_KEY_STORE }}'
CASANET_KEY_ALIAS: '${{ secrets.CASANET_KEY_ALIAS }}'
CASANET_KEY_PASSWORD: '${{ secrets.CASANET_KEY_PASSWORD }}'
BUILD_PATH: www
run: |
export BRANCH=${GITHUB_REF##*/}
if [[ $BRANCH == 'main' ]]; then export REACT_APP_SHOW_VERSION_COMMIT='false' ; else export REACT_APP_SHOW_VERSION_COMMIT='true'; fi
if [[ $BRANCH == 'main' ]]; then export BUILD_TYPE='release' ; else export BUILD_TYPE='debug'; fi
yarn run build
npm i -g cordova
node scripts/decode-key-store.js
cordova platform add android
cordova build android --$BUILD_TYPE -- --keystore=casanet-key-store.jks --storePassword=$CASANET_KEY_PASSWORD --alias=$CASANET_KEY_ALIAS --password=$CASANET_KEY_PASSWORD --packageType=bundle
cordova build android --$BUILD_TYPE -- --keystore=casanet-key-store.jks --storePassword=$CASANET_KEY_PASSWORD --alias=$CASANET_KEY_ALIAS --password=$CASANET_KEY_PASSWORD --packageType=apk
mkdir android
cp platforms/android/app/build/outputs/bundle/$BUILD_TYPE/app-$BUILD_TYPE.aab android/app-$BUILD_TYPE.aab
cp platforms/android/app/build/outputs/apk/$BUILD_TYPE/app-$BUILD_TYPE.apk android/app-$BUILD_TYPE.apk
- uses: actions/upload-artifact@v3
with:
name: android
path: android
- name: Bundle www # The assets build for the public CDN
env:
BUILD_PATH: www
API_URL_PROD: '${{ secrets.API_URL }}'
API_URL_DEV: '${{ secrets.API_URL_DEV }}'
V3_URL_PROD: '${{ secrets.V3_URL }}'
V3_URL_DEV: '${{ secrets.V3_URL_DEV }}'
LIGHTWEIGHT_URL_PROD: '${{ secrets.LIGHTWEIGHT_URL }}'
LIGHTWEIGHT_URL_DEV: '${{ secrets.LIGHTWEIGHT_URL_DEV }}'
run: |
export BRANCH=${GITHUB_REF##*/}
if [[ $BRANCH == 'main' ]]; then export REACT_APP_API_URL=$API_URL_PROD ; else export REACT_APP_API_URL=$API_URL_DEV; fi
if [[ $BRANCH == 'main' ]]; then export REACT_APP_V3_URL=$V3_URL_PROD ; else export REACT_APP_V3_URL=$V3_URL_DEV; fi
if [[ $BRANCH == 'main' ]]; then export REACT_APP_LIGHTWEIGHT_URL=$LIGHTWEIGHT_URL_PROD ; else export REACT_APP_LIGHTWEIGHT_URL=$LIGHTWEIGHT_URL_DEV; fi
if [[ $BRANCH == 'main' ]]; then export REACT_APP_SHOW_VERSION_COMMIT='false' ; else export REACT_APP_SHOW_VERSION_COMMIT='true'; fi
yarn run build
- uses: actions/upload-artifact@v3
with:
name: www
path: www
- name: Bundle internal # The assets build for the local server, the api server is just ''
env:
REACT_APP_API_URL: ''
REACT_APP_V3_URL: ''
REACT_APP_LIGHTWEIGHT_URL: ''
BUILD_PATH: internal
run: |
export BRANCH=${GITHUB_REF##*/}
if [[ $BRANCH == 'main' ]]; then export REACT_APP_SHOW_VERSION_COMMIT='false' ; else export REACT_APP_SHOW_VERSION_COMMIT='true'; fi
yarn run build
- uses: actions/upload-artifact@v3
with:
name: internal
path: internal
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/download-artifact@master
- name: Install node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Run-Test
run: |
export PORT="9090"
export REACT_APP_MOCK_API_URL="http://localhost:9090"
export REACT_APP_API_URL="http://localhost:9090"
export FRONT_SERVE_PORT="3001"
export BUILD_PATH="temp-e2e"
export REACT_APP_MOCK_MODE="true"
export REACT_APP_LOCAL_DEV="true"
echo "Installing dependencies"
npm i -g yarn
yarn
echo "Preparing mock assets"
npm run prepare_mock
npm run build
echo "Run mock server"
node -v
cd temp-mock/mock-server
node index.js &
cd ../..
node node_modules/http-server/bin/http-server ./temp-e2e -p $FRONT_SERVE_PORT &
echo "Run tests"
npm run test
release:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/download-artifact@master
with:
name: android
path: android
- name: Version Info
id: version_info
# "Build" the release title and text body from the latest pushed commit, then pull the version bombed version for the release version
run: |
title=$(git log -1 --pretty=%B | sed -n '1p')
echo "TITLE=$title" >> $GITHUB_OUTPUT
body=$(git log -1 --pretty=%B | sed 1d)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo "BODY=$body" >> $GITHUB_OUTPUT
git pull
version=$(node -p "require('./package.json').version")
echo "VERSION=$version" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version_info.outputs.VERSION }}
name: ${{ steps.version_info.outputs.TITLE }}
body: ${{ steps.version_info.outputs.BODY }}
draft: false
prerelease: false
files: |
./android/app-release.aab
./android/app-release.apk