-
Notifications
You must be signed in to change notification settings - Fork 6
174 lines (147 loc) · 6.47 KB
/
release-engine.yml
File metadata and controls
174 lines (147 loc) · 6.47 KB
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
name: Release Engine
on:
push:
tags:
- 'engine.*'
env:
# GCS_BUCKET is the name of the Google Cloud Storage bucket to which all artifacts are deployed.
GCS_BUCKET: mitbattlecode-releases
# RELEASE_ARTIFACT_ID is the name of the Maven artifact produced by the buildsystem.
# Important: you must make sure no ID is a prefix of a different ID. Otherwise, you could
# inadvertently cause unintended episodes to become public.
RELEASE_ARTIFACT_ID: battlecode26
# IS_PUBLIC is whether to release deployments publicly. Set to exactly the text "YES" to do so.
IS_PUBLIC: YES
jobs:
release-java:
name: Release Java
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout branch
uses: actions/checkout@v3
- name: Inject release version
run: |
release_version=${GITHUB_REF#refs/*/}
release_version=${release_version#engine.}
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: releases-agent@mitbattlecode.iam.gserviceaccount.com
- name: Set up Google Cloud SDK
uses: 'google-github-actions/setup-gcloud@v1'
- name: Clone private maps
if: ${{ env.IS_PUBLIC != 'YES' }}
uses: actions/checkout@v3
with:
repository: battlecode/private-maps
token: ${{ secrets.CI_REPOSITORY_CLONE_PAT }}
path: private-maps
- name: Inject private maps
if: ${{ env.IS_PUBLIC != 'YES' }}
run: |
source="private-maps/$RELEASE_ARTIFACT_ID"
dest="engine/src/main/battlecode/world/resources"
if [ -d "$source" ]; then
cp -r -i "$source/." "$dest/" < /dev/null &> private-maps-copy-log
if [ -s "private-maps-copy-log" ]; then
echo "FAILED! Public and private maps should not intersect."
cat private-maps-copy-log
exit 1
fi
fi
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 21
distribution: adopt
- name: Publish to local repository
run: ./gradlew publishServerPublicationToMavenLocal -Prelease_version=$RELEASE_VERSION -Partifact_id=${RELEASE_ARTIFACT_ID}-java
- 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: 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 javadocs
run: |
unzip -d ${{ runner.temp }}/javadoc $HOME/.m2/repository/org/battlecode/${RELEASE_ARTIFACT_ID}-java/${RELEASE_VERSION}/*-javadoc.jar
gsutil -m rsync -a $OBJECT_ACL -r ${{ runner.temp }}/javadoc gs://$GCS_BUCKET/javadoc/${RELEASE_ARTIFACT_ID}/${RELEASE_VERSION}
- name: Upload specs
run: gsutil -m rsync -a $OBJECT_ACL -r ./specs gs://$GCS_BUCKET/specs/${RELEASE_ARTIFACT_ID}/$RELEASE_VERSION
release-python:
name: Release Python
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: 3.12
- name: Checkout branch
uses: actions/checkout@v3
- name: Inject release version
run: |
release_version=${GITHUB_REF#refs/*/}
release_version=${release_version#engine.}
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: releases-agent@mitbattlecode.iam.gserviceaccount.com
- name: Set up Google Cloud SDK
uses: 'google-github-actions/setup-gcloud@v1'
- name: Clone private maps
if: ${{ env.IS_PUBLIC != 'YES' }}
uses: actions/checkout@v3
with:
repository: battlecode/private-maps
token: ${{ secrets.CI_REPOSITORY_CLONE_PAT }}
path: private-maps
- name: Inject private maps
if: ${{ env.IS_PUBLIC != 'YES' }}
run: |
source="private-maps/$RELEASE_ARTIFACT_ID"
dest="engine/src/main/battlecode/world/resources"
if [ -d "$source" ]; then
cp -r -i "$source/." "$dest/" < /dev/null &> private-maps-copy-log
if [ -s "private-maps-copy-log" ]; then
echo "FAILED! Public and private maps should not intersect."
cat private-maps-copy-log
exit 1
fi
fi
- name: Build python package
shell: bash -el {0} # Make sure conda is activated
run: |
conda info
python --version
pip install --upgrade build
SETUPTOOLS_SCM_PRETEND_VERSION=${RELEASE_VERSION} python -m build
working-directory: engine/src/crossplay_python
- 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: Upload python package to remote repository
run: |
mv *.tar.gz battlecode.tar.gz
gsutil -m cp -a $OBJECT_ACL battlecode.tar.gz gs://$GCS_BUCKET/maven/org/battlecode/${RELEASE_ARTIFACT_ID}-python/${RELEASE_VERSION}/
working-directory: engine/src/crossplay_python/dist
# TODO: docs?
# - name: Upload javadocs
# run: |
# unzip -d ${{ runner.temp }}/javadoc $HOME/.m2/repository/org/battlecode/$RELEASE_ARTIFACT_ID/$RELEASE_VERSION/*-javadoc.jar
# gsutil -m rsync -a $OBJECT_ACL -r ${{ runner.temp }}/javadoc gs://$GCS_BUCKET/javadoc/$RELEASE_ARTIFACT_ID/$RELEASE_VERSION