Skip to content

Commit f6c2b19

Browse files
committed
add signed releases
1 parent f2c57d1 commit f6c2b19

File tree

7 files changed

+113
-1
lines changed

7 files changed

+113
-1
lines changed

.github/cosign.key

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-----BEGIN ENCRYPTED COSIGN PRIVATE KEY-----
2+
eyJrZGYiOnsibmFtZSI6InNjcnlwdCIsInBhcmFtcyI6eyJOIjozMjc2OCwiciI6
3+
OCwicCI6MX0sInNhbHQiOiJIYm5Zeno2c1orRytYdlFTUWorTU5PZEhnTmZTQnpR
4+
NTd4MkRIQWI5emU4PSJ9LCJjaXBoZXIiOnsibmFtZSI6Im5hY2wvc2VjcmV0Ym94
5+
Iiwibm9uY2UiOiIyS1pvUHF1bG9NcDUvcFBsOWg5cDR5VXBsL2M5eFI1OCJ9LCJj
6+
aXBoZXJ0ZXh0IjoiT1NqZUMvS2dtWUkzQ2ErVlVmQlh1Wm9hU0FkYWxFT0wwWk9G
7+
UEMrNFFWYWhtMUtNeHM2YUUwNWpvT3hveEF1eDRxaGk2amJmenp0MG5SelhJUUZt
8+
QjRSblBDTUQ4NmduQ2owR243dE4vc3V0TmpZbVI0c3NORzZpNXVYdTBuWmdseHk3
9+
K1k5SXU0cW0wOWordXRyNURwODM3RmF2Z0w3ZUhJeU1LQjlZWVd0OWZMV0s4VFps
10+
b29yTjJpVDYxT1E4Y0diM0JyOGw2ang2YkE9PSJ9
11+
-----END ENCRYPTED COSIGN PRIVATE KEY-----

.github/workflows/goreleaser.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: release
2+
on:
3+
push:
4+
tags:
5+
- '*'
6+
jobs:
7+
release:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
with:
13+
fetch-depth: 0
14+
- name: Set up Go
15+
uses: actions/setup-go@v2
16+
with:
17+
go-version: 1.17
18+
- name: install cosign
19+
uses: sigstore/cosign-installer@main
20+
with:
21+
cosign-release: 'v1.2.1'
22+
- name: Run GoReleaser
23+
uses: goreleaser/goreleaser-action@v2
24+
with:
25+
distribution: goreleaser
26+
version: latest
27+
args: release --rm-dist
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
COSIGN_PWD: ${{ secrets.COSIGN_PWD }}

.github/workflows/build.yml .github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
on: [push, pull_request]
2-
name: build
2+
name: test
33
jobs:
44
test:
55
strategy:

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# goreleaser distribution directory
2+
dist
3+
4+
# GoLand idea configuration
5+
.idea
6+
7+
# VSCode configuration
8+
.vscode

.goreleaser.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
project_name: in-toto
2+
builds:
3+
- ldflags:
4+
- "-s -w"
5+
- "-extldflags=-zrelro"
6+
- "-extldflags=-znow"
7+
- "-X main.tag={{.Version}}"
8+
- "-X main.commit={{.FullCommit}}"
9+
- "-X main.date={{.Date}}"
10+
env:
11+
- "CGO_ENABLED=0"
12+
- "GO111MODULE=on"
13+
- "GOFLAGS=-mod=readonly -trimpath"
14+
goos:
15+
- linux
16+
- darwin
17+
- windows
18+
goarch:
19+
- amd64
20+
main: ./cmd/in-toto/
21+
signs:
22+
- cmd: cosign
23+
signature: "${artifact}.sig"
24+
stdin: '{{ .Env.COSIGN_PWD }}'
25+
args: ["sign-blob", "-key=.github/cosign.key", "-output=${signature}", "${artifact}"]
26+
artifacts: all

cmd/in-toto/version.go

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"github.com/spf13/cobra"
6+
)
7+
8+
var (
9+
commit = "none"
10+
date = "unknown"
11+
tag = "dev"
12+
)
13+
14+
var versionCmd = &cobra.Command{
15+
Use: "version",
16+
Short: "Display the version of the in-toto CLI tool",
17+
Long: `Display the commit ID, the date and the version tag of the in-toto CLI as embedded by the build system.`,
18+
RunE: version,
19+
}
20+
21+
func init() {
22+
rootCmd.AddCommand(versionCmd)
23+
}
24+
25+
func version(cmd *cobra.Command, args []string) error {
26+
// let us make it as simple as possible.
27+
// We could encode the version information as JSON like kubectl does,
28+
// but what if the json package has a bug? :/
29+
fmt.Println("commit : ", commit)
30+
fmt.Println("date : ", date)
31+
fmt.Println("version: ", tag)
32+
return nil
33+
}

cosign.pub

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-----BEGIN PUBLIC KEY-----
2+
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE2aAPtd19aLTQNfMnspdWzs2e0ieD
3+
NxbkxAfrlSrJ7t/CUdQVlzqRydZQ1HnRfGmB6xPW6U7BDFUexVYLMTMOBQ==
4+
-----END PUBLIC KEY-----

0 commit comments

Comments
 (0)