Skip to content

Commit

Permalink
images: Build images via ko (#165)
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Augustus <[email protected]>
  • Loading branch information
justaugustus authored Aug 13, 2023
1 parent 65f9ed3 commit 9b77ac1
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/presubmits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ jobs:
version: v1.14.0
args: build

- name: Build images
uses: magefile/mage-action@3b833fb24c0d19eed3aa760b9eb285b4b84f420f # v2.3.0
with:
version: v1.14.0
args: buildImagesLocal

verify:
runs-on: ubuntu-latest
steps:
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release

on:
push:
branches:
- main
tags:
- v*

env:
COSIGN_EXPERIMENTAL: true

jobs:
build-image:
runs-on: ubuntu-latest

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

steps:
- name: Harden Runner
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: 1.19
check-latest: true

- name: Install ko
uses: ko-build/setup-ko@ace48d793556083a76f1e3e6068850c1f4a369aa # v0.6

- name: Install cosign
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 # v3.1.1

- name: Log into ghcr.io
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build images
uses: magefile/mage-action@3b833fb24c0d19eed3aa760b9eb285b4b84f420f # v2.3.0
with:
version: v1.14.0
args: buildImages
14 changes: 14 additions & 0 deletions .ko.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
defaultBaseImage: cgr.dev/chainguard/static

builds:
- id: gh-jira-issue-sync
dir: .
main: ./main.go
env:
- CGO_ENABLED=0
flags:
- -trimpath
ldflags:
- -extldflags "-static"
- "{{ .Env.GHJIRA_LDFLAGS }}"
14 changes: 0 additions & 14 deletions Dockerfile

This file was deleted.

25 changes: 21 additions & 4 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ import (
var Default = Verify

const (
binDir = "bin"
moduleName = "github.com/uwu-tools/gh-jira-issue-sync"
scriptDir = "scripts"
binDir = "bin"
scriptDir = "scripts"

// Module variables.
orgName = "uwu-tools"
toolName = "gh-jira-issue-sync"

// Versions.
golangciVersion = "v1.50.1"
Expand All @@ -51,6 +54,20 @@ const (
coverProfileFilename = "unit-coverage.out"
)

var (
moduleName = fmt.Sprintf(
"github.com/%s/%s",
orgName,
toolName,
)

koDockerRepo = fmt.Sprintf(
"ghcr.io/%s/%s",
orgName,
toolName,
)
)

// All runs all targets for this repository
func All() error {
if err := Verify(); err != nil {
Expand Down Expand Up @@ -177,7 +194,7 @@ func BuildBinariesSnapshot() error {
)
}

// BuildImages build bom image using ko
// BuildImages build image using ko
func BuildImages() error {
fmt.Println("Building images with ko...")

Expand Down

0 comments on commit 9b77ac1

Please sign in to comment.