Skip to content

Commit

Permalink
Build and release linux artifacts on tags (#39)
Browse files Browse the repository at this point in the history
* Create Github release on tags

* Build e2e test runner with CGO
  • Loading branch information
alpe authored Jun 8, 2023
1 parent 94819bd commit 7143902
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 5 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release mesh-security

on:
push:
tags:
- "v*.*.*"
permissions:
contents: read

jobs:
release:
permissions:
contents: write # for goreleaser/goreleaser-action to create a GitHub release
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
check-latest: true
- name: Build demo app artifact
run: make build-linux-static

- name: Create release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
id: create_release
with:
draft: false
prerelease: false
body_path: RELEASE_NOTES.md
files: |
demo/build/*
tests/e2e/build/*
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ install:
build:
$(MAKE) -C demo build

build-linux-static:
$(MAKE) -C demo build-linux-static
$(MAKE) -C tests/e2e build-linux

########################################
### Testing

Expand Down Expand Up @@ -79,5 +83,5 @@ proto-check-breaking:


.PHONY: all install \
build test test-all \
build build-linux-static test test-all \
proto-all proto-format proto-swagger-gen proto-lint proto-check-breaking
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Release
39 changes: 39 additions & 0 deletions demo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM golang:1.20-alpine AS go-builder
ARG ARCH=x86_64

RUN apk add --no-cache ca-certificates build-base git

WORKDIR /code

# Download dependencies and CosmWasm libwasmvm if found.
ADD go.mod go.sum ./

#ADD https://github.com/CosmWasm/wasmvm/releases/download/v$wasmvm/libwasmvm_muslc.$arch.a /lib/libwasmvm_muslc.$arch.a
## Download
RUN set -eux; \
WASM_VERSION=v$(go list -m github.com/CosmWasm/wasmvm | cut -d" " -f2 | cut -d"v" -f2); \
echo $WASM_VERSION; \
wget -O /lib/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASM_VERSION}/libwasmvm_muslc.${ARCH}.a

# Copy over code
COPY . /code

# force it to use static lib (from above) not standard libgo_cosmwasm.so file
# then log output of file /code/bin/meshd
# then ensure static linking
RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build-vendored \
&& file /code/build/meshd \
&& echo "Ensuring binary is statically linked ..." \
&& (file /code/build/meshd | grep "statically linked")

# --------------------------------------------------------
FROM alpine:3.16

COPY --from=go-builder /code/build/meshd /usr/bin/meshd

WORKDIR /opt

# rest server, tendermint p2p, tendermint rpc
EXPOSE 1317 26656 26657

CMD ["/usr/bin/meshd", "version"]
18 changes: 15 additions & 3 deletions demo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
BINDIR ?= $(GOPATH)/bin
SIMAPP = .
BUILD_DIR = ./build

export GO111MODULE = on

Expand Down Expand Up @@ -76,9 +76,21 @@ ifeq ($(OS),Windows_NT)
$(error mesh demo server not supported)
exit 1
else
go build -mod=readonly $(BUILD_FLAGS) -o build/meshd ./cmd/meshd
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILD_DIR)/meshd ./cmd/meshd
endif

build-vendored:
go build -mod=vendor $(BUILD_FLAGS) -o $(BUILD_DIR)/meshd ./cmd/meshd

build-linux-static:
go mod vendor # quick hack to make local dependencies work in Docker
mkdir -p $(BUILD_DIR)
docker build --tag osmosis/meshd:local ./
docker create --name meshd_temp osmosis/meshd:local
docker cp meshd_temp:/usr/bin/meshd $(BUILD_DIR)/
docker rm -f meshd_temp
rm -rf vendor/

install:
go install -mod=readonly $(BUILD_FLAGS) ./cmd/meshd

Expand Down Expand Up @@ -106,6 +118,6 @@ test-sim-multi-seed-short: runsim
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 10 TestFullAppSimulation

.PHONY: all \
go-mod-cache draw-deps clean build \
go-mod-cache draw-deps clean build build-linux-static build-vendored \
test test-all test-build test-cover test-unit test-race \
proto-all proto-format proto-swagger-gen proto-lint proto-check-breaking
10 changes: 9 additions & 1 deletion tests/e2e/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#!/usr/bin/make -f

BUILD_DIR = ./build

all: test

test:
go test -mod=readonly -race ./...

.PHONY: all test
build:
CGO_ENABLED=1 go test -c -mod=readonly -o $(BUILD_DIR)/mesh-security.e2e.test

build-linux:
CGO_ENABLED=1 GOOS=linux go test -c -mod=readonly -o $(BUILD_DIR)/mesh-security.e2e.test

.PHONY: all build build-linux test

0 comments on commit 7143902

Please sign in to comment.