-
-
Notifications
You must be signed in to change notification settings - Fork 264
302 lines (300 loc) · 14.8 KB
/
crankshaft.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
name: build-crankshaft
on:
# schedule:
# - cron: '0 10 * * *' # everyday at 10am
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
default: 'DEV'
# pull_request:
jobs:
buildimage:
runs-on: ubuntu-latest
outputs:
artifact_path: ${{ steps.get-artifact-name.outputs.artifact_path }}
artifact_filename: ${{ steps.get-artifact-name.outputs.artifact_filename }}
md5_path: ${{ steps.get-artifact-name.outputs.md5_path }}
md5_filename: ${{ steps.get-artifact-name.outputs.md5_filename }}
sha1_path: ${{ steps.get-artifact-name.outputs.sha1_path }}
sha1_filename: ${{ steps.get-artifact-name.outputs.sha1_filename }}
sha256_path: ${{ steps.get-artifact-name.outputs.sha256_path }}
sha256_filename: ${{ steps.get-artifact-name.outputs.sha256_filename }}
pi2_artifact_path: ${{ steps.get-artifact-name.outputs.artifact_path }}
pi2_artifact_filename: ${{ steps.get-artifact-name-pi2.outputs.artifact_filename }}
pi2_md5_path: ${{ steps.get-artifact-name-pi2.outputs.md5_path }}
pi2_md5_filename: ${{ steps.get-artifact-name-pi2.outputs.md5_filename }}
pi2_sha1_path: ${{ steps.get-artifact-name-pi2.outputs.sha1_path }}
pi2_sha1_filename: ${{ steps.get-artifact-name-pi2.outputs.sha1_filename }}
pi2_sha256_path: ${{ steps.get-artifact-name-pi2.outputs.sha256_path }}
pi2_sha256_filename: ${{ steps.get-artifact-name-pi2.outputs.sha256_filename }}
version: ${{ steps.get_version.outputs.version }}
builddate: ${{ steps.get_version.outputs.builddate }}
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
submodules: true
-
name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all
-
name: Get the version
id: get_version
run: |
raw=$(git branch -r --contains ${{ github.ref }})
branch=${raw/origin\/}
echo ::set-output name=version::${VERSION}
echo ::set-output name=buildhash::$(git rev-parse --short "$GITHUB_SHA")
echo ::set-output name=buildbranch::'crankshaft-ng'
echo ::set-output name=builddate::$(date '+%Y-%m-%d')
env:
version: ${{ github.event.inputs.version }}
-
name: Configure
id: configure
run: |
cat > config <<EOF
IMG_NAME=${IMG_VERSION}
ENABLE_SSH=0
#these are the defaults uncomment to change
#FIRST_USER_NAME=pi
#FIRST_USER_PASS=raspberry
# Uncomment this if a build fails and you'd like to try again
#CONTINUE=1
IMG_VERSION=${IMG_VERSION}
IMG_FILENAME=${IMG_VERSION}
ZIP_FILENAME=${IMG_VERSION}
BUILDHASH='${BUILDHASH}'
BUILDBRANCH='${BUILDBRANCH}'
BUILDDATE='${BUILDDATE}'
EOF
find . -type f -iname "*.sh" -exec chmod +x {} \;
cat config
env:
version: ${{ steps.get_version.outputs.version }}
BUILDHASH: ${{ steps.get_version.outputs.buildhash }}
BUILDBRANCH: ${{ steps.get_version.outputs.buildbranch }}
BUILDDATE: ${{ steps.get_version.outputs.builddate }}
IMG_VERSION: '${{ steps.get_version.outputs.builddate }}-${{ steps.get_version.outputs.buildbranch }}-${{ steps.get_version.outputs.buildhash }}'
-
name: Run build
id: build-docker
run: bash ./build-docker.sh
env:
GIT_HASH: ${{ steps.get_version.outputs.buildhash }}
GIT_BRANCH: ${{ steps.get_version.outputs.buildbranch }}
-
name: Get Name of Artifact
id: get-artifact-name
run: |
ls -hla deploy/*
ARTIFACT_PATHNAME=$(ls deploy/*[!-pi2].zip | head -n 1)
ARTIFACT_NAME=$(basename $ARTIFACT_PATHNAME)
MD5_PATHNAME=$(ls deploy/*[!-pi2].img.md5 | head -n 1)
MD5_NAME=$(basename $MD5_PATHNAME)
SHA1_PATHNAME=$(ls deploy/*[!-pi2].sha1 | head -n 1)
SHA1_NAME=$(basename $SHA1_PATHNAME)
SHA256_PATHNAME=$(ls deploy/*[!-pi2].sha256 | head -n 1)
SHA256_NAME=$(basename $SHA256_PATHNAME)
echo ::set-output name=artifact_filename::${ARTIFACT_NAME}
echo ::set-output name=artifact_path::${ARTIFACT_PATHNAME}
echo ::set-output name=md5_filename::${MD5_NAME}
echo ::set-output name=md5_path::${MD5_PATHNAME}
echo ::set-output name=sha1_filename::${SHA1_NAME}
echo ::set-output name=sha1_path::${SHA1_PATHNAME}
echo ::set-output name=sha256_filename::${SHA256_NAME}
echo ::set-output name=sha256_path::${SHA256_PATHNAME}
-
name: Get Name of Artifact - pi2
id: get-artifact-name-pi2
run: |
ls -hla deploy/*
ARTIFACT_PATHNAME=$(ls deploy/*[-pi2].zip | head -n 1)
ARTIFACT_NAME=$(basename $ARTIFACT_PATHNAME)
MD5_PATHNAME=$(ls deploy/*[-pi2].img.md5 | head -n 1)
MD5_NAME=$(basename $MD5_PATHNAME)
SHA1_PATHNAME=$(ls deploy/*[-pi2].sha1 | head -n 1)
SHA1_NAME=$(basename $SHA1_PATHNAME)
SHA256_PATHNAME=$(ls deploy/*[-pi2].sha256 | head -n 1)
SHA256_NAME=$(basename $SHA256_PATHNAME)
echo ::set-output name=artifact_filename::${ARTIFACT_NAME}
echo ::set-output name=artifact_path::${ARTIFACT_PATHNAME}
echo ::set-output name=md5_filename::${MD5_NAME}
echo ::set-output name=md5_path::${MD5_PATHNAME}
echo ::set-output name=sha1_filename::${SHA1_NAME}
echo ::set-output name=sha1_path::${SHA1_PATHNAME}
echo ::set-output name=sha256_filename::${SHA256_NAME}
echo ::set-output name=sha256_path::${SHA256_PATHNAME}
-
name: Upload build artifacts
id: upload_deploy
uses: actions/upload-artifact@v4
with:
name: deploy
path: |
${{ steps.get-artifact-name.outputs.artifact_path }}
${{ steps.get-artifact-name.outputs.md5_path }}
${{ steps.get-artifact-name.outputs.sha1_path }}
${{ steps.get-artifact-name.outputs.sha256_path }}
${{ steps.get-artifact-name-pi2.outputs.artifact_path }}
${{ steps.get-artifact-name-pi2.outputs.md5_path }}
${{ steps.get-artifact-name-pi2.outputs.sha1_path }}
${{ steps.get-artifact-name-pi2.outputs.sha256_path }}
./pi-gen/deploy/build.log
release:
name: Create release
needs: [buildimage]
if:
contains(github.event.inputs.version,'csng')
runs-on: ubuntu-latest
steps:
-
name: Create GitHub release
id: create_release
uses: release-drafter/release-drafter@v5
with:
version: ${{needs.version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Download artifact
uses: actions/download-artifact@v4
with:
name: deploy
-
name: Get Name of Artifact
id: get-artifact-name
run: |
ls -hla deploy/*
ARTIFACT_PATHNAME=$(ls deploy/*[!-pi2].zip | head -n 1)
ARTIFACT_NAME=$(basename $ARTIFACT_PATHNAME)
MD5_PATHNAME=$(ls deploy/*[!-pi2].img.md5 | head -n 1)
MD5_NAME=$(basename $MD5_PATHNAME)
SHA1_PATHNAME=$(ls deploy/*[!-pi2].sha1 | head -n 1)
SHA1_NAME=$(basename $SHA1_PATHNAME)
SHA256_PATHNAME=$(ls deploy/*[!-pi2].sha256 | head -n 1)
SHA256_NAME=$(basename $SHA256_PATHNAME)
echo ::set-output name=artifact_filename::${ARTIFACT_NAME}
echo ::set-output name=artifact_path::${ARTIFACT_PATHNAME}
echo ::set-output name=md5_filename::${MD5_NAME}
echo ::set-output name=md5_path::${MD5_PATHNAME}
echo ::set-output name=sha1_filename::${SHA1_NAME}
echo ::set-output name=sha1_path::${SHA1_PATHNAME}
echo ::set-output name=sha256_filename::${SHA256_NAME}
echo ::set-output name=sha256_path::${SHA256_PATHNAME}
-
name: Get Name of Artifact - pi2
id: get-artifact-name-pi2
run: |
ls -hla deploy/*
ARTIFACT_PATHNAME=$(ls deploy/*[-pi2].zip | head -n 1)
ARTIFACT_NAME=$(basename $ARTIFACT_PATHNAME)
MD5_PATHNAME=$(ls deploy/*[-pi2].img.md5 | head -n 1)
MD5_NAME=$(basename $MD5_PATHNAME)
SHA1_PATHNAME=$(ls deploy/*[-pi2].sha1 | head -n 1)
SHA1_NAME=$(basename $SHA1_PATHNAME)
SHA256_PATHNAME=$(ls deploy/*[-pi2].sha256 | head -n 1)
SHA256_NAME=$(basename $SHA256_PATHNAME)
echo ::set-output name=artifact_filename::${ARTIFACT_NAME}
echo ::set-output name=artifact_path::${ARTIFACT_PATHNAME}
echo ::set-output name=md5_filename::${MD5_NAME}
echo ::set-output name=md5_path::${MD5_PATHNAME}
echo ::set-output name=sha1_filename::${SHA1_NAME}
echo ::set-output name=sha1_path::${SHA1_PATHNAME}
echo ::set-output name=sha256_filename::${SHA256_NAME}
echo ::set-output name=sha256_path::${SHA256_PATHNAME}
-
name: Upload Release Asset
id: upload-release-asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # 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
asset_path: ${{ steps.get-artifact-name.outputs.artifact_path }}
asset_name: ${{ steps.get-artifact-name.outputs.artifact_filename }}
asset_content_type: application/zip
-
name: Upload Release Asset -pi2
id: upload-release-asset-pi2
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # 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
asset_path: ${{ steps.get-artifact-name-pi2.outputs.artifact_path }}
asset_name: ${{ steps.get-artifact-name-pi2.outputs.artifact_filename }}
asset_content_type: application/zip
-
name: Upload Release MD5
id: upload-release-md5
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # 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
asset_path: ${{ steps.get-artifact-name.outputs.md5_path }}
asset_name: ${{ steps.get-artifact-name.outputs.md5_filename }}
asset_content_type: text/plain
-
name: Upload Release MD5 -pi2
id: upload-release-md5-pi2
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # 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
asset_path: ${{ steps.get-artifact-name-pi2.outputs.md5_path }}
asset_name: ${{ steps.get-artifact-name-pi2.outputs.md5_filename }}
asset_content_type: text/plain
-
name: Upload Release SHA1
id: upload-release-sha1
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # 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
asset_path: ${{ steps.get-artifact-name.outputs.sha1_path }}
asset_name: ${{ steps.get-artifact-name.outputs.sha1_filename }}
asset_content_type: text/plain
-
name: Upload Release SHA1 -pi2
id: upload-release-sha1-pi2
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # 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
asset_path: ${{ steps.get-artifact-name-pi2.outputs.sha1_path }}
asset_name: ${{ steps.get-artifact-name-pi2.outputs.sha1_filename }}
asset_content_type: text/plain
-
name: Upload Release SHA256
id: upload-release-SHA256
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # 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
asset_path: ${{ steps.get-artifact-name.outputs.sha256_path }}
asset_name: ${{ steps.get-artifact-name.outputs.sha256_filename }}
asset_content_type: text/plain
-
name: Upload Release SHA256 -pi2
id: upload-release-SHA256-pi2
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # 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
asset_path: ${{ steps.get-artifact-name-pi2.outputs.sha256_path }}
asset_name: ${{ steps.get-artifact-name-pi2.outputs.sha256_filename }}
asset_content_type: text/plain