-
Notifications
You must be signed in to change notification settings - Fork 160
334 lines (303 loc) · 13.5 KB
/
release.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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# This workflow takes care of creating release archives for the
# GAP distribution. It is run for all PR and branch pushes as usual,
# but also on tags named `vX.Y.Z` with X, Y, Z numbers.
#
# For builds triggered by a tag, the tag is turned into a GitHub release and
# the produced archives are attached to that.
name: "Wrap releases"
on:
workflow_dispatch:
pull_request:
push:
tags: v[1-9]+.[0-9]+.[0-9]+
branches:
- master
- stable-*
schedule:
# Every day at 3:33 AM UTC
- cron: '33 3 * * *'
concurrency:
# group by workflow and ref; the last slightly strange component ensures that for pull
# requests, we limit to 1 concurrent job, but for the master branch we don't
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.ref != 'refs/heads/master' || github.run_number }}
# Cancel intermediate builds, but only if it is a pull request build.
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
env:
NO_COVERAGE: 1
jobs:
unix:
name: "Create Unix archives and data"
# Don't run this twice on PRs for branches pushed to the same repository
if: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) }}
runs-on: ubuntu-latest
outputs:
cygwin-matrix: ${{ steps.set-cygwin-matrix.outputs.matrix }}
gap-build-version: ${{ steps.get-build.outputs.name }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# When an annotated tag is pushed, then for some reason we don't see it
# in this action; instead an unannotated tag with the same name is
# present, we resolve this by force-fetching tags.
# But we first fetch tags from gap-system/gap, so that our scripts should
# know about all of the 'usual' tags.
# Only then do we fetch tags from the current fork, which will overwrite
# any of those from gap-system/gap that conflict.
- name: "Force fetch tags"
run: |
git fetch https://github.com/gap-system/gap --tags --force
git fetch --tags --force
- name: "Set up Python"
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: "Install Python modules"
run: pip3 install PyGithub python-dateutil
- name: "Install latex"
run: |
packages=(
texlive-latex-base
texlive-latex-recommended
texlive-latex-extra
texlive-fonts-recommended
)
sudo apt-get update
sudo apt-get install --no-install-recommends "${packages[@]}"
- name: "Configure GAP"
run: dev/ci-configure-gap.sh
- name: "Build GAP"
run: dev/ci-build-gap.sh
- name: "Record the GAP build version"
id: get-build
run: |
BUILD=`head -1 cnf/GAP-VERSION-FILE | cut -d ' ' -f3`
echo "steps.get-build.outputs.name = ${BUILD}"
echo "name=${BUILD}" >> $GITHUB_OUTPUT
- name: "Make archives"
run: python -u ./dev/releases/make_archives.py
- name: "Test building GAP from the primary release archive"
run: |
mkdir -p test-gap-tarball
pushd test-gap-tarball
tar xvf ../tmp/gap-${{ steps.get-build.outputs.name }}.tar.gz
cd gap*
# test building GAP
./configure --prefix=/tmp/gapprefix
make -j8
popd
- name: "Test 'make install' from the primary release archive"
run: |
pushd test-gap-tarball/gap*
GAPPREFIX=/tmp/gapprefix TEST_SUITES="testmakeinstall" ../../dev/ci.sh
popd
# Upload the main GAP .tar.gz file (which includes packages).
# We only upload this tarball in order to minimise our demand on GitHub's
# resources, and that is why we also only upload these for the daily cron
# jobs, and in the case of an error on making a release.
#
# The artifact lives for 1 day; i.e. typically until the next cron job runs.
#
# Warning: the result is a single .zip file (so things are compressed twice).
- name: "Upload GAP tarball"
if: ${{ (!startsWith(github.ref, 'refs/tags/v') && failure()) || github.event_name == 'schedule' }}
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: gap-${{ steps.get-build.outputs.name }}.tar.gz
path: tmp/gap-${{ steps.get-build.outputs.name }}.tar.gz
retention-days: 1
# Always upload metadata, and keep longer, since it is much smaller.
- name: "Upload JSON metadata"
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: "JSON metadata"
path: tmp/*json.gz
retention-days: 7
- name: "Make GitHub release"
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: python -u ./dev/releases/make_github_release.py ${GITHUB_REF#refs/tags/} tmp/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Decide which Cygwin installers to build next"
id: set-cygwin-matrix
run: |
CYGWIN_MATRIX='{"arch":["x86_64"]}'
echo "Setting Cygwin matrix: $CYGWIN_MATRIX"
echo "matrix=$CYGWIN_MATRIX" >> $GITHUB_OUTPUT
cygwin:
name: "Create Windows ${{ matrix.arch }} installer"
needs: unix
runs-on: windows-2019
env:
CHERE_INVOKING: 1
GAP_BUILD_VERSION: ${{ needs.unix.outputs.gap-build-version }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.unix.outputs.cygwin-matrix) }}
steps:
# The GAP to be wrapped is put into gap-$GAP_BUILD_VERSION/
# The sage-windows script requires the GAP directory to be named this way.
#
# If the event is a pushed release tag, then we are wrapping a version of
# GAP that already has its packages in place and all manuals compiled.
# Therefore sage-windows only needs to compile GAP and the packages.
#
# Otherwise, we wrap a cloned version of GAP.
# In none of these cases do we build GAP's manuals, because it's too slow.
# If the event is a PR, then we `make bootstrap-pkg-minimal` to save time
# (none of the required packages requires compilation).
# If the event is a pushed branch, then we `make bootstrap-pkg-full` and
# then run the BuildPackages.sh script. This takes a long time.
- name: "Set some environment variables according to the GitHub context"
run: |
if [[ $GITHUB_REF == refs/tags/v* ]]; then
GAPDEV_DIR="gap-dev"
COMPILEGAP="make -j2"
elif [[ $GITHUB_EVENT_NAME == 'pull_request' ]]; then
GAPDEV_DIR="gap-${GAP_BUILD_VERSION}"
COMPILEGAP="make -j2 && make bootstrap-pkg-minimal"
elif [[ $GITHUB_REF == refs/heads/* ]]; then
GAPDEV_DIR="gap-${GAP_BUILD_VERSION}"
COMPILEGAP="make -j2 && make bootstrap-pkg-full"
else
echo "Unrecognised GitHub situation!"
exit 1
fi
echo "Using: GAPDEV_DIR=${GAPDEV_DIR} and COMPILEGAP=${COMPILEGAP}"
echo "GAPDEV_DIR=${GAPDEV_DIR}" >> $GITHUB_ENV
echo "SAGE_RUN_CONFIGURE_CMD=\"cd \$(SAGE_ROOT) && ${COMPILEGAP}\"" >> $GITHUB_ENV
# In all cases, we currently need to clone GAP for its release scripts.
#
# If the GitHub event is a pushed release tag, then we compile/wrap a GAP
# tarball that we download from the GitHub release that was just created
# and uploaded by the preceding 'unix' job.
#
# Otherwise, we compile and wrap the appropriate GAP development clone
# into the installer.
#
# Alternatively, we could upload the desired GAP tarball via the
# 'actions/upload-artifact' action in the preceding 'unix' job, and then
# use this in all cases in this 'cygwin' job. This would save some
# repeated work and hence time, and unify the code here slightly.
#
# Furthermore, this would remove the need for the
# download_release_archive.py script, and if we would also remove the need
# for the upload_file_to_github_release.py script, as described below,
# then we would no longer need access to the GAP release scripts in this
# job at all. Therefore, in all cases, we would be able to remove:
# * Clone GAP
# * Copy GAP's release scripts
# * Set up Python and its modules
# - Although we would still need a way to create the EXE checksum files
# * The existence of the GAPDEV_DIR environment variable
# * The different values of the COMPILEGAP variable above, because in all
# cases it would be just "make -j2", since the downloaded release
# artifact would/could already contain the appropriate packages.
- name: "Clone GAP"
uses: actions/checkout@v3
with:
path: ${{ env.GAPDEV_DIR }}
- name: "Copy GAP's release scripts to a safe place"
run: cp -rp ${GAPDEV_DIR}/dev/releases .
- uses: actions/setup-python@v4
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
with:
python-version: 3.9
- name: "Install required Python modules"
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: pip3 install PyGithub
# We could probably use either a GitHub Action from the GitHub Marketplace
# to download the appropriate GAP tarball from the GitHub release, rather
# than creating and using the Python file. This would probably mean that
# we lose the ability to verify checksums, but that is probably fine.
- name: "Download the appropriate GAP release tarball"
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
python -u ./releases/download_release_archive.py \
v${GAP_BUILD_VERSION} \
gap-${GAP_BUILD_VERSION}.tar.gz .
tar -zxf gap-${GAP_BUILD_VERSION}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# The following repository should eventually be owned by a GAP-related
# organisation, and perhaps ultimately it could/should be re-integrated
# with the original sagemath/sage-windows repository.
- name: "Clone the Windows installer maker scripts"
uses: actions/checkout@v3
with:
repository: ChrisJefferson/sage-windows
ref: master
path: sage-windows
- uses: gap-actions/setup-cygwin@v1
# Currently, the sage-windows/release_gap.sh script wraps the GAP
# contained in gap-${GAP_BUILD_VERSION}, and outputs its installer to
# sage-windows/Output/gap-${GAP_BUILD_VERSION}-$ARCH.exe
#
# TODO:
# * Investigate how to speed this up. e.g. if we don't need to compile
# GAP's manuals then could we perhaps avoid installing TeXLive?
# * Investigate splitting release_gap.sh into multiple scripts so that
# this big step can be split up into multiple steps
- name: "Compile GAP and its packages, and create the installer"
shell: C:\cygwin64\bin\bash.exe --login --norc -o igncr '{0}'
run: |
cd ${GITHUB_WORKSPACE}/sage-windows
bash release_gap.sh
env:
ARCH: ${{ matrix.arch }}
SAGE_BUILD_DOC_CMD: '"true"'
SAGE_VERSION: ${{ env.GAP_BUILD_VERSION }}
# Artifacts live for 1 day, i.e. until the next cron job runs.
- name: "Upload the installer as an artifact"
if: ${{ github.event_name == 'schedule' }}
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: gap-${{ env.GAP_BUILD_VERSION }}-${{ matrix.arch }}.exe
path: sage-windows/Output/gap-${{ env.GAP_BUILD_VERSION }}-${{ matrix.arch }}.exe
retention-days: 1
# To reduce code, we could use an Action from the GitHub Marketplace to
# upload to the release, rather than use our own script. We would still
# have to create the .sha256 file, and upload it here too.
- name: "Upload the installer to the GitHub release"
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
python -u \
./releases/upload_files_to_github_release.py \
v${GAP_BUILD_VERSION} \
sage-windows/Output/gap-${GAP_BUILD_VERSION}-${{ matrix.arch }}.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# The following job is duplicated in CI.yml - keep the two in sync.
# (except for their different 'needs' components).
slack-notification:
name: Send Slack notification on status change
needs:
- unix
- cygwin
if: ${{ always() && github.event_name != 'pull_request' && github.repository == 'gap-system/gap' }}
runs-on: ubuntu-latest
steps:
- name: Get branch name
id: get-branch
run: echo "branch=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Determine whether CI status changed
uses: gap-actions/should-i-notify-action@v1
id: should_notify
with:
branch: ${{ steps.get-branch.outputs.branch }}
needs_context: ${{ toJson(needs) }}
github_token: ${{ secrets.GITHUB_TOKEN }}
notify_on_changed_status: true
- name: Send slack notification
uses: act10ns/slack@v2
if: ${{ steps.should_notify.outputs.should_send_message == 'yes' }}
with:
status: ${{ steps.should_notify.outputs.current_status }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}