File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3939 run : |
4040 echo "commit-date=$(git log --date=iso8601-strict -1 --pretty=%ct)" >> "$GITHUB_OUTPUT"
4141 echo "commit=$GITHUB_SHA" >> "$GITHUB_OUTPUT"
42- echo "version=$(git describe --tags --always --dirty | cut -c2- )" >> "$GITHUB_OUTPUT"
42+ echo "version=$(git describe --tags --always --dirty)" >> "$GITHUB_OUTPUT"
4343 echo "tree-state=$(if git diff --quiet; then echo "clean"; else echo "dirty"; fi)" >> "$GITHUB_OUTPUT"
44-
4544 # ========================================================================================================================================
4645 # Prerequesite: Create a .slsa-goreleaser.yml in the root directory of your project.
4746 # See format in https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/go/README.md#configuration-file
@@ -50,10 +49,16 @@ jobs:
5049 permissions :
5150 id-token : write # To sign.
5251 contents : write # To upload release assets.
53- actions : read # To read workflow path.
52+ actions : read # To read workflow path.
53+ strategy :
54+ matrix :
55+ os : [linux, windows, darwin]
56+ arch : [amd64, arm64]
5457 uses : slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml@v1.4.0
58+ needs : args
5559 with :
5660 go-version : 1.19
61+ config-file : .slsa-goreleaser/${{matrix.os}}-${{matrix.arch}}.yml
5762 # =============================================================================================================
5863 # Optional: For more options, see https://github.com/slsa-framework/slsa-github-generator#golang-projects
5964 # =============================================================================================================
Original file line number Diff line number Diff line change 1+ import yaml from "https://esm.sh/yaml@2.2.1" ;
2+
3+ const f = ".github/workflows/go-ossf-slsa3-publish.yml" ;
4+ const root = await Deno . readTextFile ( f ) . then ( ( r ) => yaml . parse ( r ) ) ;
5+
6+ const matrix = root . jobs . build . strategy . matrix ;
7+ /**@type {string } */
8+ const fileFomat = root . jobs . build . with [ "config-file" ] ;
9+
10+ const tpl = await Deno . readTextFile ( ".slsa-goreleaser.yml" ) ;
11+
12+ let tasks = [ ] ;
13+ for ( let os of matrix . os ) {
14+ for ( let arch of matrix . arch ) {
15+ let n = tpl . replace ( "{{goos}}" , os ) . replace ( "{{goarch}}" , arch ) ;
16+ let f = fileFomat
17+ . replace ( "${{matrix.os}}" , os )
18+ . replace ( "${{matrix.arch}}" , arch ) ;
19+ let task = Deno . writeTextFile ( f , n ) ;
20+ tasks . push ( task ) ;
21+ }
22+ }
23+
24+ await Promise . all ( tasks ) ;
25+ console . log ( "generator finish" ) ;
Original file line number Diff line number Diff line change @@ -4,23 +4,18 @@ version: 1
44# (Optional) List of env variables used during compilation.
55env :
66 - GO111MODULE=on
7- - CGO_ENABLED=1
7+ - CGO_ENABLED=0
88
99# (Optional) Flags for the compiler.
1010flags :
1111 - -trimpath
1212 - -tags=netgo
1313
1414# The OS to compile for. `GOOS` env variable will be set to this value.
15- goos :
16- - windows
17- - linux
18- - darwin
15+ goos : " {{goos}}"
1916
2017# The architecture to compile for. `GOARCH` env variable will be set to this value.
21- goarch :
22- - amd64
23- - arm64
18+ goarch : " {{goarch}}"
2419
2520# (Optional) Entrypoint to compile.
2621main : ./cmd/lcode-hub
@@ -35,7 +30,4 @@ binary: lcode-hub-{{ .Os }}-{{ .Arch }}
3530
3631# (Optional) ldflags generated dynamically in the workflow, and set as the `evaluated-envs` input variables in the workflow.
3732ldflags :
38- - " -X main.Version={{ .Env.VERSION }}"
39- - " -X main.Commit={{ .Env.COMMIT }}"
40- - " -X main.CommitDate={{ .Env.COMMIT_DATE }}"
41- - " -X main.TreeState={{ .Env.TREE_STATE }}"
33+ - " -X main.Version={{ .Env.VERSION }}"
You can’t perform that action at this time.
0 commit comments