Skip to content

Commit 88ac77e

Browse files
Refactor CI
1 parent b81561c commit 88ac77e

File tree

3 files changed

+132
-109
lines changed

3 files changed

+132
-109
lines changed

.github/workflows/release.yml renamed to .github/workflows/release-client.yml

Lines changed: 33 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
name: Release
1+
name: Release Client
22
on:
33
push:
44
tags:
5-
- '*'
5+
- 'client.*'
66

77
env:
88
# GCS_BUCKET is the name of the Google Cloud Storage bucket to which all artifacts are deployed.
99
GCS_BUCKET: mitbattlecode-releases
1010

11-
# RELEASE_ARTIFACT_ID is the name of the Maven artifact produced by the buildsystem.
12-
# Important: you must make sure no ID is a prefix of a different ID. Otherwise, you could
13-
# inadvertently cause unintended episodes to become public.
14-
RELEASE_ARTIFACT_ID: battlecode24
15-
16-
# IS_PUBLIC is whether to release deployments publicly. Set to exactly the text "YES" to do so.
17-
IS_PUBLIC: NO
11+
# CLIENT_ARTIFACT_ID is the name of the base client artifact produced by the buildsystem.
12+
CLIENT_ARTIFACT_ID: battlecode25
1813

1914
jobs:
2015
build-client:
@@ -25,19 +20,19 @@ jobs:
2520
strategy:
2621
matrix:
2722
include:
28-
- platform-name: "macos-latest"
29-
build-name: "macos"
30-
tauri-target: "universal-apple-darwin"
31-
tauri-copy-path: "bundle/macos/*.app"
23+
#- platform-name: "macos-latest"
24+
# build-name: "macos"
25+
# tauri-target: "universal-apple-darwin"
26+
# tauri-copy-path: "bundle/macos/*.app"
3227
- platform-name: "ubuntu-latest"
3328
build-name: "linux"
3429
tauri-target: "x86_64-unknown-linux-gnu"
3530
tauri-copy-path: "bundle/appimage/*.AppImage"
3631
upload-dist: true
37-
- platform-name: "windows-latest"
38-
build-name: "windows"
39-
tauri-target: "x86_64-pc-windows-msvc"
40-
tauri-copy-path: "*.exe"
32+
#- platform-name: "windows-latest"
33+
# build-name: "windows"
34+
# tauri-target: "x86_64-pc-windows-msvc"
35+
# tauri-copy-path: "*.exe"
4136
runs-on: ${{ matrix.platform-name }}
4237
env:
4338
TAURI_OUTPUT: ./src-tauri/target/${{ matrix.tauri-target }}/release/${{ matrix.tauri-copy-path }}
@@ -65,7 +60,7 @@ jobs:
6560
if: startsWith(matrix.platform-name, 'ubuntu')
6661
run: |
6762
sudo apt-get update
68-
sudo apt-get install -y libwebkit2gtk-4.0-dev build-essential wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
63+
sudo apt-get install -y libwebkit2gtk-4.0-37 build-essential wget libssl-dev libgtk-3-0 libayatana-appindicator3-dev librsvg2-dev
6964
npm install @tauri-apps/cli-linux-x64-gnu
7065
7166
- name: Install windows dependencies
@@ -135,6 +130,7 @@ jobs:
135130
- name: Inject release version
136131
run: |
137132
release_version=${GITHUB_REF#refs/*/}
133+
release_version=${release_version#client.}
138134
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
139135
echo "The release version is $release_version"
140136
@@ -148,28 +144,6 @@ jobs:
148144
- name: Set up Google Cloud SDK
149145
uses: 'google-github-actions/setup-gcloud@v1'
150146

151-
- name: Clone private maps
152-
if: ${{ env.IS_PUBLIC != 'YES' }}
153-
uses: actions/checkout@v3
154-
with:
155-
repository: battlecode/private-maps
156-
token: ${{ secrets.CI_REPOSITORY_CLONE_PAT }}
157-
path: private-maps
158-
159-
- name: Inject private maps
160-
if: ${{ env.IS_PUBLIC != 'YES' }}
161-
run: |
162-
source="private-maps/$RELEASE_ARTIFACT_ID"
163-
dest="engine/src/main/battlecode/world/resources"
164-
if [ -d "$source" ]; then
165-
cp -r -i "$source/." "$dest/" < /dev/null &> private-maps-copy-log
166-
if [ -s "private-maps-copy-log" ]; then
167-
echo "FAILED! Public and private maps should not intersect."
168-
cat private-maps-copy-log
169-
exit 1
170-
fi
171-
fi
172-
173147
- name: Set up JDK 8
174148
uses: actions/setup-java@v3
175149
with:
@@ -183,33 +157,33 @@ jobs:
183157

184158
# Always cleanup even if other commands failed so we don't unnecessarily store
185159
# the artifacts in the cloud
186-
- name: Cleanup client artifacts
187-
uses: geekyeggo/delete-artifact@54ab544f12cdb7b71613a16a2b5a37a9ade990af
188-
if: always()
189-
with:
190-
name: client-*
191-
192-
- name: Publish to local repository
193-
run: ./gradlew publishToMavenLocal -Prelease_version=$RELEASE_VERSION
160+
#- name: Cleanup client artifacts
161+
# uses: geekyeggo/delete-artifact@54ab544f12cdb7b71613a16a2b5a37a9ade990af
162+
# if: always()
163+
# with:
164+
# name: client-*
194165

195166
- name: Determine access control
196167
run: |
197-
[[ "$IS_PUBLIC" = "YES" ]] && acl="public-read" || acl="project-private"
168+
acl="public-read"
198169
echo "OBJECT_ACL=$acl" >> $GITHUB_ENV
199170
echo "Objects will be uploaded with ACL $acl"
200171
201-
- name: Upload maven artifacts to remote repository
202-
run: gsutil -m rsync -a $OBJECT_ACL -r $HOME/.m2/repository/org/battlecode gs://$GCS_BUCKET/maven/org/battlecode
203-
204-
- name: Upload javadocs
172+
- name: Publish to local repository
205173
run: |
206-
unzip -d ${{ runner.temp }}/javadoc $HOME/.m2/repository/org/battlecode/$RELEASE_ARTIFACT_ID/$RELEASE_VERSION/*-javadoc.jar
207-
gsutil -m rsync -a $OBJECT_ACL -r ${{ runner.temp }}/javadoc gs://$GCS_BUCKET/javadoc/$RELEASE_ARTIFACT_ID/$RELEASE_VERSION
174+
id_base=${CLIENT_ARTIFACT_ID}-client
175+
path_base=client/artifacts/client
176+
#./gradlew publishClientPublicationToMavenLocal -Prelease_version=$RELEASE_VERSION -Partifact_id=${id_base}-win-tauri -Partifact_path=${path_base}-windows/tauri-output.zip
177+
#./gradlew publishClientPublicationToMavenLocal -Prelease_version=$RELEASE_VERSION -Partifact_id=${id_base}-mac-tauri -Partifact_path=${path_base}-macos/tauri-output.zip
178+
./gradlew publishClientPublicationToMavenLocal -Prelease_version=$RELEASE_VERSION -Partifact_id=${id_base}-linux-tauri -Partifact_path=${path_base}-linux/tauri-output.zip
179+
#./gradlew publishClientPublicationToMavenLocal -Prelease_version=$RELEASE_VERSION -Partifact_id=${id_base}-win-electron -Partifact_path=${path_base}-windows/electron-output.zip
180+
#./gradlew publishClientPublicationToMavenLocal -Prelease_version=$RELEASE_VERSION -Partifact_id=${id_base}-mac-electron -Partifact_path=${path_base}-macos/electron-output.zip
181+
./gradlew publishClientPublicationToMavenLocal -Prelease_version=$RELEASE_VERSION -Partifact_id=${id_base}-linux-electron -Partifact_path=${path_base}-linux/electron-output.zip
208182
209-
- name: Upload specs
210-
run: gsutil -m rsync -a $OBJECT_ACL -r ./specs gs://$GCS_BUCKET/specs/$RELEASE_ARTIFACT_ID/$RELEASE_VERSION
183+
- name: Upload maven artifacts to remote repository
184+
run: gsutil -m rsync -a $OBJECT_ACL -r $HOME/.m2/repository/org/battlecode gs://$GCS_BUCKET/maven/org/battlecode
211185

212186
- name: Upload web client
213187
run: |
214-
gsutil -m rsync -r -a $OBJECT_ACL ./artifacts/client-dist gs://$GCS_BUCKET/client/$RELEASE_ARTIFACT_ID/$RELEASE_VERSION
215-
working-directory: ./client
188+
gsutil -m rsync -r -a $OBJECT_ACL ./client-dist gs://$GCS_BUCKET/client/$CLIENT_ARTIFACT_ID/$RELEASE_VERSION
189+
working-directory: ./client/artifacts
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Release Engine
2+
on:
3+
push:
4+
tags:
5+
- 'engine.*'
6+
7+
env:
8+
# GCS_BUCKET is the name of the Google Cloud Storage bucket to which all artifacts are deployed.
9+
GCS_BUCKET: mitbattlecode-releases
10+
11+
# RELEASE_ARTIFACT_ID is the name of the Maven artifact produced by the buildsystem.
12+
# Important: you must make sure no ID is a prefix of a different ID. Otherwise, you could
13+
# inadvertently cause unintended episodes to become public.
14+
RELEASE_ARTIFACT_ID: battlecode25
15+
16+
# IS_PUBLIC is whether to release deployments publicly. Set to exactly the text "YES" to do so.
17+
IS_PUBLIC: NO
18+
19+
jobs:
20+
release:
21+
name: Release
22+
runs-on: ubuntu-latest
23+
needs: build-client
24+
permissions:
25+
contents: read
26+
id-token: write
27+
28+
steps:
29+
- name: Checkout branch
30+
uses: actions/checkout@v3
31+
32+
- name: Inject release version
33+
run: |
34+
release_version=${GITHUB_REF#refs/*/}
35+
release_version=${release_version#engine.}
36+
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
37+
echo "The release version is $release_version"
38+
39+
- name: Authenticate to Google Cloud Platform
40+
uses: google-github-actions/auth@v1
41+
with:
42+
create_credentials_file: true
43+
workload_identity_provider: projects/830784087321/locations/global/workloadIdentityPools/releases/providers/github-workflow
44+
service_account: [email protected]
45+
46+
- name: Set up Google Cloud SDK
47+
uses: 'google-github-actions/setup-gcloud@v1'
48+
49+
- name: Clone private maps
50+
if: ${{ env.IS_PUBLIC != 'YES' }}
51+
uses: actions/checkout@v3
52+
with:
53+
repository: battlecode/private-maps
54+
token: ${{ secrets.CI_REPOSITORY_CLONE_PAT }}
55+
path: private-maps
56+
57+
- name: Inject private maps
58+
if: ${{ env.IS_PUBLIC != 'YES' }}
59+
run: |
60+
source="private-maps/$RELEASE_ARTIFACT_ID"
61+
dest="engine/src/main/battlecode/world/resources"
62+
if [ -d "$source" ]; then
63+
cp -r -i "$source/." "$dest/" < /dev/null &> private-maps-copy-log
64+
if [ -s "private-maps-copy-log" ]; then
65+
echo "FAILED! Public and private maps should not intersect."
66+
cat private-maps-copy-log
67+
exit 1
68+
fi
69+
fi
70+
71+
- name: Set up JDK 8
72+
uses: actions/setup-java@v3
73+
with:
74+
java-version: 8
75+
distribution: adopt
76+
77+
- name: Publish to local repository
78+
run: ./gradlew publishServerPublicationToMavenLocal -Prelease_version=$RELEASE_VERSION -Partifact_id=${RELEASE_ARTIFACT_ID}-java
79+
80+
- name: Determine access control
81+
run: |
82+
[[ "$IS_PUBLIC" = "YES" ]] && acl="public-read" || acl="project-private"
83+
echo "OBJECT_ACL=$acl" >> $GITHUB_ENV
84+
echo "Objects will be uploaded with ACL $acl"
85+
86+
- name: Upload maven artifacts to remote repository
87+
run: gsutil -m rsync -a $OBJECT_ACL -r $HOME/.m2/repository/org/battlecode gs://$GCS_BUCKET/maven/org/battlecode
88+
89+
- name: Upload javadocs
90+
run: |
91+
unzip -d ${{ runner.temp }}/javadoc $HOME/.m2/repository/org/battlecode/$RELEASE_ARTIFACT_ID/$RELEASE_VERSION/*-javadoc.jar
92+
gsutil -m rsync -a $OBJECT_ACL -r ${{ runner.temp }}/javadoc gs://$GCS_BUCKET/javadoc/$RELEASE_ARTIFACT_ID/$RELEASE_VERSION
93+
94+
- name: Upload specs
95+
run: gsutil -m rsync -a $OBJECT_ACL -r ./specs gs://$GCS_BUCKET/specs/$RELEASE_ARTIFACT_ID/$RELEASE_VERSION

build.gradle

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,11 @@ task release_sources(type: Jar, dependsOn: classes) {
150150
from project(":engine").sourceSets.main.allSource
151151
}
152152

153-
def clientDirPrefix = 'client/artifacts/client-'
154-
155153
publishing {
156154
publications {
157155
server(MavenPublication) {
158156
groupId 'org.battlecode'
159-
artifactId 'battlecode24'
157+
artifactId project.findProperty('artifact_id') ?: 'NONSENSE'
160158
version project.findProperty('release_version') ?: 'NONSENSE'
161159

162160
artifact release_main
@@ -170,56 +168,12 @@ publishing {
170168
}
171169
}
172170

173-
// Tauri
174-
175-
clientWinTauri(MavenPublication) {
176-
groupId 'org.battlecode'
177-
artifactId 'battlecode24-client-win-tauri'
178-
version project.findProperty('release_version') ?: 'NONSENSE'
179-
180-
artifact (clientDirPrefix + 'windows/tauri-output.zip')
181-
}
182-
183-
clientMacTauri(MavenPublication) {
184-
groupId 'org.battlecode'
185-
artifactId 'battlecode24-client-mac-tauri'
186-
version project.findProperty('release_version') ?: 'NONSENSE'
187-
188-
artifact (clientDirPrefix + 'macos/tauri-output.zip')
189-
}
190-
191-
clientLinuxTauri(MavenPublication) {
192-
groupId 'org.battlecode'
193-
artifactId 'battlecode24-client-linux-tauri'
194-
version project.findProperty('release_version') ?: 'NONSENSE'
195-
196-
artifact (clientDirPrefix + 'linux/tauri-output.zip')
197-
}
198-
199-
// Electron
200-
201-
clientWinElectron(MavenPublication) {
202-
groupId 'org.battlecode'
203-
artifactId 'battlecode24-client-win-electron'
204-
version project.findProperty('release_version') ?: 'NONSENSE'
205-
206-
artifact (clientDirPrefix + 'windows/electron-output.zip')
207-
}
208-
209-
clientMacElectron(MavenPublication) {
210-
groupId 'org.battlecode'
211-
artifactId 'battlecode24-client-mac-electron'
212-
version project.findProperty('release_version') ?: 'NONSENSE'
213-
214-
artifact (clientDirPrefix + 'macos/electron-output.zip')
215-
}
216-
217-
clientLinuxElectron(MavenPublication) {
171+
client(MavenPublication) {
218172
groupId 'org.battlecode'
219-
artifactId 'battlecode24-client-linux-electron'
173+
artifactId project.findProperty('artifact_id') ?: 'NONSENSE'
220174
version project.findProperty('release_version') ?: 'NONSENSE'
221175

222-
artifact (clientDirPrefix + 'linux/electron-output.zip')
176+
artifact project.findProperty('artifact_path') ?: 'NONSENSE'
223177
}
224178
}
225179
}

0 commit comments

Comments
 (0)