Skip to content

Commit

Permalink
build: use ko for build
Browse files Browse the repository at this point in the history
  • Loading branch information
calmh committed Aug 14, 2024
1 parent 6f1cb46 commit a845da7
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 45 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and Publish

on:
push:

permissions:
packages: write
contents: write

jobs:
build-and-push-docker-image:
name: Build Docker image and push
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 'stable'

- uses: go-semantic-release/action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup ko
uses: ko-build/setup-ko@v0.6

- name: Login to Github Packages
uses: docker/#-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build containers
run: |
git fetch --tags
descr=$(git describe --tags)
short=$(git describe --tags --abbrev=0)
export version="${descr#v}"
if [[ $descr == $short ]]; then
minor="${version%.*}"
major="${version%%.*}"
ko build --bare --sbom=none -t edge -t latest -t "$version" -t "$minor" -t "$major" .
else
ko build --bare --sbom=none -t edge .
fi
env:
KO_DOCKER_REPO: ghcr.io/kastelo/go-import-redirector
41 changes: 0 additions & 41 deletions .github/workflows/build.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .ko.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defaultPlatforms:
- linux/arm64
- linux/amd64
4 changes: 0 additions & 4 deletions Dockerfile

This file was deleted.

0 comments on commit a845da7

Please # to comment.