-
Notifications
You must be signed in to change notification settings - Fork 3
195 lines (165 loc) · 7.6 KB
/
release-client.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
name: Release Client
on:
push:
tags:
- 'client.*'
env:
# GCS_BUCKET is the name of the Google Cloud Storage bucket to which all artifacts are deployed.
GCS_BUCKET: mitbattlecode-releases
# CLIENT_ARTIFACT_ID is the name of the base client artifact produced by the buildsystem.
CLIENT_ARTIFACT_ID: battlecode25
# IS_PUBLIC is whether to release deployments publicly. Set to exactly the text "YES" to do so.
IS_PUBLIC: YES
jobs:
build-client:
name: Build client
permissions:
contents: read
id-token: write
strategy:
matrix:
include:
- platform-name: "macos-latest"
build-name: "macos"
tauri-target: "universal-apple-darwin"
tauri-copy-path: "bundle/macos/*.app"
electron-module-name: "UNUSED"
- platform-name: "ubuntu-latest"
build-name: "linux"
tauri-target: "x86_64-unknown-linux-gnu"
tauri-copy-path: "bundle/appimage/*.AppImage"
electron-module-name: "linux-x64-gnu.node"
upload-dist: true
- platform-name: "windows-latest"
build-name: "windows"
tauri-target: "x86_64-pc-windows-msvc"
tauri-copy-path: "*.exe"
electron-module-name: "win32-x64-msvc.node"
runs-on: ${{ matrix.platform-name }}
env:
TAURI_OUTPUT: ./src-tauri/target/${{ matrix.tauri-target }}/release/${{ matrix.tauri-copy-path }}
TAURI_BUILD_COMMAND: npm run tauri-pack -- -t ${{ matrix.tauri-target }}
ELECTRON_BUILD_COMMAND: npx cross-env ELECTRON_MODULE_NAME=${{ matrix.electron-module-name }} npm run electron-pack
steps:
- name: Checkout branch
uses: actions/checkout@v3
- name: Set up Node 18
uses: actions/setup-node@v3
with:
node-version: 18
# Rust toolchain is preinstalled on runner images, but we need to add the x86
# toolchain on macos to compile universal apps from the M1 runner
- name: Install macos dependencies
if: startsWith(matrix.platform-name, 'macos')
run: |
rustup target add x86_64-apple-darwin
npm install @tauri-apps/[email protected]
- name: Install linux dependencies
if: startsWith(matrix.platform-name, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.0-dev build-essential wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
npm install @tauri-apps/[email protected]
- name: Install windows dependencies
if: startsWith(matrix.platform-name, 'windows')
run: npm install @tauri-apps/[email protected]
- name: Install schema
run: npm install
working-directory: ./schema
- name: Install client
run: npm install
working-directory: ./client
- name: Build client webpack
run: npm run build
working-directory: ./client
- name: Compile electron modules
run: npm run electron-compile-modules
working-directory: ./client
# Specially compile x86 electron modules to be included in universal build
- name: Compile (extra) electron modules
if: startsWith(matrix.platform-name, 'macos')
run: RUST_TARGET=x86_64-apple-darwin npm run electron-compile-modules
working-directory: ./client
- name: Build client applications
run: npm run concurrently -- --kill-others-on-fail "${{ env.ELECTRON_BUILD_COMMAND }}" "${{ env.TAURI_BUILD_COMMAND }}"
working-directory: ./client
# 7-zip is preinstalled on runner images
- name: Zip tauri result
run: 7z a packaged-client/tauri-output.zip "${{ env.TAURI_OUTPUT }}"
working-directory: ./client
# Only need to create this artifact on one job since all platforms produce
# the same result
- name: Upload dist files artifact
if: matrix.upload-dist
uses: actions/upload-artifact@v3
with:
name: client-dist
path: ./client/dist
- name: Upload client artifact
uses: actions/upload-artifact@v3
with:
name: client-${{ matrix.build-name }}
path: |
./client/packaged-client/*-output.zip
release:
name: Release
runs-on: ubuntu-latest
needs: build-client
permissions:
contents: read
id-token: write
actions: write # To cleanup artifacts
steps:
- name: Checkout branch
uses: actions/checkout@v3
- name: Inject release version
run: |
release_version=${GITHUB_REF#refs/*/}
release_version=${release_version#client.}
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
echo "The release version is $release_version"
- name: Authenticate to Google Cloud Platform
uses: google-github-actions/auth@v1
with:
create_credentials_file: true
workload_identity_provider: projects/830784087321/locations/global/workloadIdentityPools/releases/providers/github-workflow
service_account: [email protected]
- name: Set up Google Cloud SDK
uses: 'google-github-actions/setup-gcloud@v1'
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 21
distribution: adopt
- name: Download all client artifacts
uses: actions/download-artifact@v3
with:
path: ./client/artifacts
# Always cleanup even if other commands failed so we don't unnecessarily store
# the artifacts in the cloud
- name: Cleanup client artifacts
uses: geekyeggo/delete-artifact@54ab544f12cdb7b71613a16a2b5a37a9ade990af
if: always()
with:
name: client-*
- name: Determine access control
run: |
[[ "$IS_PUBLIC" = "YES" ]] && acl="public-read" || acl="project-private"
echo "OBJECT_ACL=$acl" >> $GITHUB_ENV
echo "Objects will be uploaded with ACL $acl"
- name: Publish to local repository
run: |
id_base=${CLIENT_ARTIFACT_ID}-client
path_base=client/artifacts/client
./gradlew publishClientPublicationToMavenLocal -Prelease_version=$RELEASE_VERSION -Partifact_id=${id_base}-win-tauri -Partifact_path=${path_base}-windows/tauri-output.zip
./gradlew publishClientPublicationToMavenLocal -Prelease_version=$RELEASE_VERSION -Partifact_id=${id_base}-mac-tauri -Partifact_path=${path_base}-macos/tauri-output.zip
./gradlew publishClientPublicationToMavenLocal -Prelease_version=$RELEASE_VERSION -Partifact_id=${id_base}-linux-tauri -Partifact_path=${path_base}-linux/tauri-output.zip
./gradlew publishClientPublicationToMavenLocal -Prelease_version=$RELEASE_VERSION -Partifact_id=${id_base}-win-electron -Partifact_path=${path_base}-windows/electron-output.zip
./gradlew publishClientPublicationToMavenLocal -Prelease_version=$RELEASE_VERSION -Partifact_id=${id_base}-mac-electron -Partifact_path=${path_base}-macos/electron-output.zip
./gradlew publishClientPublicationToMavenLocal -Prelease_version=$RELEASE_VERSION -Partifact_id=${id_base}-linux-electron -Partifact_path=${path_base}-linux/electron-output.zip
- name: Upload maven artifacts to remote repository
run: gsutil -m rsync -a $OBJECT_ACL -r $HOME/.m2/repository/org/battlecode gs://$GCS_BUCKET/maven/org/battlecode
- name: Upload web client
run: |
gsutil -m rsync -r -a $OBJECT_ACL ./client-dist gs://$GCS_BUCKET/client/$CLIENT_ARTIFACT_ID/$RELEASE_VERSION
working-directory: ./client/artifacts