forked from couchbaselabs/otp
-
Notifications
You must be signed in to change notification settings - Fork 10
222 lines (204 loc) · 8.11 KB
/
main.yaml
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
##
## This workflow handles testing of pull requests and pushes.
## It also publishes some packages to any new Erlang/OTP release
##
## To speed this up it would be nice if one could share docker
## images inbetween different jobs, but at the moment this is
## not possible so we need to rebuild all of Erlang/OTP multiple
## times.
##
## Also once the windows runner supports WSL we should implement
## support for building Erlang/OTP here.
##
## When ghcr.io support using the GITHUB_TOKEN we should migrate
## over to use it instead as that should allow us to use the
## built-in caching mechanisms of docker/build-push-action@v2.
## However as things are now we use docker directly to make things
## work.
##
name: Build and check Erlang/OTP
on:
push:
pull_request:
jobs:
pack:
name: Pack the Erlang/OTP tar.gz
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Commit autoconf files
## We first commit the autoconf generate so that they
## are kept in the pre-built achive
run: |
./otp_build autoconf
find . -name aclocal.m4 | xargs git add -f
find . -name configure | xargs git add -f
find . -name config.h.in | xargs git add -f
find . -name config.guess | xargs git add -f
find . -name config.sub | xargs git add -f
find . -name install-sh | xargs git add -f
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git diff --cached --quiet || git commit --no-verify -m 'Add generated configure files'
- name: Archive git repository
run: git archive --prefix otp/ -o otp_src.tar.gz HEAD
- name: Upload source tar archive
uses: actions/upload-artifact@v2
with:
name: otp_git_archive
path: otp_src.tar.gz
build:
name: Build Erlang/OTP
runs-on: ubuntu-latest
needs: pack
strategy:
matrix:
type: [64-bit,32-bit,cross-compile,documentation]
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Download source archive
uses: actions/download-artifact@v2
with:
name: otp_git_archive
- name: Docker login
uses: docker/login-action@v1
with:
registry: docker.pkg.github.com
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Calculate BASE image
id: base
run: |
BASE_TAG=$(grep "^FROM" .github/dockerfiles/Dockerfile.${{ matrix.type }} | head -1 | awk '{print $2}')
echo "::set-output name=BASE_TAG::${BASE_TAG}"
.github/scripts/base-tag "${BASE_TAG}"
- name: Pull BASE image
run: docker pull ${{ steps.base.outputs.BASE_TAG }}
- name: Build BASE image
run: |
docker build --pull --tag ${{ steps.base.outputs.BASE_TAG }} \
--cache-from ${{ steps.base.outputs.BASE_TAG }} \
--file .github/dockerfiles/Dockerfile.${{ steps.base.outputs.BASE_TYPE }} \
--build-arg BASE=${{ steps.base.outputs.BASE }} .
- name: Build ${{ matrix.type }} image
run: |
docker build --tag otp --file .github/dockerfiles/Dockerfile.${{ matrix.type }} \
--build-arg ARCHIVE=otp_src.tar.gz .
## Smoke build tests
- if: matrix.type == '32-bit' || matrix.type == '64-bit' || matrix.type == 'cross-compile'
name: Run smoke test
run: docker run -v $PWD/scripts:/scripts otp "cd /tests && /scripts/run-smoke-tests"
## Documentation checks
- if: matrix.type == 'documentation'
name: Run xmllimt
run: docker run otp "make xmllint"
- if: matrix.type == 'documentation'
name: Run html link check
run: docker run -v $PWD/scripts:/scripts otp "/scripts/otp_html_check /otp doc/index.html"
- if: matrix.type == 'documentation'
name: Release docs to publish
run: |
docker run -v $PWD/:/github otp "make release_docs DOC_TARGETS='man html pdf' RELEASE_ROOT=/github/docs"
sudo chown -R `whoami` docs
cd docs
tar czf ../otp_doc_man.tar.gz man
rm -rf man
tar czf ../otp_doc_html.tar.gz *
- if: matrix.type == 'documentation'
name: Upload html documentation archive
uses: actions/upload-artifact@v2
with:
name: otp_doc_html
path: otp_doc_html.tar.gz
- if: matrix.type == 'documentation'
name: Upload man documentation archive
uses: actions/upload-artifact@v2
with:
name: otp_doc_man
path: otp_doc_man.tar.gz
## Run dialyzer
- if: matrix.type == '64-bit'
name: Run dialyzer
run: docker run -v $PWD/scripts:/scripts otp "/scripts/run-dialyzer"
## Build pre-built tar archives
- if: matrix.type == '32-bit'
name: Build pre-built tar archives
run: |
docker run -v $PWD:/github otp \
"scripts/build-otp-tar -o /github/otp_clean_src.tar.gz /github/otp_src.tar.gz -b /buildroot/otp/ /buildroot/otp.tar.gz"
- if: matrix.type == '32-bit'
name: Upload pre-built tar archive
uses: actions/upload-artifact@v2
with:
name: otp_prebuilt
path: otp_src.tar.gz
## If this is a tag that has been pushed we do some release work
release:
name: Release Erlang/OTP
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'erlang/otp'
steps:
## This step outputs the tag name and whether the tag is a release or patch
## (all releases have only two version identifiers, while patches have three
## or more)
- name: Get Tag Name
id: tag
run: |
TAG=${GITHUB_REF#refs/tags/}
VSN=${TAG#OTP-}
IS_RELEASE=`$(echo $TAG | grep -E '^OTP-[0-9]+\.[0-9]+$' > /dev/null) \
&& echo "true" || echo "false"`
echo "::set-output name=tag::${TAG}"
echo "::set-output name=vsn::${VSN}"
echo "::set-output name=release::${IS_RELEASE}"
- uses: actions/checkout@v2
## Publish the pre-built archive and docs
- name: Download source archive
uses: actions/download-artifact@v2
with:
name: otp_prebuilt
- name: Download html docs
uses: actions/download-artifact@v2
with:
name: otp_doc_html
- name: Download man docs
uses: actions/download-artifact@v2
with:
name: otp_doc_man
## We add the correct version name into the file names
## and create the hash files for all assets
- name: Create pre-build and doc archives
run: |
mkdir artifacts
tar -xzf otp_src.tar.gz
mv otp otp_src_${{ steps.tag.outputs.vsn }}
tar -czf artifacts/otp_src_${{ steps.tag.outputs.vsn }}.tar.gz otp_src_${{ steps.tag.outputs.vsn }}
mv otp_doc_man.tar.gz artifacts/otp_doc_man_${{ steps.tag.outputs.vsn }}.tar.gz
mv otp_doc_html.tar.gz artifacts/otp_doc_html_${{ steps.tag.outputs.vsn }}.tar.gz
- name: Build OTP Bundle
if: steps.tag.outputs.release == 'true'
run: |
scripts/bundle-otp ${{ steps.tag.outputs.tag }}
## Create hash files
- name: Create pre-build and doc archives
run: |
shopt -s nullglob
cd artifacts
md5sum {*.tar.gz,*.txt} > MD5.txt
sha256sum {*.tar.gz,*.txt} > SHA256.txt
- name: Upload pre-built and doc tar archives
uses: softprops/action-gh-release@v1
with:
name: OTP ${{ steps.tag.outputs.vsn }}
files: |
artifacts/*.tar.gz
artifacts/*.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy on erlang.org
env:
GITHUB_TOKEN: ${{ secrets.TRIGGER_ERLANG_ORG_BUILD }}
run: |
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/erlang/erlang-org/actions/workflows/update-gh-cache.yaml/dispatches" -d '{"ref":"master"}'