Skip to content

Commit

Permalink
Modify the Makefile to build release bundles (#150)
Browse files Browse the repository at this point in the history
* change to create release bundles in Makefile instead of CI

* opt-out of macOS release bundles

* fix to select the appropriate libwasmvm.* version used in the repository

* remove redandant matrix settings

* make the method for getting the libwasmvm libraries the same
  • Loading branch information
torao authored Mar 6, 2023
1 parent 10df576 commit f10051e
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 124 deletions.
210 changes: 96 additions & 114 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
build_for_linux:
name: "Release Build for Linux"
needs: create_tarball
runs-on: ubuntu-latest
runs-on: self-hosted
strategy:
matrix:
arch: [ amd64, arm64 ]
Expand All @@ -41,12 +41,10 @@ jobs:
cc: x86_64-linux-gnu-gcc
cxx: x86_64-linux-gnu-g++
libwasmvm: libwasmvm.x86_64.so
test: 1
- arch: arm64
cc: aarch64-linux-gnu-gcc
cxx: aarch64-linux-gnu-g++
libwasmvm: libwasmvm.aarch64.so
test: 0
steps:
- name: "Set tag as version"
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV # set env.VERSION=v0.0.0
Expand All @@ -71,102 +69,86 @@ jobs:

- name: "Set ID=${{ env.VERSION }}-linux-${{ matrix.arch }}"
run: echo "ID=${{ env.VERSION }}-linux-${{ matrix.arch }}" >> $GITHUB_ENV
- name: "Build artifact: linux-${{ matrix.arch }}"
- name: "Build release bundle: linux-${{ matrix.arch }}"
run: |
make clean build GOARCH=${{ matrix.arch }} CC=${{ matrix.cc }} CXX=${{ matrix.cxx }}
- name: "Archive artifact: linux-${{ matrix.arch }}"
go env -w GOARCH=${{ matrix.arch }}
make clean build-release-bundle CC=${{ matrix.cc }} CXX=${{ matrix.cxx }}
- name: "Create checksum: linux-${{ matrix.arch }}"
run: |
mkdir -p ./artifacts/lbm-${{ env.ID }}
mv ./build/lbm ./artifacts/lbm-${{ env.ID }}/lbm-${{ env.ID }}
cd ./artifacts
LIBWASMVM=`find ~ -name ${{ matrix.libwasmvm }} -type f`
if [ ! -f "$LIBWASMVM" ]; then echo "ERROR: ${{ matrix.libwasmvm }} not found: $LIBWASMVM"; exit 1; fi
cp "$LIBWASMVM" ./lbm-${{ env.ID }}/${{ matrix.libwasmvm }}
ls -laF ./lbm-${{ env.ID }}
echo "MD5: `md5sum ./lbm-${{ env.ID }}/lbm-${{ env.ID }}`"
if [ ${{ matrix.test }} -eq 1 ]; then echo "Binary launch version: `LD_LIBRARY_PATH=./lbm-${{ env.ID }} ./lbm-${{ env.ID }}/lbm-${{ env.ID }} version`" 2>&1; fi
tar zcvf ./lbm-${{ env.ID }}.tgz lbm-${{ env.ID }}/
cd ./build
ls -laF
md5sum lbm-${{ env.ID }}.tgz > ./lbm-${{ env.ID }}.md5
sha256sum lbm-${{ env.ID }}.tgz > ./lbm-${{ env.ID }}.sha256
- name: "Store artifact: linux-${{ matrix.arch }}"
uses: actions/upload-artifact@v3
with:
name: release-${{ env.VERSION }}
path: |
./artifacts/lbm-${{ env.ID }}.tgz
./artifacts/lbm-${{ env.ID }}.md5
./artifacts/lbm-${{ env.ID }}.sha256
./build/lbm-${{ env.ID }}.tgz
./build/lbm-${{ env.ID }}.md5
./build/lbm-${{ env.ID }}.sha256
# build_for_darwin:
# name: "Release Build for macOS"
# needs: create_tarball
# runs-on: macOS-latest
# strategy:
# matrix:
# arch: [ "amd64", "arm64" ]
# include:
# - arch: amd64
# libwasmvm: libwasmvm.dylib
# test: 1
# - arch: arm64
# libwasmvm: libwasmvm.dylib
# test: 0
# steps:
# - name: "Set tag as version"
# run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV # set env.VERSION=v0.0.0
# - name: "Setup Xcode"
# run: sudo xcode-select --switch /Applications/Xcode.app
# - name: "Install md5sum"
# run: |
# brew update
# brew install md5sha1sum
# - name: "Install go"
# uses: actions/setup-go@v3
# with:
# go-version: '1.18'
# check-latest: true
# - name: "Print go environment"
# run: go env
# - name: "Download compressed repository source"
# uses: actions/download-artifact@v3
# with:
# name: release-${{ env.VERSION }}
# - name: "Extract compressed repository source"
# run: tar zxf lbm-${{ env.VERSION }}.tgz --strip-components=1
#
# - name: "Set ID=${{ env.VERSION }}-darwin-${{ matrix.arch }}"
# run: echo "ID=${{ env.VERSION }}-darwin-${{ matrix.arch }}" >> $GITHUB_ENV
# - name: "Build artifact: darwin-${{ matrix.arch }}"
# run: |
# make clean build GOARCH=${{ matrix.arch }}
# - name: "Archive artifact: darwin-${{ matrix.arch }}"
# run: |
# mkdir -p ./artifacts/lbm-${{ env.ID }}
# mv ./build/lbm ./artifacts/lbm-${{ env.ID }}/lbm-${{ env.ID }}
# cd ./artifacts
# LIBWASMVM=`find ~ -name ${{ matrix.libwasmvm }} -type f`
# if [ ! -f "$LIBWASMVM" ]; then echo "ERROR: ${{ matrix.libwasmvm }} not found: $LIBWASMVM"; exit 1; fi
# cp "$LIBWASMVM" ./lbm-${{ env.ID }}/${{ matrix.libwasmvm }}
# ls -laF ./lbm-${{ env.ID }}
# echo "MD5: `md5sum ./lbm-${{ env.ID }}/lbm-${{ env.ID }}`"
# if [ ${{ matrix.test }} -eq 1 ]; then echo "Binary launch version: `LD_LIBRARY_PATH=./lbm-${{ env.ID }} ./lbm-${{ env.ID }}/lbm-${{ env.ID }} version`" 2>&1; fi
# tar zcvf ./lbm-${{ env.ID }}.tgz lbm-${{ env.ID }}/
# md5sum lbm-${{ env.ID }}.tgz > ./lbm-${{ env.ID }}.md5
# shasum -a 256 lbm-${{ env.ID }}.tgz > ./lbm-${{ env.ID }}.sha256
# - name: "Store artifact: darwin-${{ matrix.arch }}"
# uses: actions/upload-artifact@v3
# with:
# name: release-${{ env.VERSION }}
# path: |
# ./artifacts/lbm-${{ env.ID }}.tgz
# ./artifacts/lbm-${{ env.ID }}.md5
# ./artifacts/lbm-${{ env.ID }}.sha256
# build_for_darwin:
# name: "Release Build for macOS"
# needs: create_tarball
# runs-on: macOS-latest
# strategy:
# matrix:
# arch: [ "amd64", "arm64" ]
# include:
# - arch: amd64
# libwasmvm: libwasmvm.dylib
# - arch: arm64
# libwasmvm: libwasmvm.dylib
# steps:
# - name: "Set tag as version"
# run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV # set env.VERSION=v0.0.0
# - name: "Setup Xcode"
# run: sudo xcode-select --switch /Applications/Xcode.app
# - name: "Install md5sum"
# run: |
# brew update
# brew install md5sha1sum
# - name: "Install go"
# uses: actions/setup-go@v3
# with:
# go-version: '1.18'
# check-latest: true
# - name: "Print go environment"
# run: go env
# - name: "Download compressed repository source"
# uses: actions/download-artifact@v3
# with:
# name: release-${{ env.VERSION }}
# - name: "Extract compressed repository source"
# run: tar zxf lbm-${{ env.VERSION }}.tgz --strip-components=1
#
# - name: "Set ID=${{ env.VERSION }}-darwin-${{ matrix.arch }}"
# run: echo "ID=${{ env.VERSION }}-darwin-${{ matrix.arch }}" >> $GITHUB_ENV
# - name: "Build release bundle: darwin-${{ matrix.arch }}"
# run: |
# go env -w GOARCH=${{ matrix.arch }}
# make clean build-release-bundle
# - name: "Create checksum: darwin-${{ matrix.arch }}"
# run: |
# cd ./build
# ls -laF
# md5sum lbm-${{ env.ID }}.tgz > ./lbm-${{ env.ID }}.md5
# shasum -a 256 lbm-${{ env.ID }}.tgz > ./lbm-${{ env.ID }}.sha256
# - name: "Store artifact: darwin-${{ matrix.arch }}"
# uses: actions/upload-artifact@v3
# with:
# name: release-${{ env.VERSION }}
# path: |
# ./build/lbm-${{ env.ID }}.tgz
# ./build/lbm-${{ env.ID }}.md5
# ./build/lbm-${{ env.ID }}.sha256

create_release:
name: "Create Release"
needs: [ build_for_linux ]
# needs: [ build_for_linux, build_for_darwin ]
runs-on: ubuntu-latest
# needs: [ build_for_linux, build_for_darwin ]
runs-on: self-hosted
steps:
- name: "Set tag as version"
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV # set env.VERSION=v0.0.0
Expand All @@ -181,17 +163,17 @@ jobs:
run: "ls -laF"
- name: "Create build report"
run: |
echo "App: lbm" > build_report.txt
echo "Version: ${{ env.VERSION }}" >> build_report.txt
echo "Commit: ${{ github.sha }}" >> build_report.txt
echo "Checksums MD5:" >> build_report.txt
echo " `cat lbm-${{ env.VERSION }}-linux-amd64.md5`" >> build_report.txt
echo " `cat lbm-${{ env.VERSION }}-linux-arm64.md5`" >> build_report.txt
echo " `cat lbm-${{ env.VERSION }}.tgz.md5`" >> build_report.txt
echo "Checksums SHA256:" >> build_report.txt
echo " `cat lbm-${{ env.VERSION }}-linux-amd64.sha256`" >> build_report.txt
echo " `cat lbm-${{ env.VERSION }}-linux-arm64.sha256`" >> build_report.txt
echo " `cat lbm-${{ env.VERSION }}.tgz.sha256`" >> build_report.txt
echo "App: lbm" > build_report.txt
echo "Version: ${{ env.VERSION }}" >> build_report.txt
echo "Commit: ${{ github.sha }}" >> build_report.txt
echo "Checksums MD5:" >> build_report.txt
echo " `cat lbm-${{ env.VERSION }}-linux-amd64.md5`" >> build_report.txt
echo " `cat lbm-${{ env.VERSION }}-linux-arm64.md5`" >> build_report.txt
echo " `cat lbm-${{ env.VERSION }}.tgz.md5`" >> build_report.txt
echo "Checksums SHA256:" >> build_report.txt
echo " `cat lbm-${{ env.VERSION }}-linux-amd64.sha256`" >> build_report.txt
echo " `cat lbm-${{ env.VERSION }}-linux-arm64.sha256`" >> build_report.txt
echo " `cat lbm-${{ env.VERSION }}.tgz.sha256`" >> build_report.txt
- name: "Create release note"
run: |
cat ./RELEASE_NOTE.md > release_note.txt
Expand Down Expand Up @@ -229,24 +211,24 @@ jobs:
asset_path: lbm-${{ env.VERSION }}-linux-arm64.tgz
asset_name: lbm-${{ env.VERSION }}-linux-arm64.tgz
asset_content_type: application/octet-stream
# - name: "Upload artifact: lbm-${{ env.VERSION }}-dawrin-amd64"
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ github.token }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: lbm-${{ env.VERSION }}-darwin-amd64.tgz
# asset_name: lbm-${{ env.VERSION }}-darwin-amd64.tgz
# asset_content_type: application/octet-stream
# - name: "Upload artifact: lbm-${{ env.VERSION }}-dawrin-arm64"
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ github.token }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: lbm-${{ env.VERSION }}-darwin-arm64.tgz
# asset_name: lbm-${{ env.VERSION }}-darwin-arm64.tgz
# asset_content_type: application/octet-stream
# - name: "Upload artifact: lbm-${{ env.VERSION }}-dawrin-amd64"
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ github.token }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: lbm-${{ env.VERSION }}-darwin-amd64.tgz
# asset_name: lbm-${{ env.VERSION }}-darwin-amd64.tgz
# asset_content_type: application/octet-stream
# - name: "Upload artifact: lbm-${{ env.VERSION }}-dawrin-arm64"
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ github.token }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: lbm-${{ env.VERSION }}-darwin-arm64.tgz
# asset_name: lbm-${{ env.VERSION }}-darwin-arm64.tgz
# asset_content_type: application/octet-stream
- name: "Upload artifact: compressed repository source"
uses: actions/upload-release-asset@v1
env:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (ibc-go) [\#140](https://github.com/line/lbm/pull/140) apply ibc-go
* (x/wasmplus) [\#141](https://github.com/line/lbm/pull/141) change wasm module to wrapped `x/wasmplus`
* (lbm-sdk) [\#144](https://github.com/line/lbm/pull/144) bump line/lbm-sdk v0.47.0-alpha1 (11966d1234155ebef20b64f2ae7a905beffdb33f)
* (build) [\#150](https://github.com/line/lbm/pull/150) Modify the Makefile to build release bundles

### Improvements
* (x/wasmd) [\#146](https://github.com/line/lbm/pull/146) update wasmd version
Expand Down
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ COPY ./go.mod /lbm-build/lbm/go.mod
COPY ./go.sum /lbm-build/lbm/go.sum
RUN go mod download

# See https://github.com/line/wasmvm/releases
ADD https://github.com/line/wasmvm/releases/download/v1.1.1-0.11.1/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
ADD https://github.com/line/wasmvm/releases/download/v1.1.1-0.11.1/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep e03e401e58f72d40a08a99a81bb05123146bb1d6f68b9afbede5481b3ea460f7
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep 06fcd14950c5014e35cc4af39090cb7161b5594d398a7d8fb05525d991370a18
# Install libwasmvm.*.a
COPY ./builders/scripts/install-libwasmvm.sh ./
RUN sh install-libwasmvm.sh && rm install-libwasmvm.sh

RUN ln -s /lib/libwasmvm_muslc.${ARCH}.a /usr/lib/libwasmvm_muslc.a

Expand Down
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ ifeq (,$(findstring nostrip,$(LBM_BUILD_OPTIONS)))
BUILD_FLAGS += -trimpath
endif

# platform depend behavior
ifeq (darwin, $(shell go env GOOS))
LIBWASMVM ?= libwasmvm.dylib
else
ifeq (linux, $(shell go env GOOS))
LIBWASMVM ?= libwasmvm.$(ARCH).so
else
echo "ERROR: unsupported platform: $(shell go env GOOS)"
exit 1
endif
endif

#$(info $$BUILD_FLAGS is [$(BUILD_FLAGS)])

# The below include contains the tools target.
Expand All @@ -154,6 +166,29 @@ build-static-centos7: go.sum $(BUILDDIR)/
docker build -t line/lbm-builder:static_centos7 -f builders/Dockerfile.static_centos7 .
docker run -it --rm -v $(shell pwd):/code -e LBM_BUILD_OPTIONS="$(LBM_BUILD_OPTIONS)" line/lbm-builder:static_centos7

# USAGE: go env -w GOARCH={amd64|arm64} && make clean build-release-bundle VERSION=v0.0.0
RELEASE_BUNDLE=lbm-$(VERSION)-$(shell go env GOOS)-$(shell go env GOARCH)
LIBWASMVM_VERSION=$(shell go list -m github.com/line/wasmvm | awk '{print $$2}')
LIBWASMVM_PATH=$(shell find $(shell go env GOMODCACHE) -name $(LIBWASMVM) -type f | grep "$(LIBWASMVM_VERSION)")
build-release-bundle: build
@if [ "$(shell go env GOOS)" != "$(shell go env GOHOSTOS)" ]; then echo "ERROR: OS not match"; exit 1; fi
@if [ -z "${LIBWASMVM_PATH}" ]; then echo "ERROR: $(LIBWASMVM) $(LIBWASMVM_VERSION) not found: $(shell go env GOMODCACHE)"; exit 1; fi
@if [ ! -f "${LIBWASMVM_PATH}" ]; then echo "ERROR: Multiple version of $(LIBWASMVM) found: ${LIBWASMVM_PATH}"; exit 1; fi
@mkdir -p $(BUILDDIR)/$(RELEASE_BUNDLE)
@cp $(BUILDDIR)/lbm $(BUILDDIR)/$(RELEASE_BUNDLE)/$(RELEASE_BUNDLE)
@cp "$(LIBWASMVM_PATH)" $(BUILDDIR)/$(RELEASE_BUNDLE)/
@case "$(shell go env GOHOSTOS),$(shell go env GOHOSTARCH),$(shell go env GOARCH)" in \
*,amd64,amd64 | *,arm64,arm64 | darwin,arm64,*) \
LD_LIBRARY_PATH=$(BUILDDIR)/$(RELEASE_BUNDLE) $(BUILDDIR)/$(RELEASE_BUNDLE)/$(RELEASE_BUNDLE) version; \
if [ $$? -ne 0 ]; then echo "ERROR: Test execution failed."; printenv; go env; exit 1; fi; \
echo "OK: Test execution confirmed.";; \
*) \
echo "SKIP: Test execution unconfirmed.";; \
esac
@cd $(BUILDDIR) && tar zcvf ./$(RELEASE_BUNDLE).tgz $(RELEASE_BUNDLE)/ > /dev/null 2>&1
@rm -rf $(BUILDDIR)/$(RELEASE_BUNDLE)/
@echo "Built: $(BUILDDIR)/$(RELEASE_BUNDLE).tgz"

install: go.sum $(BUILDDIR)/ dbbackend $(LIBSODIUM_TARGET)
CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_ENABLED=$(CGO_ENABLED) go install $(BUILD_FLAGS) $(BUILD_ARGS) ./cmd/lbm

Expand Down
8 changes: 3 additions & 5 deletions builders/Dockerfile.static
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ COPY ./go.mod /lbm-build/lbm/go.mod
COPY ./go.sum /lbm-build/lbm/go.sum
RUN go mod download

# See https://github.com/line/wasmvm/releases
ADD https://github.com/line/wasmvm/releases/download/v1.1.1-0.11.1/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
ADD https://github.com/line/wasmvm/releases/download/v1.1.1-0.11.1/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep e03e401e58f72d40a08a99a81bb05123146bb1d6f68b9afbede5481b3ea460f7
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep 06fcd14950c5014e35cc4af39090cb7161b5594d398a7d8fb05525d991370a18
# Install libwasmvm.*.a
COPY ./builders/scripts/install-libwasmvm.sh ./
RUN sh install-libwasmvm.sh && rm install-libwasmvm.sh

RUN ln -s /lib/libwasmvm_muslc.${ARCH}.a /usr/lib/libwasmvm_muslc.a

Expand Down
22 changes: 22 additions & 0 deletions builders/scripts/install-libwasmvm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# This script is used in the Dockerfiles and installs the lbm dependency libwasmvm.*.a into the container image.
# See also https://github.com/line/wasmvm/releases

set -e

WASMVM_VERSION=`go list -m github.com/line/wasmvm | awk '{print $2}' | grep -o 'v\d\+\.\d\+\.\d\+-\d\+\.\d\+\.\d\+'`
curl -L -f -o ./checksums.txt https://github.com/line/wasmvm/releases/download/${WASMVM_VERSION}/checksums.txt
for arch in x86_64 aarch64
do
curl -L -f -o /lib/libwasmvm_muslc.${arch}.a https://github.com/line/wasmvm/releases/download/${WASMVM_VERSION}/libwasmvm_muslc.$arch.a
CHECKSUM=`grep libwasmvm_muslc.${arch}.a ./checksums.txt | awk '{print $1}'`
if [ -z "${CHECKSUM}" ]
then
echo "ERROR: libwasmvm_muslc.${arch}.a"
cat ./checksums.txt
exit 1
fi
sha256sum /lib/libwasmvm_muslc.${arch}.a | grep "${CHECKSUM}"
done
rm ./checksums.txt

0 comments on commit f10051e

Please sign in to comment.