Skip to content

Commit

Permalink
Add build and push CI.
Browse files Browse the repository at this point in the history
The CI builds and pushes Linux amd64 images to quay.io tagged using
the full commit revision.

Signed-off-by: Chris Doherty <[email protected]>
  • Loading branch information
chrisdoherty4 committed Mar 11, 2024
1 parent ac59c9a commit d6bdc81
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 9 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Actions
on:
push:
branches:
- "*"
tags-ignore:
- "v*"
pull_request: {}
workflow_dispatch: {}
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
platform: [amd64]
steps:
- uses: actions/checkout@v4
- name: Build linux/${{ matrix.platform }}
run: make images -j$(nproc) GOOS=linux GOARCH=${{ matrix.platform }}
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release
on:
push:
branches:
- "main"
workflow_dispatch: {}
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
platform: [amd64]
steps:
- uses: actions/checkout@v4

- name: Build linux/${{ matrix.platform }}
run: make images -j $(nproc) GOOS=linux GOARCH=${{ matrix.platform }}

- name: Push linux/${{ matrix.platform }}
run: make push -j $(nprox)
File renamed without changes.
52 changes: 43 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,52 @@
BINS = archive2disk cexec grub2disk kexec oci2disk qemuimg2disk rootio slurp syslinux writefile
# Use bash
SHELL := bash
.SHELLFLAGS := -o pipefail -euc
.ONESHELL:

include rules.mk
# Second expansion is used by the image targets to depend on their respective binaries. It is
# necessary because automatic variables are not set on first expansion.
# See https://www.gnu.org/software/make/manual/html_node/Secondary-Expansion.html.
.SECONDEXPANSION:

all: $(BINS)
# Define the list of actions that can be built.
ACTIONS := archive2disk cexec grub2disk kexec oci2disk qemuimg2disk rootio slurp syslinux writefile

.PHONY: $(BINS)
$(BINS):
# Define the commit for tagging images.
GIT_COMMIT := $(shell git rev-parse HEAD)

# Define Docker registry details.
DOCKER_REPOSITORY := quay.io/tinkerbell/actions

include Rules.mk

.PHONY: help
help: ## Print this help
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[%\/0-9A-Za-z_-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
@echo
@echo Individual actions can be built with their name. For example, \`make archive2disk\`.


.PHONY: $(ACTIONS)
$(ACTIONS): ## Build a specific action image.
docker buildx build --platform linux/amd64 --load -t $@:latest -f ./$@/Dockerfile .

.PHONY: images
images: ## Build all action images.
images: $(ACTIONS)

.PHONY: push
push: ## Push all action images.
push: $(addprefix push-,$(ACTIONS))

.PHONY: push-%
push-%: ## Push a specific action image to the registry. This recipe assumes you are already authenticated with the registry.
IMAGE_NAME=$(DOCKER_REPOSITORY)/$*:$(GIT_COMMIT)
docker tag $*:latest $$IMAGE_NAME
docker push $$IMAGE_NAME

formatters: ## Run all formatters.
formatters: $(toolBins)
git ls-files '*.go' | xargs -I% sh -c 'sed -i "/^import (/,/^)/ { /^\s*$$/ d }" % && bin/gofumpt -w %'
git ls-files '*.go' | xargs -I% bin/goimports -w %

tidy-all:
for d in $(BINS); do (cd $$d; go mod tidy); done

include lint.mk
include Lint.mk
File renamed without changes.

0 comments on commit d6bdc81

Please sign in to comment.