-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SLSA builder to release binary, and -version/-help flags (#5)
- Loading branch information
Showing
6 changed files
with
154 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Unfortunately, we can't have a single file with dynamic os/arch, so we have to define one file per target platform we want. | ||
|
||
See https://github.com/slsa-framework/slsa-github-generator/blob/v2.0.0/internal/builders/go/README.md#multi-platform-builds. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: 1 | ||
|
||
env: | ||
- CGO_ENABLED=0 | ||
|
||
flags: | ||
- -trimpath | ||
|
||
goos: darwin | ||
goarch: amd64 | ||
|
||
main: ./cmd/kueueleuleu/main.go | ||
|
||
binary: kueueleuleu-{{ .Os }}-{{ .Arch }} | ||
|
||
ldflags: | ||
- "-X main.version={{ .Env.VERSION }}" | ||
- "-X main.commit={{ .Env.COMMIT }}" | ||
- "-X main.commitDate={{ .Env.COMMIT_DATE }}" | ||
- "-X main.treeState={{ .Env.TREE_STATE }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: 1 | ||
|
||
env: | ||
- CGO_ENABLED=0 | ||
|
||
flags: | ||
- -trimpath | ||
|
||
goos: darwin | ||
goarch: arm64 | ||
|
||
main: ./cmd/kueueleuleu/main.go | ||
|
||
binary: kueueleuleu-{{ .Os }}-{{ .Arch }} | ||
|
||
ldflags: | ||
- "-X main.version={{ .Env.VERSION }}" | ||
- "-X main.commit={{ .Env.COMMIT }}" | ||
- "-X main.commitDate={{ .Env.COMMIT_DATE }}" | ||
- "-X main.treeState={{ .Env.TREE_STATE }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: 1 | ||
|
||
env: | ||
- CGO_ENABLED=0 | ||
|
||
flags: | ||
- -trimpath | ||
|
||
goos: linux | ||
goarch: amd64 | ||
|
||
main: ./cmd/kueueleuleu/main.go | ||
|
||
binary: kueueleuleu-{{ .Os }}-{{ .Arch }} | ||
|
||
ldflags: | ||
- "-X main.version={{ .Env.VERSION }}" | ||
- "-X main.commit={{ .Env.COMMIT }}" | ||
- "-X main.commitDate={{ .Env.COMMIT_DATE }}" | ||
- "-X main.treeState={{ .Env.TREE_STATE }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: SLSA go releaser | ||
on: | ||
push: | ||
tags: | ||
- "*" | ||
|
||
jobs: | ||
args: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.ldflags.outputs.version }} | ||
commit: ${{ steps.ldflags.outputs.commit }} | ||
commit-date: ${{ steps.ldflags.outputs.commit-date }} | ||
tree-state: ${{ steps.ldflags.outputs.tree-state }} | ||
steps: | ||
- id: checkout | ||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # tag=v4.1.6 | ||
with: | ||
fetch-depth: 0 | ||
- id: ldflags | ||
run: | | ||
echo "version=$(git describe --tags --always --dirty | cut -c2-)" >> "$GITHUB_OUTPUT" | ||
echo "commit=$GITHUB_SHA" >> "$GITHUB_OUTPUT" | ||
echo "commit-date=$(git log --date=iso8601-strict -1 --pretty=%cI)" >> "$GITHUB_OUTPUT" | ||
echo "tree-state=$(if git diff --quiet; then echo "clean"; else echo "dirty"; fi)" >> "$GITHUB_OUTPUT" | ||
build: | ||
permissions: | ||
id-token: write # to sign the provenance | ||
contents: write # to upload assets to release | ||
actions: read # to read the workflow path | ||
strategy: | ||
matrix: | ||
os: | ||
- linux | ||
- darwin | ||
arch: | ||
- amd64 | ||
- arm64 | ||
exclude: | ||
- os: linux | ||
arch: arm64 | ||
needs: args | ||
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected] # cannot reference by digest, see: https://github.com/slsa-framework/slsa-github-generator/blob/v2.0.0/README.md#referencing-slsa-builders-and-generators | ||
with: | ||
go-version: 1.21 | ||
config-file: .github/workflows/.slsa-goreleaser/${{matrix.os}}-${{matrix.arch}}.yaml | ||
evaluated-envs: "VERSION:${{needs.args.outputs.version}}, COMMIT:${{needs.args.outputs.commit}}, COMMIT_DATE:${{needs.args.outputs.commit-date}}, TREE_STATE:${{needs.args.outputs.tree-state}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters