Skip to content

Commit

Permalink
chore: update makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyasbhat0 committed Aug 21, 2024
1 parent 7e1b423 commit 15344c4
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 18 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/release-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Release Dev image

on:
push:
branches: [main]

jobs:
release-dev:
name: release-dev-binaries-and-images
runs-on: ubuntu-latest

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

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

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

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

- name: release-cross-testnet
run: make release-cross
env:
TAG: testnet
GORELEASER_SKIP_VALIDATE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: release-testnet
run: make release
env:
GORELEASER_SKIP_VALIDATE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: release-cross
run: make release-cross
env:
GORELEASER_SKIP_VALIDATE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: release
run: make release
env:
GORELEASER_SKIP_VALIDATE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .goreleaser-cross.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ dockers:
goos: linux
goarch: arm64
image_templates:
- 'ghcr.io/arkeonetwork/{{ .ProjectName }}d:{{if eq .Env.RELEASE "true"}}v{{ .Version }}-arm64v8{{else}}{{ .ShortCommit }}-arm64v8{{end}}'
- 'ghcr.io/arkeonetwork/{{ .ProjectName }}d:{{if eq .Env.RELEASE "true"}}v{{ .Version }}-arm64{{else}}{{ .ShortCommit }}-arm64{{end}}'
build_flag_templates:
- "--pull"
- "--platform=linux/arm64"
Expand All @@ -155,7 +155,7 @@ dockers:
goarch: arm64
dockerfile: Dockerfile.dev
image_templates:
- 'ghcr.io/arkeonetwork/{{ .ProjectName }}d-dev:{{if eq .Env.RELEASE "true"}}v{{ .Version }}{{else}}{{ .ShortCommit }}{{end}}-arm64v8'
- 'ghcr.io/arkeonetwork/{{ .ProjectName }}d-dev:{{if eq .Env.RELEASE "true"}}v{{ .Version }}{{else}}{{ .ShortCommit }}{{end}}-arm64'
build_flag_templates:
- "--pull"
- "--platform=linux/arm64"
Expand All @@ -175,12 +175,12 @@ docker_manifests:
- --insecure
image_templates:
- 'ghcr.io/arkeonetwork/{{ .ProjectName }}d:{{if eq .Env.RELEASE "true"}}v{{ .Version }}-amd64{{else}}{{ .ShortCommit }}-amd64{{end}}'
- 'ghcr.io/arkeonetwork/{{ .ProjectName }}d:{{if eq .Env.RELEASE "true"}}v{{ .Version }}-arm64v8{{else}}{{ .ShortCommit }}-arm64v8{{end}}'
- 'ghcr.io/arkeonetwork/{{ .ProjectName }}d:{{if eq .Env.RELEASE "true"}}v{{ .Version }}-arm64{{else}}{{ .ShortCommit }}-arm64{{end}}'
- name_template: 'ghcr.io/arkeonetwork/{{ .ProjectName }}d-dev:{{if eq .Env.RELEASE "true" }}v{{ .Version }}{{else}}{{ .ShortCommit }}{{end}}'
create_flags:
- --insecure
push_flags:
- --insecure
image_templates:
- 'ghcr.io/arkeonetwork/{{ .ProjectName }}d-dev:{{if eq .Env.RELEASE "true"}}v{{ .Version }}{{else}}{{ .ShortCommit }}{{end}}-amd64'
- 'ghcr.io/arkeonetwork/{{ .ProjectName }}d-dev:{{if eq .Env.RELEASE "true"}}v{{ .Version }}{{else}}{{ .ShortCommit }}{{end}}-arm64v8'
- 'ghcr.io/arkeonetwork/{{ .ProjectName }}d-dev:{{if eq .Env.RELEASE "true"}}v{{ .Version }}{{else}}{{ .ShortCommit }}{{end}}-arm64'
93 changes: 80 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ PROJECT_NAME= arkeo
DOCKER := $(shell which docker)
NOW=$(shell date +'%Y-%m-%d_%T')
COMMIT:=$(shell git log -1 --format='%H')
SHORT_COMMIT:=$(shell git rev-parse --short=7 HEAD)
CHAIN_VERSION:=$(shell cat chain.version)
SENTINEL_VERSION:=$(shell cat sentinel.version)
TAG?=latest
Expand Down Expand Up @@ -55,6 +56,7 @@ GORELEASER_VERSION = v1.21.0
# Release Env Variable
RELEASE ?= false
GORELEASER_SKIP_VALIDATE ?= false
GORELEASER_SKIP_PUBLISH ?= false

########################################################################################
# Targets
Expand All @@ -74,8 +76,40 @@ install-testnet:

# ------------------------------ Docker Build ------------------------------

# Detect OS and architecture
OS := $(shell uname -s)
ARCH := $(shell uname -m)

# Determine the Docker build command based on OS and architecture
ifeq ($(OS), Darwin)
ifeq ($(ARCH), arm64)
DOCKER_BUILD := docker-build-cross
IMAGE_ARCH:= arm64
else ifeq ($(ARCH), x86_64)
IMAGE_ARCH:= arm64
DOCKER_BUILD := docker-build-cross
endif
else ifeq ($(OS), Linux)
ifeq ($(ARCH), arm64)
IMAGE_ARCH:= arm64
DOCKER_BUILD := docker-build-cross
else ifeq ($(ARCH), x86_64)
IMAGE_ARCH:= amd64
DOCKER_BUILD := docker-build
endif
endif

# Fallback for unsupported architectures
ifeq ($(DOCKER_BUILD),)
$(error Unsupported architecture: $(ARCH))
endif

# Docker build target
build:
@$(MAKE) $(DOCKER_BUILD)

docker-build:
$(DOCKER) run \
@docker run \
--rm \
-e BUILD_TAG=$(TAG) \
-e RELEASE=$(RELEASE) \
Expand All @@ -84,13 +118,31 @@ docker-build:
-v `pwd`:/go/src/github.com/arkeonetwork/arkeo \
-w /go/src/github.com/arkeonetwork/arkeo \
ghcr.io/goreleaser/goreleaser:$(GORELEASER_VERSION) \
--clean
--snapshot
--clean \
--snapshot \
--skip=$(GORELEASER_SKIP_VALIDATE)

docker-build-cross:
@docker run \
--rm \
-e CGO_ENABLED=1 \
-e BUILD_TAG=$(TAG) \
-e RELEASE=$(RELEASE)\
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-v `pwd`/sysroot:/sysroot \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
-f .goreleaser-cross.yaml \
--clean \
--snapshot \
--skip-validate=$(GORELEASER_SKIP_VALIDATE) \
--skip-publish=$(GORELEASER_SKIP_PUBLISH)


localnet: docker-build
@docker run --rm -it -p 1317:1317 -p 26656:26656 -p 26657:26657 ${IMAGE}:${TAG}

localnet: build
IMAGE_TAG=$(SHORT_COMMIT)-$(IMAGE_ARCH) docker-compose -f docker-compose-localnet.yaml up

# ------------------------------ Testnet ------------------------------

Expand Down Expand Up @@ -280,19 +332,34 @@ release-dry-run:
ghcr.io/goreleaser/goreleaser:${GORELEASER_VERSION} \
--clean --skip=validate --skip=publish

.PHONY: release
.PHONY: releases
release:
@if [ ! -f ".release-env" ]; then \
echo "\033[91m.release-env is required for release\033[0m";\
exit 1;\
fi
docker run \
@docker run \
--rm \
-e CGO_ENABLED=1 \
-e BUILD_TAG=$(TAG) \
-e RELEASE=$(RELEASE)\
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-v `pwd`/sysroot:/sysroot \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser:${GORELEASER_VERSION} \
--clean \
--skip-validate=$(GORELEASER_SKIP_VALIDATE) \
--skip-publish=$(GORELEASER_SKIP_PUBLISH)

release-cross:
@docker run \
--rm \
-e CGO_ENABLED=1 \
--env-file .release-env \
-e BUILD_TAG=$(TAG) \
-e RELEASE=$(RELEASE)\
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-v `pwd`/sysroot:/sysroot \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --clean
-f .goreleaser-cross.yaml \
--clean \
--skip-validate=$(GORELEASER_SKIP_VALIDATE) \
--skip-publish=$(GORELEASER_SKIP_PUBLISH)
2 changes: 1 addition & 1 deletion docker-compose-localnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3"

services:
node:
image: ghcr.io/arkeonetwork/arkeod-dev:${TAG}
image: ghcr.io/arkeonetwork/arkeod-dev:${IMAGE_TAG}
entrypoint:
- sh
- /opt/genesis.sh
Expand Down

0 comments on commit 15344c4

Please sign in to comment.