Skip to content

Commit 043b978

Browse files
Ian Lewisjoshuagl
Ian Lewis
andauthored
Doc updates (slsa-framework#359)
* Golang -> Go * Formatting and supported triggers section * Some changes to supported triggers * Update internal/builders/go/README.md Co-authored-by: Joshua Lock <[email protected]> * Update internal/builders/go/README.md Co-authored-by: Joshua Lock <[email protected]> Co-authored-by: Joshua Lock <[email protected]>
1 parent b9f640a commit 043b978

File tree

3 files changed

+71
-49
lines changed

3 files changed

+71
-49
lines changed

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This repository contains the code, examples and technical design for system desc
99
---
1010

1111
- [Generation of provenance](#generation-of-provenance)
12-
- [Golang projects](#golang-projects)
12+
- [Go projects](#go-projects)
1313
- [Other projects](#other-projects)
1414
- [Verification of provenance](#verification-of-provenance)
1515
- [Installation](#installation)
@@ -24,13 +24,15 @@ This repository contains the code, examples and technical design for system desc
2424

2525
## Generation of provenance
2626

27-
### Golang projects
27+
### Go projects
2828

29-
To generate SLSA provenance for your Golang project, follow [internal/builders/go/README.md](internal/builders/go/README.md).
29+
To generate SLSA provenance for your [Go](https://go.dev/) project, follow
30+
[internal/builders/go/README.md](internal/builders/go/README.md).
3031

3132
### Other projects
3233

33-
To generate SLSA provenance for other programming languages, follow [internal/builders/generic/README.md](internal/builders/generic/README.md).
34+
To generate SLSA provenance for other programming languages, follow
35+
[internal/builders/generic/README.md](internal/builders/generic/README.md).
3436
This is a pre-release only and we will have the official release in July 2022.
3537

3638
## Verification of provenance
@@ -62,4 +64,3 @@ For a more in-depth technical dive, read the [SPECIFICATIONS.md](./SPECIFICATION
6264
### Provenance format
6365

6466
The format of the provenance is available in [PROVENANCE_FORMAT.md](./PROVENANCE_FORMAT.md).
65-

internal/builders/generic/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ project simply generates provenance as a separate step in an existing workflow.
1919
- [Benefits of Provenance](#benefits-of-provenance)
2020
- [Generating Provenance](#generating-provenance)
2121
- [Getting Started](#getting-started)
22+
- [Supported Triggers](#supported-triggers)
2223
- [Workflow Inputs](#workflow-inputs)
2324
- [Workflow Outputs](#workflow-outputs)
2425
- [Provenance Format](#provenance-format)
@@ -157,6 +158,22 @@ jobs:
157158
${{needs.provenance.outputs.attestation-name}}
158159
```
159160
161+
### Supported Triggers
162+
163+
The following [GitHub trigger events](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows) are fully supported and tested:
164+
165+
- `schedule`
166+
- `push` (including new tags)
167+
- `release`
168+
- Manual run via `workflow_dispatch`
169+
170+
However, in practice, most triggers should work with the exception of
171+
`pull_request`. If you would like support for `pull_request`, please tell us
172+
about your use case on [issue
173+
#358](https://github.com/slsa-framework/slsa-github-generator/issues/358). If
174+
you have an issue in all other triggers please submit a [new
175+
issue](https://github.com/slsa-framework/slsa-github-generator/issues/new/choose).
176+
160177
### Workflow Inputs
161178

162179
The builder workflow

internal/builders/go/README.md

+48-44
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
1-
# Generation of SLSA3+ provenance for Golang projects
1+
# Generation of SLSA3+ provenance for Go projects
22

3-
This document explains how to use the builder for Golang projects.
3+
This document explains how to use the builder for [Go](https://go.dev/) projects.
44

55
---
66

77
[Generation of provenance](#generation)
88

9-
- [Supported triggers](#supported-triggers)
10-
- [Configuration file](#configuration-file)
9+
- [Supported Triggers](#supported-triggers)
10+
- [Configuration File](#configuration-file)
1111
- [Migration from goreleaser](#migration-from-goreleaser)
12-
- [Workflow inputs](#workflow-inputs)
12+
- [Workflow Inputs](#workflow-inputs)
1313
- [Workflow Example](#workflow-example)
14-
- [Example provenance](#example-provenance)
15-
- [BuildConfig format](#buildconfig-format)
14+
- [Provenance Example](#provenance-example)
15+
- [BuildConfig Format](#buildconfig-format)
1616

1717
---
1818

1919
## Generation
2020

21-
To generate provenance for a golang binary, follow the steps below:
21+
To generate provenance for a Go binary, follow the steps below:
2222

23-
### Supported triggers
23+
### Supported Triggers
2424

25-
Most GitHub trigger events are supported, at the exception of `pull_request`. We have extensively tested the
26-
following triggers: `schedule`, `push` (including new tags), `release` and manual `workflow_dispatch`.
25+
The following [GitHub trigger events](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows) are fully supported and tested:
2726

28-
If you would like support for `pull_request`, please tell us about your use case and [file an issue](https://github.com/slsa-framework/slsa-github-generator/issues/new).
27+
- `schedule`
28+
- `push` (including new tags)
29+
- `release`
30+
- Manual run via `workflow_dispatch`
2931

30-
### Configuration file
32+
However, in practice, most triggers should work with the exception of `pull_request`. If you would like support for `pull_request`, please tell us about your use case on [issue #358](https://github.com/slsa-framework/slsa-github-generator/issues/358). If you have an issue in all other triggers please submit a [new issue](https://github.com/slsa-framework/slsa-github-generator/issues/new/choose).
33+
34+
### Configuration File
3135

3236
Define a configuration file called `.slsa-goreleaser.yml` in the root of your project.
3337

@@ -46,7 +50,7 @@ flags:
4650
- -tags=netgo
4751

4852
# The OS to compile for. `GOOS` env variable will be set to this value.
49-
goos: linux
53+
goos: linux
5054

5155
# The architecture to compile for. `GOARCH` env variable will be set to this value.
5256
goarch: amd64
@@ -64,15 +68,15 @@ binary: binary-{{ .Os }}-{{ .Arch }}
6468

6569
# (Optional) ldflags generated dynamically in the workflow, and set as the `evaluated-envs` input variables in the workflow.
6670
ldflags:
67-
- '-X main.Version={{ .Env.VERSION }}'
68-
- '-X main.Commit={{ .Env.COMMIT }}'
69-
- '-X main.CommitDate={{ .Env.COMMIT_DATE }}'
70-
- '-X main.TreeState={{ .Env.TREE_STATE }}'
71+
- "-X main.Version={{ .Env.VERSION }}"
72+
- "-X main.Commit={{ .Env.COMMIT }}"
73+
- "-X main.CommitDate={{ .Env.COMMIT_DATE }}"
74+
- "-X main.TreeState={{ .Env.TREE_STATE }}"
7175
```
7276
7377
### Migration from goreleaser
7478
75-
If you are already using Goreleaser, you may be able to migrate to our builder using multiple config files for each build. However, this is cumbersome and we are working on supporting multiple builds in a single config file for future releases.
79+
If you are already using Goreleaser, you may be able to migrate to our builder using multiple config files for each build. However, this is cumbersome and we are working on supporting multiple builds in a single config file for future releases.
7680
7781
In the meantime, you can use both Goreleaser and this builder in the same repository. For example, you can pick one build you would like to start generating provenance for. Goreleaser and this builder can co-exist without interfering with one another, so long as the resulting binaries have different names (e.g., when building for different OS/Arch). If you want to keep the same name, you can use the Goreleaser `ignore` option in the `.goreleaser.yml`:
7882

@@ -97,38 +101,38 @@ We think gradual adoption is good for projects to get used to SLSA.
97101
98102
The configuration file accepts many of the common fields Goreleaser uses, as you can see in the [example](#configuration-file). The configuration file also supports two variables: `{{ .Os }}` and `{{ .Arch }}`. Other variables can be set manually as shows in the table below, in combination with the builder's `evaluated-envs`:
99103
100-
| Name | Value | Example |
101-
| --------------------------- | ----------------------------------------------- | ------------------ |
102-
| `{{ .CommitDate }}` | `date -d @$(git log --date=iso8601-strict -1 --pretty=%ct)` | `Mon Jun 13 01:23:36 AM UTC 2022` |
103-
| `{{ .FullCommit }}` | `$GITHUB_SHA` or `$(git rev-parse HEAD)` | `b2a980888f359b8cef22cb61f153746e1a06deb0` |
104-
| `{{ .ShortCommit }}` | `$(echo $GITHUB_SHA \| cut -c1-8)` or `$(git rev-parse HEAD \| cut -c1-8)` | `b2a98088` |
105-
| `{{ .Version }}` | `$(git describe --tags --always --dirty \| cut -c2-)` or `$(echo $GITHUB_REF_NAME \| cut -c2-)` on new tags and release triggers | `1.2.3-alpha+b2a98088` |
106-
| `{{ .Tag }}` | `$GITHUB_REF_NAME` (on `release` and `push` new tag triggers) or `$(git describe --tags --always --dirty \| cut -c2-)` | `v1.2.3-alpha+b2a98088` |
107-
| `{{ .Major }}` | `$(git describe --tags --always --dirty \| cut -d '.' -f1 \| cut -c2-)` | `1` |
108-
| `{{ .Minor }}` | `$(git describe --tags --always --dirty \| cut -d '.' -f2` | `2` |
109-
| `{{ .Patch }}` | `$(git describe --tags --always --dirty \| cut -d '.' -f3 \| cut -d '-' -f1 \| cut -d '+' -f1` | `3` |
104+
| Name | Value | Example |
105+
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
106+
| `{{ .CommitDate }}` | `date -d @$(git log --date=iso8601-strict -1 --pretty=%ct)` | `Mon Jun 13 01:23:36 AM UTC 2022` |
107+
| `{{ .FullCommit }}` | `$GITHUB_SHA` or `$(git rev-parse HEAD)` | `b2a980888f359b8cef22cb61f153746e1a06deb0` |
108+
| `{{ .ShortCommit }}` | `$(echo $GITHUB_SHA \| cut -c1-8)` or `$(git rev-parse HEAD \| cut -c1-8)` | `b2a98088` |
109+
| `{{ .Version }}` | `$(git describe --tags --always --dirty \| cut -c2-)` or `$(echo $GITHUB_REF_NAME \| cut -c2-)` on new tags and release triggers | `1.2.3-alpha+b2a98088` |
110+
| `{{ .Tag }}` | `$GITHUB_REF_NAME` (on `release` and `push` new tag triggers) or `$(git describe --tags --always --dirty \| cut -c2-)` | `v1.2.3-alpha+b2a98088` |
111+
| `{{ .Major }}` | `$(git describe --tags --always --dirty \| cut -d '.' -f1 \| cut -c2-)` | `1` |
112+
| `{{ .Minor }}` | `$(git describe --tags --always --dirty \| cut -d '.' -f2` | `2` |
113+
| `{{ .Patch }}` | `$(git describe --tags --always --dirty \| cut -d '.' -f3 \| cut -d '-' -f1 \| cut -d '+' -f1` | `3` |
110114
111115
If you think you need suppport for other variables, please [open an issue](https://github.com/slsa-framework/slsa-github-generator/issues/new).
112116
113-
### Workflow inputs
117+
### Workflow Inputs
114118
115119
The builder workflow [slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml](.github/workflows/builder_go_slsa3.yml) accepts the following inputs:
116120
117-
| Name | Required | Description | Default |
118-
| ------------------ | -------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
119-
| `config-file` | no | `.github/workflows/slsa-goreleaser.yml` | The configuration file for the builder. A path within the calling repository. |
120-
| `evaluated-envs` | no | empty value | A list of environment variables, seperated by `,`: `VAR1: value, VAR2: value`. This is typically used to pass dynamically-generated values, such as `ldflags`. Note that only environment variables with names starting with `CGO_` or `GO` are accepted. |
121-
| `go-version` | yes | The go version for your project. This value is passed, unchanged, to the [actions/setup-go](https://github.com/actions/setup-go) action when setting up the environment |
122-
| `upload-assets` | no | true on new tags | Whether to upload assets to a GitHub release or not. |
121+
| Name | Required | Description | Default |
122+
| ---------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
123+
| `config-file` | no | `.github/workflows/slsa-goreleaser.yml` | The configuration file for the builder. A path within the calling repository. |
124+
| `evaluated-envs` | no | empty value | A list of environment variables, seperated by `,`: `VAR1: value, VAR2: value`. This is typically used to pass dynamically-generated values, such as `ldflags`. Note that only environment variables with names starting with `CGO_` or `GO` are accepted. |
125+
| `go-version` | yes | The go version for your project. This value is passed, unchanged, to the [actions/setup-go](https://github.com/actions/setup-go) action when setting up the environment |
126+
| `upload-assets` | no | true on new tags | Whether to upload assets to a GitHub release or not. |
123127
124128
### Workflow Example
125129
126130
Create a new workflow, say `.github/workflows/slsa-goreleaser.yml`.
127131
128-
Make sure that you reference the trusted builder with a semnatic version of the form `vX.Y.Z`. The build will fail
129-
if you reference it via a shorter tag like `vX.Y` or `vX`.
132+
Make sure that you reference the trusted builder with a semantic version of the form `vX.Y.Z`. The build will fail
133+
if you reference it via a shorter tag like `vX.Y` or `vX`.
130134
131-
Refencing via hash is currently not supported due to limitations
135+
Referencing via hash is currently not supported due to limitations
132136
of the reusable workflow APIs. (We are working with GitHub to address this limitation).
133137
134138
```yaml
@@ -166,9 +170,9 @@ jobs:
166170
# Trusted builder.
167171
build:
168172
permissions:
169-
id-token: write # To sign the provenance.
170-
contents: write # To upload assets to release.
171-
actions: read # To read the workflow path.
173+
id-token: write # To sign the provenance.
174+
contents: write # To upload assets to release.
175+
actions: read # To read the workflow path.
172176
needs: args
173177
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
174178
with:
@@ -177,7 +181,7 @@ jobs:
177181
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}}"
178182
```
179183

180-
### Example provenance
184+
### Provenance Example
181185

182186
An example of the provenance generated from this repo is below:
183187

@@ -278,7 +282,7 @@ An example of the provenance generated from this repo is below:
278282
}
279283
```
280284

281-
### BuildConfig format
285+
### BuildConfig Format
282286

283287
The `BuildConfig` contains the following fields:
284288

0 commit comments

Comments
 (0)