Skip to content

Commit

Permalink
Merge pull request #109 from philips-labs/release-signing
Browse files Browse the repository at this point in the history
Signing of artifacts
  • Loading branch information
marcofranssen authored Jan 14, 2022
2 parents 3511795 + abc16c4 commit 58d245d
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 15 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ jobs:
with:
go-version: 1.17

- name: Install cosign
uses: sigstore/[email protected]
with:
cosign-release: 'v1.4.1'

- name: Checkout
uses: actions/[email protected]
with:
Expand All @@ -100,6 +105,10 @@ jobs:
fi
rm -f /tmp/spiffe-vault-release-vars.env
- name: Install signing key
run: |
echo '${{ secrets.COSIGN_PRIVATE_KEY }}' > cosign.key
- name: Release ${{ (!startsWith(github.ref, 'refs/tags/') && 'snapshot') || '' }}
uses: goreleaser/goreleaser-action@v2
with:
Expand All @@ -109,6 +118,7 @@ jobs:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
LDFLAGS: ${{ steps.release-vars.outputs.LDFLAGS }}
GIT_HASH: ${{ steps.release-vars.outputs.GIT_HASH }}
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}

- name: Get container info
id: container_info
Expand All @@ -125,6 +135,10 @@ jobs:
docker logout
docker logout ghcr.io
- name: Cleanup signing keys
if: ${{ always() }}
run: rm -f cosign.key

container-provenance:
name: container-provenance
needs: [release]
Expand All @@ -142,7 +156,7 @@ jobs:
cosign-release: 'v1.4.1'

- name: Generate provenance for ${{ matrix.repo }}
uses: philips-labs/[email protected].0
uses: philips-labs/[email protected].1-draft
with:
command: generate
subcommand: container
Expand All @@ -169,14 +183,14 @@ jobs:

- name: Verify attestation
run: |
echo '${{ secrets.COSIGN_PUBLIC_KEY }}' > cosign.pub
cosign verify-attestation --key cosign.pub ${{ matrix.repo }}@${{ needs.release.outputs.container_digest }}
- name: Logout from Container registries
if: ${{ always() }}
run: |
docker logout
docker logout ghcr.io
rm -f cosign.key
provenance:
name: provenance
Expand All @@ -186,7 +200,7 @@ jobs:

steps:
- name: Generate provenance for Release
uses: philips-labs/[email protected].0
uses: philips-labs/[email protected].1-draft
with:
command: generate
subcommand: github-release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/example-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/download-artifact@v2

- name: Generate provenance
uses: philips-labs/[email protected].0
uses: philips-labs/[email protected].1-draft
with:
command: generate
subcommand: files
Expand Down
57 changes: 55 additions & 2 deletions .goreleaser.draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ archives:
files:
- LICENSE*
- README*
- cosign.pub
- dist/*.sig
format_overrides:
- goos: windows
format: zip

checksum:
name_template: 'checksums.txt'

dockers:
- goos: linux
goarch: amd64
Expand All @@ -57,8 +62,54 @@ dockers:
- "go.sum"
- "cmd"
- "lib"
checksum:
name_template: 'checksums.txt'

signs:
- id: checksums
cmd: cosign
stdin: '{{ .Env.COSIGN_PASSWORD }}'
output: true
artifacts: checksum
args:
- sign-blob
- --key
- cosign.key
- '--output-certificate=${certificate}'
- '--output-signature=${signature}'
- '${artifact}'
- id: binaries
cmd: cosign
stdin: '{{ .Env.COSIGN_PASSWORD }}'
output: true
artifacts: binary
args:
- sign-blob
- --key
- cosign.key
- '--output-certificate=${certificate}'
- '--output-signature=${signature}'
- '${artifact}'
- id: archives
cmd: cosign
stdin: '{{ .Env.COSIGN_PASSWORD }}'
output: true
artifacts: archive
args:
- sign-blob
- --key
- cosign.key
- '--output-certificate=${certificate}'
- '--output-signature=${signature}'
- '${artifact}'

docker_signs:
- cmd: cosign
artifacts: all
output: true
args:
- 'sign'
- --key
- cosign.key
- '${artifact}'

snapshot:
name_template: "{{ .Version }}-next"
Expand All @@ -75,3 +126,5 @@ changelog:
release:
draft: true
prerelease: auto
extra_files:
- glob: "./cosign.pub"
57 changes: 55 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ archives:
files:
- LICENSE*
- README*
- cosign.pub
- dist/*.sig
format_overrides:
- goos: windows
format: zip

checksum:
name_template: 'checksums.txt'

dockers:
- goos: linux
goarch: amd64
Expand All @@ -57,8 +62,54 @@ dockers:
- "go.sum"
- "cmd"
- "lib"
checksum:
name_template: 'checksums.txt'

signs:
- id: checksums
cmd: cosign
stdin: '{{ .Env.COSIGN_PASSWORD }}'
output: true
artifacts: checksum
args:
- sign-blob
- --key
- cosign.key
- '--output-certificate=${certificate}'
- '--output-signature=${signature}'
- '${artifact}'
- id: binaries
cmd: cosign
stdin: '{{ .Env.COSIGN_PASSWORD }}'
output: true
artifacts: binary
args:
- sign-blob
- --key
- cosign.key
- '--output-certificate=${certificate}'
- '--output-signature=${signature}'
- '${artifact}'
- id: archives
cmd: cosign
stdin: '{{ .Env.COSIGN_PASSWORD }}'
output: true
artifacts: archive
args:
- sign-blob
- --key
- cosign.key
- '--output-certificate=${certificate}'
- '--output-signature=${signature}'
- '${artifact}'

docker_signs:
- cmd: cosign
artifacts: all
output: true
args:
- 'sign'
- --key
- cosign.key
- '${artifact}'

snapshot:
name_template: "{{ .Version }}-next"
Expand All @@ -75,3 +126,5 @@ changelog:
release:
draft: false
prerelease: auto
extra_files:
- glob: "./cosign.pub"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ image: ## build the binary in a docker image
.

$(GO_PATH)/bin/goreleaser:
go install github.com/goreleaser/goreleaser@v0.182.1
go install github.com/goreleaser/goreleaser@v1.2.5

.PHONY: snapshot-release
snapshot-release: $(GO_PATH)/bin/goreleaser ## creates a snapshot release using goreleaser
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ See all available images [here.](https://hub.docker.com/r/philipssoftware/slsa-p
Run the Docker image by doing:

```sh
docker run philipssoftware/slsa-provenance:v0.5.0
docker run philipssoftware/slsa-provenance:v0.5.1-draft
```

**GitHub Container Registry**
See all available images [here.](https://github.com/philips-labs/slsa-provenance-action/pkgs/container/slsa-provenance)
Run the Docker image by doing:

```sh
docker run ghcr.io/philips-labs/slsa-provenance:v0.5.0
docker run ghcr.io/philips-labs/slsa-provenance:v0.5.1-draft
```

The Docker image includes the working binary that can be executed by using the ``slsa-provenance`` command.
Expand Down Expand Up @@ -145,7 +145,7 @@ The easiest way to use this action is to add the following into your workflow fi

steps:
- name: Generate provenance for Release
uses: philips-labs/[email protected].0
uses: philips-labs/[email protected].1-draft
with:
command: generate
subcommand: files
Expand Down Expand Up @@ -180,7 +180,7 @@ The easiest way to use this action is to add the following into your workflow fi
path: extra-materials/

- name: Generate provenance
uses: philips-labs/[email protected].0
uses: philips-labs/[email protected].1-draft
with:
command: generate
subcommand: files
Expand Down
2 changes: 1 addition & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ runs:
run: |
echo Running slsa-provenance with following arguments
echo ${{ steps.compose-args.outputs.provenance_args }}
- uses: 'docker://ghcr.io/philips-labs/slsa-provenance:v0.5.0'
- uses: 'docker://ghcr.io/philips-labs/slsa-provenance:v0.5.1-draft'
with:
args: ${{ steps.compose-args.outputs.provenance_args }}
2 changes: 1 addition & 1 deletion release.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
To make a new release you can make use of the following `make` task.

```bash
make gh-release NEW_VERSION=v0.6.0 OLD_VERSION=v0.5.0 DESCRIPTION="A test release to see how it works"
make gh-release NEW_VERSION=v0.6.0 OLD_VERSION=v0.5.1-draft DESCRIPTION="A test release to see how it works"
```

`NEW_VERSION` the version that you want to release.
Expand Down

0 comments on commit 58d245d

Please sign in to comment.