-
-
Notifications
You must be signed in to change notification settings - Fork 263
245 lines (242 loc) · 8.57 KB
/
pifile.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
name: Pifile
on:
# push:
workflow_dispatch:
inputs:
version:
description: 'Version'
jobs:
version:
outputs:
version: ${{ steps.get_version.outputs.version }}
buildname: ${{ steps.get_version.outputs.buildname }}
runs-on: "ubuntu-20.04"
steps:
-
name: Checkout repository
uses: actions/checkout@v1
-
name: Get the version
id: get_version
run: |
if [ -z "$version" ]
then
version=$(date '+%Y%m%d')
echo ::set-output name=version::"${version}"
else
echo ::set-output name=version::"${version}"
fi
builddate=$(date '+%Y-%m-%d')
buildbranch='crankshaft-ng'
buildhash=$(git rev-parse --short "$GITHUB_SHA")
buildname="${builddate}-${buildbranch}-${buildhash}"
echo ::set-output name=version::${version}
echo ::set-output name=buildhash::${buildhash}
echo ::set-output name=buildbranch::${buildbranch}
echo ::set-output name=builddate::${builddate}
echo ::set-output name=buildname::${buildname}
env:
version: ${{ github.event.inputs.version }}
build:
runs-on: ${{ matrix.host }}
needs: [ version ]
strategy:
fail-fast: false
max-parallel: 3
matrix:
host: [
"ubuntu-latest",
#"macos-10.15",
]
config:
- {
name: "Debian Buster armhf",
basefile: "updater/base_buster_armhf",
arch: "armhf",
osname: "buster",
ostype: "Debian"
}
- {
name: "Debian Buster arm7",
basefile: "updater/base_buster_arm7",
arch: "arm7",
osname: "buster",
ostype: "Debian"
}
name: 'Build: ${{ matrix.config.name }}'
steps:
-
name: Checkout repository
uses: actions/checkout@v1
-
name: Get the version
id: get_version
run: |
if [ -n "$ostype" ]
then
osname=${ostype}_${osname}
fi
echo ::set-output name=version::"${version}-${osname}-${arch}"
env:
version: ${{needs.version.outputs.version }}
arch: ${{ matrix.config.arch }}
ostype: ${{ matrix.config.ostype }}
osname: ${{ matrix.config.osname }}
-
name: Create Base Image
uses: Nature40/[email protected]
with:
pifile: ${{ matrix.config.basefile }}.Pifile
-
name: Rename Image
run: mv ${{ matrix.config.basefile }}.img crankshaft-${{needs.version.outputs.buildname }}.img
-
name: Package zip
id: packagezip
run: |
IMG_FILENAME="crankshaft-${{needs.version.outputs.buildname }}.img"
ZIP_FILENAME="crankshaft-${{needs.version.outputs.buildname }}.zip"
MD5HASH="${IMG_FILENAME}.md5"
SHA1HASH="${IMG_FILENAME}.sha1"
SHA256HASH="${IMG_FILENAME}.sha256"
md5sum "${IMG_FILENAME}" > "${MD5HASH}"
sha1sum "${IMG_FILENAME}" > "${SHA1HASH}"
sha256sum "${IMG_FILENAME}" > "${SHA256HASH}"
zip "${ZIP_FILENAME}" "${IMG_FILENAME}" "${MD5HASH}" "${SHA1HASH}" "${SHA256HASH}"
echo ::set-output name=ZIP_FILENAME::"${ZIP_FILENAME}"
echo ::set-output name=MD5HASH::"${MD5HASH}"
echo ::set-output name=SHA1HASH::"${SHA1HASH}"
echo ::set-output name=SHA256HASH::"${SHA256HASH}"
-
name: Upload build artifacts
id: upload_deploy
uses: actions/upload-artifact@v2
with:
name: ${{ steps.get_version.outputs.version }}
path: |
${{ steps.packagezip.outputs.ZIP_FILENAME }}
${{ steps.packagezip.outputs.MD5HASH }}
${{ steps.packagezip.outputs.SHA1HASH }}
${{ steps.packagezip.outputs.SHA256HASH }}
# Create Release
release:
runs-on: ubuntu-latest
needs: [ version, build ]
name: 'Create release'
outputs:
release_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
steps:
-
name: Build Changelog
id: github_release
uses: mikepenz/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Create GitHub release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{needs.version.outputs.version }}
release_name: ${{needs.version.outputs.buildname }}
#body: ${{steps.github_release.outputs.changelog}}
draft: true
prerelease: true
# Upload release artifacts
upload:
needs: [ version, build, release ]
runs-on: ${{ matrix.host }}
strategy:
fail-fast: false
max-parallel: 3
matrix:
host: [
"ubuntu-latest",
#"macos-10.15",
]
config:
- {
name: "Debian Buster armhf",
basefile: "base_buster_armhf",
arch: "armhf",
osname: "buster",
ostype: "Debian"
}
- {
name: "Debian Buster arm7",
basefile: "updater/base_buster_arm7",
arch: "arm7",
osname: "buster",
ostype: "Debian"
}
name: 'Upload release: ${{ matrix.config.name }}'
steps:
-
name: Download build artifacts
uses: actions/[email protected]
with:
name: ${{ steps.get_version.outputs.version }}
-
name: Get Artifact Filenames
id: getfilenames
run: |
IMG_FILENAME="crankshaft-${{needs.version.outputs.buildname }}.img"
ZIP_FILENAME="crankshaft-${{needs.version.outputs.buildname }}.zip"
MD5HASH="${IMG_FILENAME}.md5"
SHA1HASH="${IMG_FILENAME}.sha1"
SHA256HASH="${IMG_FILENAME}.sha256"
zip "${ZIP_FILENAME}" "${IMG_FILENAME}" "${MD5HASH}" "${SHA1HASH}" "${SHA256HASH}"
echo ::set-output name=ZIP_FILENAME::"${ZIP_FILENAME}"
echo ::set-output name=MD5HASH::"${MD5HASH}"
echo ::set-output name=SHA1HASH::"${SHA1HASH}"
echo ::set-output name=SHA256HASH::"${SHA256HASH}"
-
name: Upload zip to release
id: upload_zip
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ needs.version.outputs.buildname }}
with:
upload_url: ${{needs.release.outputs.release_upload_url}}
asset_path: ${{ steps.getfilenames.outputs.ZIP_FILENAME }}
asset_name: ${{ steps.getfilenames.outputs.ZIP_FILENAME }}
asset_content_type: application/zip
-
name: Upload md5 to release
id: upload_md5
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ needs.version.outputs.buildname }}
with:
upload_url: ${{needs.release.outputs.release_upload_url}}
asset_path: ${{ steps.getfilenames.outputs.MD5HASH }}
asset_name: ${{ steps.getfilenames.outputs.MD5HASH }}
asset_content_type: text/plain
-
name: Upload sha1 to release
id: upload_sha1
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ needs.version.outputs.buildname }}
with:
upload_url: ${{needs.release.outputs.release_upload_url}}
asset_path: ${{ steps.getfilenames.outputs.SHA1HASH }}
asset_name: ${{ steps.getfilenames.outputs.SHA1HASH }}
asset_content_type: text/plain
-
name: Upload sha256 to release
id: upload_sha256
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ needs.version.outputs.buildname }}
with:
upload_url: ${{needs.release.outputs.release_upload_url}}
asset_path: ${{ steps.getfilenames.outputs.SHA256HASH }}
asset_name: ${{ steps.getfilenames.outputs.SHA256HASH }}
asset_content_type: text/plain