Skip to content

Commit

Permalink
Merge pull request #95 from octo-node/feature/release-workflow
Browse files Browse the repository at this point in the history
Create draft release with statically built binaries on push tags
  • Loading branch information
woof-chihuahua authored Aug 10, 2023
2 parents d75b6e5 + 935b758 commit f6a8f7d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 14 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,22 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '^1.19'
with:
go-version: "^1.19"
env:
GOOS: ${{ matrix.targetos }}
GOARCH: ${{ matrix.arch }}



- name: run tests
run: go test ./...

# we build and install in case we want to run it or capture an artifact as we do in the step below.
# we build and install in case we want to run it or capture an artifact as we do in the step below.
- name: Compile chihuahuad
run: |
go build ./...
go install ./...
# now uploads genesis.json and bin
# now uploads genesis.json and bin
- uses: actions/upload-artifact@v3
with:
name: chihuahuad ${{ matrix.targetos }} ${{ matrix.arch }}
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "Release"

on:
push:
tags:
- v*
jobs:
draft-release:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout repository
uses: actions/checkout@v3

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

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

- name: Copy Binary
run: |
make build-reproducible-all
- name: Draft Release
uses: softprops/action-gh-release@v1
with:
draft: true
files: |
chihuahuad_linux_arm64
chihuahuad_linux_amd64
chihuahuad_sha256.txt
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG IMG_TAG=latest
ARG PLATFORM="linux/amd64"
ARG GO_VERSION="1.20"
ARG GO_VERSION="1.19"
ARG RUNNER_IMAGE="gcr.io/distroless/static"

FROM --platform=${PLATFORM} golang:${GO_VERSION}-alpine as builder
Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
GO_VERSION := "1.20"

# don't override user values
ifeq (,$(VERSION))
Expand Down Expand Up @@ -110,16 +111,17 @@ build-reproducible-generic: go.sum
$(DOCKER) rm $(subst /,-,latest-build-$(PLATFORM)) || true
DOCKER_BUILDKIT=1 $(DOCKER) build -t latest-build-$(PLATFORM) \
--build-arg ARCH=$(ARCH) \
--build-arg GO_VERSION=$(GO_VERSION) \
--build-arg PLATFORM=$(PLATFORM) \
--build-arg VERSION="$(VERSION)" \
-f Dockerfile .
$(DOCKER) create -ti --name $(subst /,-,latest-build-$(PLATFORM)) latest-build-$(PLATFORM) chihuahuad
mkdir -p $(BUILDDIR)/$(NETWORK)/$(PLATFORM)/
$(DOCKER) cp -a $(subst /,-,latest-build-$(PLATFORM)):/usr/local/bin/chihuahuad $(BUILDDIR)/$(NETWORK)/$(PLATFORM)/chihuahuad
$(DOCKER) cp -a $(subst /,-,latest-build-$(PLATFORM)):/usr/local/bin/chihuahuad chihuahuad_$(subst /,_,$(PLATFORM))
sha256sum chihuahuad_$(subst /,_,$(PLATFORM)) >> ./chihuahuad_sha256.txt

# Add check to make sure we are using the proper Go version before proceeding with anything
check-go-version:
@if ! go version | grep -q "go1.19"; then \
echo "\033[0;31mERROR:\033[0m Go version 1.19 is required for compiling chihuahuad. It looks like you are using" "$(shell go version) \nThere are potential consensus-breaking changes that can occur when running binaries compiled with different versions of Go. Please download Go version 1.19 and retry. Thank you!"; \
@if ! go version | grep -q "go$(GO_VERSION)"; then \
echo "\033[0;31mERROR:\033[0m Go version $(GO_VERSION) is required for compiling chihuahuad. It looks like you are using" "$(shell go version) \nThere are potential consensus-breaking changes that can occur when running binaries compiled with different versions of Go. Please download Go version $(GO_VERSION) and retry. Thank you!"; \
exit 1; \
fi

0 comments on commit f6a8f7d

Please sign in to comment.