Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Aug 28, 2024
0 parents commit fcf1463
Show file tree
Hide file tree
Showing 12 changed files with 2,551 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release

on:
push:
tags:
- "*.*"
- "*.*.*"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v1

- name: Print version info
id: semver
run: |
make version
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to the GitHub Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: 1gtm
password: ${{ secrets.LGTM_GITHUB_TOKEN }}

- name: Run checks
run: |
make ci
- name: Build
run: |
make release
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bin
*/bin
.idea
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM alpine

ARG TARGETOS
ARG TARGETARCH

LABEL org.opencontainers.image.source https://github.com/kluster-api/capi-scripts

RUN apk add --no-cache bash curl ca-certificates

COPY scripts /tmp/scripts
68 changes: 68 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
SHELL=/bin/bash -o pipefail

REGISTRY ?= ghcr.io/appscode
BIN ?= capi-scripts
IMAGE := $(REGISTRY)/$(BIN)
TAG ?= $(shell git describe --exact-match --abbrev=0 2>/dev/null || echo "")

DOCKER_PLATFORMS := linux/amd64 linux/arm64
PLATFORM ?= linux/$(subst x86_64,amd64,$(subst aarch64,arm64,$(shell uname -m)))
VERSION = $(TAG)_$(subst /,_,$(PLATFORM))

container-%:
@$(MAKE) container \
--no-print-directory \
PLATFORM=$(subst _,/,$*)

push-%:
@$(MAKE) push \
--no-print-directory \
PLATFORM=$(subst _,/,$*)

all-container: $(addprefix container-, $(subst /,_,$(DOCKER_PLATFORMS)))

all-push: $(addprefix push-, $(subst /,_,$(DOCKER_PLATFORMS)))

.PHONY: container
container:
@echo "container: $(IMAGE):$(VERSION)"
@docker buildx build --platform $(PLATFORM) --load --pull -t $(IMAGE):$(VERSION) -f Dockerfile .
@echo

push: container
@docker push $(IMAGE):$(VERSION)
@echo "pushed: $(IMAGE):$(VERSION)"
@echo

.PHONY: docker-manifest
docker-manifest:
docker manifest create -a $(IMAGE):$(TAG) $(foreach PLATFORM,$(DOCKER_PLATFORMS),$(IMAGE):$(TAG)_$(subst /,_,$(PLATFORM)))
docker manifest push $(IMAGE):$(TAG)

.PHONY: release
release:
@$(MAKE) all-push docker-manifest --no-print-directory

.PHONY: version
version:
@echo version=$(VERSION)

.PHONY: fmt
fmt:
@find . -path ./vendor -prune -o -name '*.sh' -exec shfmt -l -w -ci -i 4 {} \;

.PHONY: verify
verify: fmt
@if !(git diff --exit-code HEAD); then \
echo "files are out of date, run make fmt"; exit 1; \
fi

.PHONY: ci
ci: verify

# make and load docker image to kind cluster
.PHONY: push-to-kind
push-to-kind: container
@echo "Loading docker image into kind cluster...."
@kind load docker-image $(IMAGE):$(VERSION)
@echo "Image has been pushed successfully into kind cluster."
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# capi-scripts

* `make release`
Loading

0 comments on commit fcf1463

Please sign in to comment.