Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add signed releases #128

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions .github/workflows/build.yml

This file was deleted.

58 changes: 58 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: release
on: [push, pull_request]
jobs:
test:
strategy:
matrix:
go-version: [ 1.16.x, 1.17.x ]
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Format Unix
if: runner.os == 'Linux'
run: test -z $(go fmt ./...)
- name: Test
run: go test -covermode atomic -coverprofile='profile.cov' ./...
- name: Send coverage
if: runner.os == 'Linux'
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
GO111MODULE=off go get github.com/mattn/goveralls
$(go env GOPATH)/bin/goveralls -coverprofile=profile.cov -service=github
release:
permissions:
id-token: write
contents: write
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
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.4.1'
- uses: anchore/sbom-action/download-syft@v0.6.0
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: 'v1.2.5'
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COSIGN_EXPERIMENTAL: 1
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# goreleaser distribution directory
dist

# GoLand idea configuration
.idea

# VSCode configuration
.vscode

# ignore cosign private key
cosign.key

bin/
41 changes: 41 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
project_name: in-toto
builds:
- ldflags:
- "-s -w"
- "-extldflags=-zrelro"
- "-extldflags=-znow"
- "-X cmd.tag={{.Version}}"
- "-X cmd.commit={{.FullCommit}}"
- "-X cmd.date={{.CommitDate}}"
env:
- "CGO_ENABLED=0"
- "GO111MODULE=on"
- "GOFLAGS=-mod=readonly -trimpath"
goos:
- linux
- darwin
- windows
goarch:
- amd64
main: ./

gomod:
proxy: true

checksum:
name_template: 'checksums.txt'

sboms:
- artifacts: archive
- id: source
artifacts: source

source:
enabled: true

signs:
- cmd: cosign
signature: "${artifact}.sig"
certificate: "${artifact}.pem"
args: ["sign-blob", "--oidc-issuer=https://token.actions.githubusercontent.com", "--output-certificate=${certificate}", "--output-signature=${signature}", "${artifact}"]
artifacts: all
33 changes: 33 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cmd

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 build 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
}