Skip to content

Commit

Permalink
fix SLSA goreleaser ldflags config to embed version info to executabl…
Browse files Browse the repository at this point in the history
…es (#119)

* update goreleaser action

Signed-off-by: hirokuni-kitahara <[email protected]>

* fix slsa goreleaser config

Signed-off-by: hirokuni-kitahara <[email protected]>

* fix slsa goreleaser ldflags

Signed-off-by: hirokuni-kitahara <[email protected]>

* fix slsa goreleaser ldflags

Signed-off-by: hirokuni-kitahara <[email protected]>

* fix slsa goreleaser ldflags

Signed-off-by: hirokuni-kitahara <[email protected]>

---------

Signed-off-by: hirokuni-kitahara <[email protected]>
  • Loading branch information
hirokuni-kitahara authored Jan 10, 2024
1 parent 3337819 commit bb4663e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/slsa-goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
commit: ${{ steps.ldflags.outputs.commit }}
version: ${{ steps.ldflags.outputs.version }}
tree-state: ${{ steps.ldflags.outputs.tree-state }}
version-package: github.com/sigstore/k8s-manifest-sigstore/pkg/util
steps:
- id: checkout
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # tag=v2.3.4
Expand All @@ -37,33 +38,33 @@ jobs:
contents: write # To upload assets to release.
actions: read # To read the workflow path.
needs: args
uses: slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml@v1.2.2
uses: slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml@v1.9.0
with:
config-file: .slsa-goreleaser-linux-amd64.yml
go-version: 1.21
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}}"
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}}, VERSION_PKG:${{needs.args.outputs.version-package}}"

build-darwin-amd64:
permissions:
id-token: write # To sign the provenance.
contents: write # To upload assets to release.
actions: read # To read the workflow path.
needs: args
uses: slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml@v1.2.2
uses: slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml@v1.9.0
with:
config-file: .slsa-goreleaser-darwin-amd64.yml
go-version: 1.21
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}}"
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}}, VERSION_PKG:${{needs.args.outputs.version-package}}"

build-windows-amd64:
permissions:
id-token: write # To sign the provenance.
contents: write # To upload assets to release.
actions: read # To read the workflow path.
needs: args
uses: slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml@v1.2.2
uses: slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml@v1.9.0
with:
config-file: .slsa-goreleaser-windows-amd64.yml
go-version: 1.21
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}}"
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}}, VERSION_PKG:${{needs.args.outputs.version-package}}"

8 changes: 4 additions & 4 deletions .slsa-goreleaser-darwin-amd64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ binary: kubectl-sigstore-darwin-amd64

# (Optional) ldflags generated dynamically in the workflow, and set as the `evaluated-envs` input variables in the workflow.
ldflags:
- "-X main.Version={{ .Env.VERSION }}"
- "-X main.Commit={{ .Env.COMMIT }}"
- "-X main.CommitDate={{ .Env.COMMIT_DATE }}"
- "-X main.TreeState={{ .Env.TREE_STATE }}"
- "-X '{{ .Env.VERSION_PKG }}.GitVersion={{ .Env.VERSION }}'"
- "-X '{{ .Env.VERSION_PKG }}.gitCommit={{ .Env.COMMIT }}'"
- "-X '{{ .Env.VERSION_PKG }}.buildDate={{ .Env.COMMIT_DATE }}'"
- "-X '{{ .Env.VERSION_PKG }}.gitTreeState={{ .Env.TREE_STATE }}'"
8 changes: 4 additions & 4 deletions .slsa-goreleaser-linux-amd64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ binary: kubectl-sigstore-linux-{{ .Arch }}

# (Optional) ldflags generated dynamically in the workflow, and set as the `evaluated-envs` input variables in the workflow.
ldflags:
- "-X main.Version={{ .Env.VERSION }}"
- "-X main.Commit={{ .Env.COMMIT }}"
- "-X main.CommitDate={{ .Env.COMMIT_DATE }}"
- "-X main.TreeState={{ .Env.TREE_STATE }}"
- "-X '{{ .Env.VERSION_PKG }}.GitVersion={{ .Env.VERSION }}'"
- "-X '{{ .Env.VERSION_PKG }}.gitCommit={{ .Env.COMMIT }}'"
- "-X '{{ .Env.VERSION_PKG }}.buildDate={{ .Env.COMMIT_DATE }}'"
- "-X '{{ .Env.VERSION_PKG }}.gitTreeState={{ .Env.TREE_STATE }}'"
9 changes: 4 additions & 5 deletions .slsa-goreleaser-windows-amd64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ binary: kubectl-sigstore-windows-amd64

# (Optional) ldflags generated dynamically in the workflow, and set as the `evaluated-envs` input variables in the workflow.
ldflags:
- -buildmode=exe
- "-X main.Version={{ .Env.VERSION }}"
- "-X main.Commit={{ .Env.COMMIT }}"
- "-X main.CommitDate={{ .Env.COMMIT_DATE }}"
- "-X main.TreeState={{ .Env.TREE_STATE }}"
- "-X '{{ .Env.VERSION_PKG }}.GitVersion={{ .Env.VERSION }}'"
- "-X '{{ .Env.VERSION_PKG }}.gitCommit={{ .Env.COMMIT }}'"
- "-X '{{ .Env.VERSION_PKG }}.buildDate={{ .Env.COMMIT_DATE }}'"
- "-X '{{ .Env.VERSION_PKG }}.gitTreeState={{ .Env.TREE_STATE }}'"

0 comments on commit bb4663e

Please sign in to comment.