-
Notifications
You must be signed in to change notification settings - Fork 33
246 lines (222 loc) · 9.5 KB
/
build-publish.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
name: Build and Publish
# This workflow is triggered on pushes to the main branch, pull requests and manual triggers
# 1. version - An initial step to be used by other steps - bumps the version code and string based on the run number and package.json
# 2. android - Builds the Android app and uploads it to Google Play (if requested)
# 3. docker - Builds the Docker image and pushes it to GitHub Container Registry
# 4. ios - Builds the iOS app and uploads it to App Store (if requested)
# 5. github-release - Tags the commit and creates a Github release with the apps' binaries (if requested)
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
inputs:
publishandroid:
description: 'Publish to Google play'
required: false
default: 'false'
publishios:
description: 'Publish to App Store'
required: false
default: 'false'
tag:
description: 'Tags and create a Github release'
required: false
default: 'false'
jobs:
version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: '20.12'
- name: Get version
uses: bbonkr/get-version-action@v1
id: get-version
with:
project: 'IsraelHiking.Web/package.json'
- name: Set version code and string
id: version-code
env:
MAJOR: ${{ steps.get-version.outputs.major }}
MINOR: ${{ steps.get-version.outputs.minor }}
PATCH: ${{ github.run_number }}
run: |
version_string=$MAJOR.$MINOR.$(($PATCH % 1000))
echo "version_code=$(($MAJOR * 100000 + $MINOR * 1000 + $PATCH % 1000))" >> $GITHUB_OUTPUT
echo "version_string=$version_string" >> $GITHUB_OUTPUT
echo "Version: $version_string" >> $GITHUB_STEP_SUMMARY
outputs:
version_code: ${{ steps.version-code.outputs.version_code }}
version_string: ${{ steps.version-code.outputs.version_string }}
android:
runs-on: ubuntu-latest
needs: version
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: '20.12'
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Bump versions in gradle
uses: chkfung/[email protected]
with:
gradlePath: IsraelHiking.Web/android/app/build.gradle
versionCode: ${{ needs.version.outputs.version_code }}
versionName: ${{ needs.version.outputs.version_string }}
- name: Build UI
run: |
cd IsraelHiking.Web
npm ci
npm run build:mobile -- --no-progress
npx cap sync android
- name: Build Android
run: |
cd IsraelHiking.Web/android
./gradlew :app:bundleRelease "-Pandroid.injected.signing.store.file=$WORKSPACE/IsraelHiking.Web/signing/IHM.jks" "-Pandroid.injected.signing.store.password=$STORE_PASSWORD" "-Pandroid.injected.signing.key.alias=ihmkey" "-Pandroid.injected.signing.key.password=$PASSWORD"
#./gradlew --no-daemon bundleRelease
env:
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
PASSWORD: ${{ secrets.PASSWORD }}
WORKSPACE: ${{ github.workspace }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: IHM_signed_${{ needs.version.outputs.version_string }}.aab
path: IsraelHiking.Web/android/app/build/outputs/bundle/release/app-release.aab
- name: Publish to Google Play
if: ${{ github.event.inputs.publishandroid == 'true' }}
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}
packageName: il.org.osm.israelhiking
releaseFiles: IsraelHiking.Web/android/app/build/outputs/bundle/release/app-release.aab
track: internal
docker:
runs-on: ubuntu-latest
needs: version
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
run: |
docker build . -t ghcr.io/israelhikingmap/website:$VERSION --build-arg VERSION=$VERSION
docker push ghcr.io/israelhikingmap/website:$VERSION
env:
VERSION: ${{ needs.version.outputs.version_string }}
ios:
runs-on: macos-14
needs: version
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: '20.12'
- name: Setup xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 15.2
- name: setup-cocoapods
uses: maxim-lobanov/setup-cocoapods@v1
with:
podfile-path: IsraelHiking.Web/ios/App/Podfile.lock
- name: Keychain setup
run: |
cd IsraelHiking.Web
openssl aes-256-cbc -pbkdf2 -k $PASSWORD -in ./signing/CI.mobileprovision.enc -d -a -out ./signing/CI.mobileprovision
openssl aes-256-cbc -pbkdf2 -k $PASSWORD -in ./signing/ihm-dist.cer.enc -d -a -out ./signing/ihm-dist.cer
openssl aes-256-cbc -pbkdf2 -k $PASSWORD -in ./signing/ihm-dist.p12.enc -d -a -out ./signing/ihm-dist.p12
security create-keychain -p CI ios-build.keychain
security default-keychain -s ios-build.keychain
security unlock-keychain -p CI ios-build.keychain
security set-keychain-settings -t 3600 -l ~/Library/Keychains/ios-build.keychain
security import ./signing/apple.cer -k ~/Library/Keychains/ios-build.keychain -T /usr/bin/codesign
security import ./signing/ihm-dist.cer -k ~/Library/Keychains/ios-build.keychain -T /usr/bin/codesign
security import ./signing/ihm-dist.p12 -k ~/Library/Keychains/ios-build.keychain -P $STORE_PASSWORD -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k CI ~/Library/Keychains/ios-build.keychain > /dev/null
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp ./signing/CI.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/
env:
PASSWORD: ${{ secrets.PASSWORD }}
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
- name: Build UI
run: |
cd IsraelHiking.Web
npm ci
npm run build:mobile -- --no-progress
npx cap sync ios
- name: Update Info.plist with build version
uses: damienaicheh/[email protected]
with:
info-plist-path: "./IsraelHiking.Web/ios/App/App/Info.plist"
bundle-short-version-string: ${{ needs.version.outputs.version_string }}
bundle-version: ${{ needs.version.outputs.version_string }}
- name: Build iOS
run: |
cd IsraelHiking.Web/ios
xcodebuild -workspace App/App.xcworkspace -scheme App -archivePath App.xcarchive -configuration Release -destination generic/platform=iOS archive -quiet
echo "Exporting archive"
xcodebuild -exportArchive -archivePath App.xcarchive -exportPath ./ -exportOptionsPlist exportOptions.plist
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: IHM_signed_${{ needs.version.outputs.version_string }}.ipa
path: IsraelHiking.Web/ios/App.ipa
- name: Publish to App Store
if: ${{ github.event.inputs.publishios == 'true' }}
run: |
cd IsraelHiking.Web/ios
xcrun altool --upload-app --type ios --file ./App.ipa --username $APPLE_APPSTORE_USER --password $APPLE_APPSTORE_PASSWORD
env:
APPLE_APPSTORE_USER: ${{ secrets.APPLE_APPSTORE_USER }}
APPLE_APPSTORE_PASSWORD: ${{ secrets.APPLE_APPSTORE_PASSWORD }}
github-release:
if: ${{ github.event.inputs.tag == 'true' }}
runs-on: ubuntu-latest
needs: [version, ios, android]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Tag commit and push
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ needs.version.outputs.version_string }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/artifacts
merge-multiple: true
- name: Rename artifacts
run: |
mv ${{ github.workspace }}/artifacts/*.ipa ${{ github.workspace }}/IHM_signed_${{ needs.version.outputs.version_string }}.ipa
mv ${{ github.workspace }}/artifacts/*.aab ${{ github.workspace }}/IHM_signed_${{ needs.version.outputs.version_string }}.aab
- name: Create release
uses: softprops/action-gh-release@v2
with:
draft: true
tag_name: v${{ needs.version.outputs.version_string }}
name: v${{ needs.version.outputs.version_string }}
token: ${{ secrets.GITHUB_TOKEN }}
files: |
IHM_signed_${{ needs.version.outputs.version_string }}.ipa
IHM_signed_${{ needs.version.outputs.version_string }}.aab