1+ # SPDX-License-Identifier: MPL-2.0
12name : CI for meson build
23
34on :
4041 release_extension : " .zip" ,
4142 archive_command : " 7z a -tzip -mmt"
4243 }
44+ - {
45+ name : " Windows MSVC ARM64" ,
46+ os : windows-latest,
47+ cc : " cl.exe" ,
48+ cxx : " cl.exe" ,
49+ arch : " x64_arm64" ,
50+ publish_release : true,
51+ meson_opts : " -Db_vscrt=static_from_buildtype --cross-file=./meson_crosscompile/msvc_arm64.txt" ,
52+ release_name : " win-ARM64" ,
53+ release_extension : " .zip" ,
54+ archive_command : " 7z a -tzip -mmt"
55+ }
4356 - {
4457 name : " Windows GCC" ,
4558 os : windows-latest,
5467 os : windows-latest,
5568 cc : " clang.exe" ,
5669 cxx : " clang++.exe" ,
70+ meson_opts : " --native-file=./meson_crosscompile/Windows-Clang.txt" ,
5771 release_name : " win-x86_64-clang" ,
5872 release_extension : " .zip" ,
5973 archive_command : " 7z a -tzip -mmt"
@@ -76,24 +90,13 @@ jobs:
7690 release_extension : " .tar.xz" ,
7791 archive_command : " tar cvfJ"
7892 }
79- - {
80- name : " Manylinux GCC" ,
81- os : ubuntu-latest,
82- image : " quay.io/pypa/manylinux2014_x86_64" ,
83- cc : " gcc" ,
84- cxx : " g++" ,
85- publish_release : true,
86- create_package : true,
87- release_name : " linux-x86_64-manylinux" ,
88- release_extension : " .tar.xz" ,
89- archive_command : " tar cvfJ"
90- }
9193 - {
9294 name : " MUSL Cross Compile x86_64" ,
9395 os : ubuntu-latest,
9496 cc : " " ,
9597 cxx : " " ,
9698 publish_release : true,
99+ create_package : true,
97100 meson_opts : " --cross-file=./meson_crosscompile/x86_64-linux-musl-cross.txt" ,
98101 cross_compiler_arch : " x86_64" ,
99102 release_name : " linux-x86_64-portable" ,
@@ -184,9 +187,24 @@ jobs:
184187 release_extension : " .tar.xz" ,
185188 archive_command : " tar cvfJ"
186189 }
190+ outputs : # where hashes need to be stored for slsa provenance
191+ # NOTE: Only doing this for builds with "publish_release: true"
192+ # format is hash-${{release_name}} for the zipped packages
193+ #
194+ hash-win-x64 : ${{ steps.hash.outputs.hash-win-x64 }}
195+ hash-win-x86 : ${{ steps.hash.outputs.hash-win-x86 }}
196+ hash-win-ARM64 : ${{ steps.hash.outputs.hash-win-ARM64 }}
197+ hash-linux-x86_64-portable : ${{ steps.hash.outputs.hash-linux-x86_64-portable }}
198+ hash-linux-i686-portable : ${{ steps.hash.outputs.hash-linux-i686-portable }}
199+ hash-linux-aarch64-portable : ${{ steps.hash.outputs.hash-linux-aarch64-portable }}
200+ hash-linux-armv7l-portable : ${{ steps.hash.outputs.hash-linux-armv7l-portable }}
201+ hash-linux-armv6-portable : ${{ steps.hash.outputs.hash-linux-armv6-portable }}
202+ hash-linux-armv5l-portable : ${{ steps.hash.outputs.hash-linux-armv5l-portable }}
203+ hash-linux-powerpc64-portable : ${{ steps.hash.outputs.hash-linux-powerpc64-portable }}
204+ hash-linux-powerpc64le-portable : ${{ steps.hash.outputs.hash-linux-powerpc64le-portable }}
187205
188206 steps :
189- - uses : actions/checkout@v3
207+ - uses : actions/checkout@v4
190208 with :
191209 submodules : recursive
192210
@@ -210,7 +228,7 @@ jobs:
210228 - name : Restore LLVM from cache
211229 if : startsWith(matrix.config.name, 'Windows Clang')
212230 id : llvm-cache
213- uses : actions/cache@v3
231+ uses : actions/cache@v4
214232 with :
215233 path : C:/Program Files/LLVM
216234 key : ' llvm-llvm-project-relid-${{ env.LLVM_RELID }}'
@@ -222,13 +240,6 @@ jobs:
222240 Invoke-WebRequest -Headers $headers -OutFile "LLVM.exe" ((Invoke-WebRequest -Headers $headers "https://api.github.com/repos/llvm/llvm-project/releases/$($env:LLVM_RELID)").Content | ConvertFrom-Json | Select-Object -ExpandProperty assets | Where -Property name -Like "*win64.exe" | Select-Object -First 1).browser_download_url
223241 7z x LLVM.exe -y -o"C:/Program Files/LLVM"
224242
225- - name : Setup toolchain for Manylinux
226- if : ${{ matrix.config.image == 'quay.io/pypa/manylinux2014_x86_64' }}
227- shell : bash
228- run : |
229- if [[ ${{ matrix.config.cc }} == "clang" ]] ; then yum install -y clang compat-gcc-44 ; fi
230- echo "/opt/python/cp310-cp310/bin" >> $GITHUB_PATH
231-
232243 - name : Escape backslash in branch name
233244 shell : bash
234245 run : echo "BRANCH_NAME=$(echo ${{ github.ref_name }} | tr / -)" >> $GITHUB_ENV
@@ -245,7 +256,7 @@ jobs:
245256 CC : ${{ matrix.config.cc }}
246257 CXX : ${{ matrix.config.cxx }}
247258 run : |
248- pip install meson==0.60.3 ninja
259+ pip install meson ninja
249260 meson setup build -Dprefix=/ -Dmandir=/man -Dbindir=/ ${{ matrix.config.meson_opts }} --buildtype=release
250261 meson install -C build
251262
@@ -258,16 +269,17 @@ jobs:
258269 shell : bash
259270
260271 # add `GOBIN` to the `PATH` otherwise nfpm in next step can't be found
261- - uses : actions/setup-go@v3
272+ - uses : actions/setup-go@v5
262273 if : ${{ matrix.config.create_package }}
263274 with :
264275 go-version : ' stable'
276+ cache : false
265277
266278 - name : Create packages
267279 if : ${{ matrix.config.create_package }}
268280 working-directory : ${{ format('build/{0}', env.DESTDIR) }}
269281 run : | # https://nfpm.goreleaser.com/install/
270- go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.22.2
282+ go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.36.1
271283 if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9\.]+$ ]]; then
272284 version=$(echo ${{ github.ref_name }} | tr -d 'v')
273285 else
@@ -278,19 +290,61 @@ jobs:
278290 nfpm package -f ../../nfpm.yaml -p rpm -t ..
279291 shell : bash
280292
293+ - name : Generate Hashes
294+ if : ${{ matrix.config.publish_release }}
295+ shell : bash
296+ id : hash
297+ run : |
298+ # sha256sum generates sha256 hash for all artifacts.
299+ # base64 -w0 encodes to base64 and outputs on a single line.
300+ # sha256sum artifact | base64 -w0
301+ # NOTE: Using suggested method to generate sha across OS's from slsa documentation
302+ # https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/generic/README.md#provenance-for-artifacts-built-across-multiple-operating-systems
303+ set -euo pipefail
304+ (sha256sum -t ${{ format('./build/{0}{1}', env.DESTDIR, matrix.config.release_extension) }} || shasum -a 256 ${{ format('./build/{0}{1}', env.DESTDIR, matrix.config.release_extension) }}) > checksum
305+ echo "hash-${{ matrix.config.release_name }}=$(base64 -w0 checksum || base64 checksum)" >> "${GITHUB_OUTPUT}"
306+
281307 - name : Uploading artifacts
282- uses : actions/upload-artifact@v3
308+ uses : actions/upload-artifact@v4
283309 with :
310+ name : ${{ format('{0}', matrix.config.release_name) }}
284311 path : |
285312 ${{ format('./build/{0}{1}', env.DESTDIR, matrix.config.release_extension) }}
286313 build/*.deb
287314 build/*.rpm
288315
289316 - name : Publish release
290317 if : ${{ startsWith(github.ref, 'refs/tags/v') && matrix.config.publish_release }}
291- uses : softprops/action-gh-release@v1
318+ uses : softprops/action-gh-release@v2
292319 with :
293320 files : |
294321 ${{ format('./build/{0}{1}', env.DESTDIR, matrix.config.release_extension) }}
295322 build/*.deb
296323 build/*.rpm
324+
325+ # This step takes all the generated hashes from all build targets and combines them so slsa provenance step can run
326+ combine_hashes :
327+ runs-on : ubuntu-latest
328+ needs : [build]
329+ outputs :
330+ hashes : ${{ steps.hashes.outputs.hashes }}
331+ env :
332+ HASHES : ${{ toJSON(needs.build.outputs) }}
333+ steps :
334+ - id : hashes
335+ run : |
336+ echo "$HASHES"
337+ echo "$HASHES" | jq -r '.[] | @base64d' | sed "/^$/d" > hashes.txt
338+ echo "hashes=$(cat hashes.txt | base64 -w0)" >> "$GITHUB_OUTPUT"
339+
340+ # Generate the slsa provenance
341+ provenance :
342+ needs : [combine_hashes]
343+ permissions :
344+ actions : read # To read the workflow path.
345+ id-token : write # To sign the provenance.
346+ contents : write # To add assets to a release.
347+ uses :
slsa-framework/slsa-github-generator/.github/workflows/[email protected] 348+ with :
349+ base64-subjects : " ${{ needs.combine_hashes.outputs.hashes }}"
350+ upload-assets : true # Optional: Upload to a new release
0 commit comments