Skip to content

Commit

Permalink
[SKIP-956] Versioning for Skiperator (#206)
Browse files Browse the repository at this point in the history
* add wip goreleaser file

Signed-off-by: anderssonw <[email protected]>

* update goreleaser

Signed-off-by: anderssonw <[email protected]>

* goreleaser action

Signed-off-by: anderssonw <[email protected]>

* add files for docker image

Signed-off-by: anderssonw <[email protected]>

* update goreleaser syntax

* set full image template for ghcr

* test using github token env var

* revert

* use ghcr.io

* use coinciding names for archive and build, see if it works

* remove changelog, does not exist

* add cosign blob sign to goreleaser

* add -y flag for cosign

* remove deploy on tag push

* add syft for sbom and image templates

* Add version information to binary

* Attempt DOCKER_EXPERIMENTAL

* Enable BuildKit

* try setting up qemu and docker buildx too

* remove attempt at multiarch images

* add docker signatures with cosign and image template to dockers field

* set same id for build, archive and docker

* remove docker_template it no worky

---------

Signed-off-by: anderssonw <[email protected]>
Co-authored-by: Even Holthe <[email protected]>
  • Loading branch information
anderssonw and evenh authored Sep 29, 2023
1 parent 7db0608 commit 1cac323
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 5 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/build-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@ name: Build and Deploy Skiperator
on:
push:
branches: [main]
# Publish semver tags as releases.
tags: ["v*.*.*"]
paths-ignore:
- doc/**
- samples/**
- README.md
- CONTRIBUTING.md
pull_request:
branches: [main]
# Publish semver tags as releases.
tags: ["v*.*.*"]
paths-ignore:
- doc/**
- samples/**
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/release-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: goreleaser

on:
push:
tags:
- "*"

permissions:
contents: write
packages: write
id-token: write

jobs:
goreleaser:
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
DOCKER_EXPERIMENTAL: 1
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- run: git fetch --force --tags

- uses: actions/setup-go@v4
with:
go-version: stable

- name: Log into GHCR registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Install Cosign
uses: sigstore/[email protected]

- name: Install Syft for SBOM Generation
shell: bash
run: curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin

- name: Release with Goreleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
/kubeconfig

.vscode/
.idea/
.idea/
dist/
69 changes: 69 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
project_name: skiperator

builds:
- env:
- CGO_ENABLED=0
binary: bin/skiperator
flags:
- -trimpath
ldflags:
- -s -w -X main.Version={{.Version}} -X main.Commit={{.ShortCommit}}
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
ignore:
- goos: darwin
goarch: i386
tags:
- osusergo
- netgo
main: ./cmd/skiperator/
id: skiperator

archives:
- id: skiperator
builds:
- skiperator
files:
- README.md

dockers:
- extra_files:
- ./
dockerfile: Dockerfile
ids:
- skiperator

docker_signs:
- artifacts: all
cmd: cosign
args:
- "sign"
- "--oidc-issuer=https://token.actions.githubusercontent.com"
- "${artifact}"
- "--yes"

signs:
- artifacts: all
cmd: cosign
signature: "${artifact}.sig"
args:
- "sign-blob"
- "--oidc-issuer=https://token.actions.githubusercontent.com"
- "--output-signature=${signature}"
- "${artifact}"
- "--yes"

sboms:
- artifacts: archive

checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ .Tag }}-dev"
changelog:
sort: asc
5 changes: 5 additions & 0 deletions cmd/skiperator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ import (
var (
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")

Version = "dev"
Commit = "N/A"
)

func init() {
Expand Down Expand Up @@ -66,6 +69,8 @@ func main() {
Level: parsedLogLevel,
})))

setupLog.Info(fmt.Sprintf("Running skiperator %s (commit %s)", Version, Commit))

kubeconfig := ctrl.GetConfigOrDie()

if !*isDeployment && !strings.Contains(kubeconfig.Host, "https://127.0.0.1") {
Expand Down

0 comments on commit 1cac323

Please sign in to comment.