Skip to content

Commit

Permalink
add signed releases
Browse files Browse the repository at this point in the history
  • Loading branch information
shibumi committed Sep 26, 2021
1 parent f2c57d1 commit f6c2b19
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .github/cosign.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----BEGIN ENCRYPTED COSIGN PRIVATE KEY-----
eyJrZGYiOnsibmFtZSI6InNjcnlwdCIsInBhcmFtcyI6eyJOIjozMjc2OCwiciI6
OCwicCI6MX0sInNhbHQiOiJIYm5Zeno2c1orRytYdlFTUWorTU5PZEhnTmZTQnpR
NTd4MkRIQWI5emU4PSJ9LCJjaXBoZXIiOnsibmFtZSI6Im5hY2wvc2VjcmV0Ym94
Iiwibm9uY2UiOiIyS1pvUHF1bG9NcDUvcFBsOWg5cDR5VXBsL2M5eFI1OCJ9LCJj
aXBoZXJ0ZXh0IjoiT1NqZUMvS2dtWUkzQ2ErVlVmQlh1Wm9hU0FkYWxFT0wwWk9G
UEMrNFFWYWhtMUtNeHM2YUUwNWpvT3hveEF1eDRxaGk2amJmenp0MG5SelhJUUZt
QjRSblBDTUQ4NmduQ2owR243dE4vc3V0TmpZbVI0c3NORzZpNXVYdTBuWmdseHk3
K1k5SXU0cW0wOWordXRyNURwODM3RmF2Z0w3ZUhJeU1LQjlZWVd0OWZMV0s4VFps
b29yTjJpVDYxT1E4Y0diM0JyOGw2ang2YkE9PSJ9
-----END ENCRYPTED COSIGN PRIVATE KEY-----
30 changes: 30 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: release
on:
push:
tags:
- '*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: install cosign
uses: sigstore/cosign-installer@main
with:
cosign-release: 'v1.2.1'
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COSIGN_PWD: ${{ secrets.COSIGN_PWD }}
2 changes: 1 addition & 1 deletion .github/workflows/build.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
on: [push, pull_request]
name: build
name: test
jobs:
test:
strategy:
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# goreleaser distribution directory
dist

# GoLand idea configuration
.idea

# VSCode configuration
.vscode
26 changes: 26 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
project_name: in-toto
builds:
- ldflags:
- "-s -w"
- "-extldflags=-zrelro"
- "-extldflags=-znow"
- "-X main.tag={{.Version}}"
- "-X main.commit={{.FullCommit}}"
- "-X main.date={{.Date}}"
env:
- "CGO_ENABLED=0"
- "GO111MODULE=on"
- "GOFLAGS=-mod=readonly -trimpath"
goos:
- linux
- darwin
- windows
goarch:
- amd64
main: ./cmd/in-toto/
signs:
- cmd: cosign
signature: "${artifact}.sig"
stdin: '{{ .Env.COSIGN_PWD }}'
args: ["sign-blob", "-key=.github/cosign.key", "-output=${signature}", "${artifact}"]
artifacts: all
33 changes: 33 additions & 0 deletions cmd/in-toto/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main

import (
"fmt"
"github.com/spf13/cobra"
)

var (
commit = "none"
date = "unknown"
tag = "dev"
)

var versionCmd = &cobra.Command{
Use: "version",
Short: "Display the version of the in-toto CLI tool",
Long: `Display the commit ID, the date and the version tag of the in-toto CLI as embedded by the build system.`,
RunE: version,
}

func init() {
rootCmd.AddCommand(versionCmd)
}

func version(cmd *cobra.Command, args []string) error {
// let us make it as simple as possible.
// We could encode the version information as JSON like kubectl does,
// but what if the json package has a bug? :/
fmt.Println("commit : ", commit)
fmt.Println("date : ", date)
fmt.Println("version: ", tag)
return nil
}
4 changes: 4 additions & 0 deletions cosign.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE2aAPtd19aLTQNfMnspdWzs2e0ieD
NxbkxAfrlSrJ7t/CUdQVlzqRydZQ1HnRfGmB6xPW6U7BDFUexVYLMTMOBQ==
-----END PUBLIC KEY-----

0 comments on commit f6c2b19

Please sign in to comment.