@@ -29,6 +29,7 @@ project simply generates provenance as a separate step in an existing workflow.
29
29
- [ Provenance for Bazel] ( #provenance-for-bazel )
30
30
- [ Provenance for Java] ( #provenance-for-java )
31
31
- [ Provenance for Rust] ( #provenance-for-rust )
32
+ - [ Provenance for Haskell] ( #provenance-for-haskell )
32
33
33
34
---
34
35
@@ -403,7 +404,7 @@ jobs:
403
404
run: |
404
405
# Your normal build workflow targets here
405
406
bazel build //path/to/target_binary //path/to_another/binary
406
-
407
+
407
408
# Copy the binaries.
408
409
cp bazel-bin/path/to/target_binary .
409
410
cp bazel-bin/path/to/another/binary .
@@ -425,7 +426,7 @@ jobs:
425
426
` ` `
426
427
427
428
4. Call the generic workflow to generate provenance by declaring the job below :
428
-
429
+
429
430
` ` ` yaml
430
431
provenance:
431
432
needs: [build]
@@ -456,7 +457,7 @@ jobs:
456
457
run: |
457
458
# Your normal build workflow targets here
458
459
bazel build //path/to/target_binary //path/to_another/binary
459
-
460
+
460
461
# Copy the binaries.
461
462
cp bazel-bin/path/to/target_binary .
462
463
cp bazel-bin/path/to/another/binary .
@@ -512,7 +513,7 @@ jobs:
512
513
run: |
513
514
# Your normal build workflow targets here
514
515
mvn clean package
515
-
516
+
516
517
# Save the location of the maven output files for easier reference
517
518
ARTIFACT_PATTERN=./target/$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)-$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)*.jar
518
519
echo "::set-output name=artifact_pattern::$ARTIFACT_PATTERN"
@@ -563,7 +564,7 @@ jobs:
563
564
run: |
564
565
# Your normal build workflow targets here
565
566
mvn clean package
566
-
567
+
567
568
# Save the location of the maven output files for easier reference
568
569
ARTIFACT_PATTERN=./target/$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)-$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)*.jar
569
570
echo "::set-output name=artifact_pattern::$ARTIFACT_PATTERN"
@@ -572,7 +573,7 @@ jobs:
572
573
id: hash
573
574
run: |
574
575
echo "::set-output name=hashes::$(sha256sum ${{ steps.build.outputs.artifact_pattern }} | base64 -w0)"
575
-
576
+
576
577
- name: Upload build artifacts
577
578
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=v3
578
579
with:
@@ -606,7 +607,7 @@ jobs:
606
607
` ` `
607
608
608
609
2. Add an `id : build` field to your gradle build ste:
609
-
610
+
610
611
` ` ` yaml
611
612
steps:
612
613
[...]
@@ -665,7 +666,7 @@ jobs:
665
666
id: hash
666
667
run: |
667
668
echo "::set-output name=hashes::$(sha256sum ./build/libs/* | base64 -w0)"
668
-
669
+
669
670
- name: Upload build artifacts
670
671
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=v3
671
672
with:
@@ -778,4 +779,109 @@ jobs:
778
779
base64-subjects: "${{ needs.build.outputs.hashes }}"
779
780
upload-assets: true # Optional: Upload to a new release
780
781
781
- ` ` `
782
+ ` ` `
783
+
784
+ # ## Provenance for Haskell
785
+
786
+ If you use [Haskell](https://www.haskell.org/) (either via
787
+ [`cabal`](https://www.haskell.org/cabal/) or
788
+ [`stack`](https://docs.haskellstack.org/en/stable/README/)) to generate your
789
+ artifacts, you can easily generate SLSA3 provenance by updating your existing
790
+ workflow with the steps indicated in the workflow below.
791
+
792
+ 1. Declare an `outputs` for the hashes :
793
+
794
+ ` ` ` yaml
795
+ jobs:
796
+ build:
797
+ outputs:
798
+ hashes: ${{ steps.hash.outputs.hashes }}
799
+
800
+ ` ` `
801
+
802
+ 2. Build your binaries. Then add a step to generate the provenance subjects as shown below. Update the sha256 sum arguments to include all binaries that you generate provenance for :
803
+
804
+ ` ` ` yaml
805
+ steps:
806
+ [...]
807
+ - name: Build using Haskell
808
+ run: |
809
+ # Your normal build workflow targets here.
810
+ cabal build # or stack build
811
+
812
+ # Copy the binary to the root directory for easier reference
813
+ # For Cabal, use the following command
814
+ cp $(cabal list-bin .) .
815
+ # For Stack, use the following command instead
816
+ # cp $(stack path --local-install-root)/bin/target_binary .
817
+
818
+ # Generate the subject.
819
+ - name: Generate subject
820
+ id: hash
821
+ run: |
822
+ set -euo pipefail
823
+
824
+ echo "::set-output name=hashes::$(sha256sum target_binary | base64 -w0)"
825
+
826
+ ` ` `
827
+
828
+ 3. Call the generic workflow to generate provenance by declaring the job below :
829
+
830
+ ` ` ` yaml
831
+ provenance:
832
+ needs: [build]
833
+ permissions:
834
+ actions: read # To read the workflow path.
835
+ id-token: write # To sign the provenance.
836
+ contents: write # To add assets to a release.
837
+ uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
838
+ with:
839
+ base64-subjects: "${{ needs.build.outputs.hashes }}"
840
+ upload-assets: true # Optional: Upload to a new release
841
+
842
+ ` ` `
843
+
844
+ All in all, it will look as the following :
845
+
846
+ ` ` ` yaml
847
+ jobs:
848
+ build:
849
+ outputs:
850
+ hashes: ${{ steps.hash.outputs.hashes }}
851
+
852
+ steps:
853
+ - name: Checkout repository
854
+ uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
855
+ - name: Setup Haskell
856
+ uses: haskell/actions/setup@745062a754c3c4b70b87cb93937ad443096cc94d # tag=v1
857
+
858
+ - name: Build using Haskell
859
+ run: |
860
+ # Your normal build workflow targets here.
861
+ cabal build # or stack build
862
+
863
+ # Copy the binary to the root directory for easier reference
864
+ # For Cabal, use the following command
865
+ cp $(cabal list-bin .) .
866
+ # For Stack, use the following command instead
867
+ # cp $(stack path --local-install-root)/bin/target_binary .
868
+
869
+ # Generate the subject.
870
+ - name: Generate subject
871
+ id: hash
872
+ run: |
873
+ set -euo pipefail
874
+
875
+ echo "::set-output name=hashes::$(sha256sum target_binary | base64 -w0)"
876
+
877
+ provenance:
878
+ needs: [build]
879
+ permissions:
880
+ actions: read # To read the workflow path.
881
+ id-token: write # To sign the provenance.
882
+ contents: write # To add assets to a release.
883
+ uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
884
+ with:
885
+ base64-subjects: "${{ needs.build.outputs.hashes }}"
886
+ upload-assets: true # Optional: Upload to a new release
887
+ ` ` `
0 commit comments