1- # This workflow uses actions that are not certified by GitHub.
2- # They are provided by a third-party and are governed by
3- # separate terms of service, privacy policy, and support
4- # documentation.
5-
6- # This workflow lets you compile your Go project using a SLSA3 compliant builder.
7- # This workflow will generate a so-called "provenance" file describing the steps
8- # that were performed to generate the final binary.
9- # The project is an initiative of the OpenSSF (openssf.org) and is developed at
10- # https://github.com/slsa-framework/slsa-github-generator.
11- # The provenance file can be verified using https://github.com/slsa-framework/slsa-verifier.
12- # For more information about SLSA and how it improves the supply-chain, visit slsa.dev.
13-
14- name : SLSA Go releaser
1+ name : SLSA go releaser
152on :
163 workflow_dispatch :
17- release :
18- types : [created]
4+ push :
5+ tags :
6+ - " *"
197
208permissions : read-all
219
2210jobs :
23- # ========================================================================================================================================
24- # Prerequesite: Create a .slsa-goreleaser.yml in the root directory of your project.
25- # See format in https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/go/README.md#configuration-file
26- # =========================================================================================================================================
11+ # Generate ldflags dynamically.
12+ # Optional: only needed for ldflags.
13+ args :
14+ runs-on : ubuntu-latest
15+ outputs :
16+ commit-date : ${{ steps.ldflags.outputs.commit-date }}
17+ commit : ${{ steps.ldflags.outputs.commit }}
18+ version : ${{ steps.ldflags.outputs.version }}
19+ tree-state : ${{ steps.ldflags.outputs.tree-state }}
20+ steps :
21+ - id : checkout
22+ uses : actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # tag=v2.3.4
23+ with :
24+ fetch-depth : 0
25+ - id : ldflags
26+ run : |
27+ echo "commit-date=$(git log --date=iso8601-strict -1 --pretty=%ct)" >> "$GITHUB_OUTPUT"
28+ echo "commit=$GITHUB_SHA" >> "$GITHUB_OUTPUT"
29+ echo "version=$(git describe --tags --always --dirty | cut -c2-)" >> "$GITHUB_OUTPUT"
30+ echo "tree-state=$(if git diff --quiet; then echo "clean"; else echo "dirty"; fi)" >> "$GITHUB_OUTPUT"
31+
32+ # Trusted builder.
2733 build :
2834 permissions :
29- id-token : write # To sign.
30- contents : write # To upload release assets.
31- actions : read # To read workflow path.
32- uses : slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml@v1.2.0
35+ id-token : write # To sign the provenance.
36+ contents : write # To upload assets to release.
37+ actions : read # To read the workflow path.
38+ needs : args
39+ uses : slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml@v1.2.2
3340 with :
34- go-version : 1.17
35- # =============================================================================================================
36- # Optional: For more options, see https://github.com/slsa-framework/slsa-github-generator#golang-projects
37- # =============================================================================================================
38-
41+ go-version : 1.19
42+ # Optional: only needed if using ldflags.
43+ evaluated-envs : " COMMIT_DATE:${{needs.args.outputs.commit-date}}, COMMIT:${{needs.args.outputs.commit}}, VERSION:${{needs.args.outputs.version}}, TREE_STATE:${{needs.args.outputs.tree-state}}"
0 commit comments