-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (173 loc) · 7.09 KB
/
ci.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
name: CI
on:
push:
branches: [ci]
permissions: {}
env:
API_DOMAIN: eternagame.org
NODE_VERSION: 20.x
BUILD_TYPE: prod
jobs:
build-eternajs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
persist-credentials: false
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('./eternajs/package-lock.json') }}
- name: Create GitHub App token for built engine access
uses: actions/create-github-app-token@v1
id: engines-app-token
with:
app-id: ${{ secrets.BUILT_ENGINE_CLIENT_ID }}
private-key: ${{ secrets.BUILT_ENGINE_APP_PRIVATE_KEY }}
owner: eternagame
repositories: eternajs-folding-engines
- name: Set GitHub App token authentication for built engine access
run: git config --global url.https://x-access-token:${{ steps.engines-app-token.outputs.token }}@github.com/eternagame/eternajs-folding-engines.insteadOf ssh://[email protected]/eternagame/eternajs-folding-engines
working-directory: ./eternajs
- name: Install dependencies
run: npm ci
working-directory: ./eternajs
- name: Build
run: npm run build:${{ env.BUILD_TYPE }}
working-directory: ./eternajs
env:
APP_SERVER_URL: https://${{ env.API_DOMAIN }}
MOBILE_APP: true
DEBUG: false
ENGINE_LOCATION: package
# Due to licensed components, we don't want the intermediate build of EternaJS available for download
- name: Encrypt build
run: gpgtar --encrypt --output eternajs --symmetric --gpg-args "--passphrase ${{ secrets.ARTIFACT_ENCRYPTION_KEY }} --batch" *
working-directory: ./eternajs/dist/prod
- name: Upload build
uses: actions/upload-artifact@v4
with:
name: eternajs
path: ./eternajs/dist/prod/eternajs
build-wrapper:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Build
run: npm run build:${{ env.BUILD_TYPE }}
env:
PARALLEL_BUILD: true
APP_SERVER_URL: https://${{ env.API_DOMAIN }}
INJECT_COOKIE_DOMAIN: .${{ env.API_DOMAIN }}
- name: Upload build
uses: actions/upload-artifact@v4
with:
name: wrapper
path: ./www
build-app:
needs: [build-eternajs, build-wrapper]
strategy:
fail-fast: false
matrix:
include:
- target: ios
packageType: development
- target: ios
packageType: app-store
- target: android
runs-on: ${{ matrix.target == 'ios' && 'macos-latest' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: wrapper
path: ./www
- uses: actions/download-artifact@v4
with:
name: eternajs
path: ./www
- name: Decrypt eternajs artifact
run: |
gpgtar --decrypt --gpg-args "--passphrase ${{ secrets.ARTIFACT_ENCRYPTION_KEY }} --batch" eternajs
rm eternajs
mv eternajs_1_ eternajs
working-directory: ./www
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('./eternajs/package-lock.json') }}
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Setup cordova platform
run: npx cordova platform add ${{ matrix.target }}
env:
PARALLEL_BUILD: true
- uses: actions/setup-java@v4
if: ${{ matrix.target == 'android' }}
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- name: Build Android
if: ${{ matrix.target == 'android' }}
run: npx cordova build ${{ matrix.target }} --${{ env.BUILD_TYPE == 'prod' && 'release' || 'debug' }} --device
env:
PARALLEL_BUILD: true
- name: Set up signing key
if: ${{ matrix.target == 'ios' }}
env:
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
run: |
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
npm ci
node src/index.js retrieve ${{ matrix.packageType == 'development' && 'IOS_DEVELOPMENT' || 'IOS_DISTRIBUTION' }} ${{ secrets.APP_SIGNING_PRIVATE_KEY_BASE64 }} ${{ secrets.APP_SIGNING_PRIVATE_KEY }} ${{ secrets.APP_STORE_CONNECT_API_KEY_ID }} ${{ secrets.APP_STORE_CONNECT_API_KEY_ISSUER_ID }} $CERTIFICATE_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
working-directory: ./.github/workflows/setup-apple-signing
- name: Set up App Store Connect API key
if: ${{ matrix.target == 'ios' }}
env:
APP_STORE_CONNECT_API_KEY_BASE64: ${{ secrets.APP_STORE_CONNECT_API_KEY_BASE64 }}
run: echo $APP_STORE_CONNECT_API_KEY_BASE64 | base64 --decode > "${{ github.workspace }}/authkey.p8"
- name: Build iOS
if: ${{ matrix.target == 'ios' }}
run: |
npx cordova build ${{ matrix.target }} --${{ env.BUILD_TYPE == 'prod' && 'release' || 'debug' }} --device \
--automaticProvisioning --authenticationKeyPath="${{ github.workspace }}/authkey.p8" \
--authenticationKeyID=${{ secrets.APP_STORE_CONNECT_API_KEY_ID }} --authenticationKeyIssuerID="${{ secrets.APP_STORE_CONNECT_API_KEY_ISSUER_ID }}" \
--developmentTeam="${{ secrets.APP_STORE_CONNECT_TEAM_ID }}" --codeSignIdentity="iPhone ${{ matrix.packageType == 'development' && 'Developer' || 'Distribution' }}" \
--packageType="${{ matrix.packageType }}"
env:
PARALLEL_BUILD: true