-
Notifications
You must be signed in to change notification settings - Fork 0
235 lines (206 loc) · 8.71 KB
/
ci.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
---
# Automated build of the:
# * riscos-build-online tool for linux.
# * riscos-build-online deb for Linux.
# * riscos-build-online Absolute for RISC OS.
name: CI
# Controls when the action will run. Triggers the workflow on:
# * push or pull request on any branch.
# * tag creation for tags beginning with a 'v'
on:
push:
branches: ["*"]
pull_request:
branches: ["*"]
create:
tags:
- v*
jobs:
build-linux:
# The type of runner that the job will run on
runs-on: ubuntu-latest
outputs:
leafname_deb: ${{ steps.version.outputs.leafname_deb }}
leafname_tool: ${{ steps.version.outputs.leafname_tool }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Build the linux binary and the deb
run: make riscos-build-online
- name: Run a test against the live build server
run: make test
- name: Build the deb
run: make deb
- name: Work out the names of the files
id: version
run: |
shopt -s failglob
set +o noglob
deb=$(ls riscos-build-online_*.deb)
echo "::set-output name=leafname_tool::riscos-build-online"
echo "::set-output name=leafname_deb::$deb"
echo "deb name is '$deb'"
- uses: actions/upload-artifact@v2
with:
name: riscos-build-online-linux-tool
path: riscos-build-online
- uses: actions/upload-artifact@v2
with:
name: riscos-build-online-linux-deb
path: ${{ steps.version.outputs.leafname_deb }}
build-riscos:
needs: build-linux
# The type of runner that the job will run on
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
leafname: ${{ steps.version.outputs.leafname }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Download built Linux binary
uses: actions/download-artifact@v1
with:
name: riscos-build-online-linux-tool
# We use the tool we've just built to create the RISC OS version.
- name: Build through build.riscos.online
run: |
set -o pipefail
zip -q9r /tmp/source-archive.zip * .robuild.yaml
chmod +x riscos-build-online-linux-tool/riscos-build-online
riscos-build-online-linux-tool/riscos-build-online -i /tmp/source-archive.zip -t 600 -o /tmp/riscos-build-online
# Step intended to be reused in CI pipelines.
# - name: Build through build.riscos.online
# run: |
# set -o pipefail
# mkdir /tmp/robuild
# # Zip up the source to send to robuild
# zip -q9r /tmp/source-archive.zip * .robuild.yaml
# # Send the archive file to build service
# curl -q -F 'source=@/tmp/source-archive.zip' -o /tmp/robuild/result.json https://json.build.riscos.online/build/json
# # Extract any system messages and output
# jq -r '.messages[]' /tmp/robuild/result.json > /tmp/robuild/messages.txt || \
# { echo "Server response:" ; cat /tmp/robuild/result.json ; false ; }
# jq -r 'reduce .output[] as $i ("";. + $i)' /tmp/robuild/result.json > /tmp/robuild/output.txt
# # Extract return code
# rc=$(jq -r .rc /tmp/robuild/result.json | tee /tmp/robuild/rc.json)
# # Marker files for the state
# if [ "$rc" != "0" ] ; then touch /tmp/robuild/failed ; else touch /tmp/robuild/ok ; fi
# # Extract the built binary if we had any
# if [ "$rc" = "0" ] ; then
# jq -r .data /tmp/robuild/result.json | base64 --decode - > /tmp/robuild/built
# fi
# # Outputs:
# # /tmp/robuild/result.json - JSON output from the service.
# # /tmp/robuild/{ok,failed} - status of the build (whether RC was 0).
# # /tmp/robuild/built - the output result from the build.
# # /tmp/robuild/rc - the value of the return code (decimal string)
# # /tmp/robuild/messages.txt - system messages
# # /tmp/robuild/output.txt - output from the build
#
# # Another drop in, which uses that information to show the results
# - name: Did it work?
# run: |
# echo "System messages:"
# sed 's/^/ /' < /tmp/robuild/messages.txt
# echo
# echo "Build output:"
# sed 's/^/ /' < /tmp/robuild/output.txt
# echo
# if [ ! -f /tmp/robuild/ok ] ; then
# echo "FAILED! Aborting"
# exit 1
# fi
- name: Give the output a versioned name
id: version
run: |
if [[ -f VersionNum ]] ; then
version=$(sed '/MajorVersion / ! d ; s/.*MajorVersion *"\(.*\)"/\1/' VersionNum)
else
version=$(git rev-parse --short HEAD)
fi
echo "This is version: $version"
leafname="riscos-build-online,ff8"
dirname="robuild-client"
filename="$dirname/$leafname"
if [ -f /tmp/riscos-build-online,ff8 ] ; then
mkdir -p "$dirname"
cp /tmp/riscos-build-online,ff8 "$filename"
else
echo "No archive was built?"
exit 1
fi
echo "::set-output name=version::$version"
echo "::set-output name=leafname::$leafname"
echo "::set-output name=filename::$filename"
- uses: actions/upload-artifact@v2
with:
name: riscos-build-online-riscos-tool
path: ${{ steps.version.outputs.filename }}
# The artifact that is downloadable from the Actions is actually a zip of the artifacts
# that we supply. So it will be a regular Zip file containing a RISC OS Zip file.
# (but when it's released it will be just the content from the zip archive)
# The release only triggers when the thing that was pushed was a tag starting with 'v'
release:
needs:
- build-riscos
- build-linux
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download built RISC OS binary
uses: actions/download-artifact@v1
with:
name: riscos-build-online-riscos-tool
- name: Download built Linux binary
uses: actions/download-artifact@v1
with:
name: riscos-build-online-linux-tool
- name: Download built Linux deb
uses: actions/download-artifact@v1
with:
name: riscos-build-online-linux-deb
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ needs.build-riscos.outputs.version }}
draft: true
prerelease: false
- name: Upload Release Asset (RISC OS)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`.
# See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: riscos-build-online-riscos-tool/${{ needs.build-riscos.outputs.leafname }}
asset_name: ${{ needs.build-riscos.outputs.leafname }}
asset_content_type: application/riscos; name="${{ needs.build-riscos.outputs.leafname }}"
- name: Upload Release Asset (Linux tool)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: riscos-build-online-linux-tool/${{ needs.build-linux.outputs.leafname_tool }}
asset_name: ${{ needs.build-linux.outputs.leafname_tool }}
asset_content_type: application/octet-stream
- name: Upload Release Asset (Linux deb)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: riscos-build-online-linux-deb/${{ needs.build-linux.outputs.leafname_deb }}
asset_name: ${{ needs.build-linux.outputs.leafname_deb }}
asset_content_type: application/vnd.debian.binary-package