Skip to content

Commit

Permalink
feat: backport integrated swagger and static binary compilation featu…
Browse files Browse the repository at this point in the history
…res (#221, #223) (#225)

* feat: add integrated swagger for finschia (#223)

* feat: add integrated swagger for finschia.

Signed-off-by: zemyblue <zemyblue@gmail.com>

* chore: update changelog

Signed-off-by: zemyblue <zemyblue@gmail.com>

* ci: add a ci to check generated code.

Signed-off-by: zemyblue <zemyblue@gmail.com>

* ci: add a ci to check generated code up-to-date

Signed-off-by: zemyblue <zemyblue@gmail.com>

* fix: ci error

Signed-off-by: zemyblue <zemyblue@gmail.com>
(cherry picked from commit b98ef07008b1a1e93882447e67286a0a2ae6339f)

---------

Signed-off-by: zemyblue <zemyblue@gmail.com>
(cherry picked from commit d649d83)

* feat: compile static binary as release assets and docker image (#221)

* build: modify docker image base and binary using static library.

Signed-off-by: zemyblue <zemyblue@gmail.com>

* chore: change the description in readme

Signed-off-by: zemyblue <zemyblue@gmail.com>

* fix: localnet-docker-build unittest

Signed-off-by: zemyblue <zemyblue@gmail.com>

* ci: change the github action ci for pushing Docker images

Signed-off-by: zemyblue <zemyblue@gmail.com>

* ci: change release build for using static binary assets.

Signed-off-by: zemyblue <zemyblue@gmail.com>

* chore: update changelog

Signed-off-by: zemyblue <zemyblue@gmail.com>

* fix: parse tag in github action of docker.yml

Signed-off-by: zemyblue <zemyblue@gmail.com>

* ci: change docker build and push trigger

Signed-off-by: zemyblue <zemyblue@gmail.com>

* ci: remove condition if `pull_request` or not.

Signed-off-by: zemyblue <zemyblue@gmail.com>

* fix: typo

Signed-off-by: zemyblue <zemyblue@gmail.com>

* chore: remove debian11 and nonroot base docker image

Signed-off-by: zemyblue <zemyblue@gmail.com>

---------

Signed-off-by: zemyblue <zemyblue@gmail.com>
(cherry picked from commit 225b581)

* fix: build option error

Signed-off-by: zemyblue <zemyblue@gmail.com>

* fix: build option error in docker

Signed-off-by: zemyblue <zemyblue@gmail.com>

* fix: build option error in docker

Signed-off-by: zemyblue <zemyblue@gmail.com>

---------

Signed-off-by: zemyblue <zemyblue@gmail.com>
  • Loading branch information
zemyblue authored Jun 26, 2023
1 parent 9b58454 commit a30d888
Show file tree
Hide file tree
Showing 35 changed files with 74,017 additions and 227 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/check-generated.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Verify that generated code is up-to-date.

name: Check generated code
on:
workflow_dispatch:
pull_request:
branches:
- '*'

permissions:
contents: read

jobs:
check-swagger:
runs-on: ubuntu-latest
steps:
- name: Setup Golang
uses: actions/setup-go@v4
with:
go-version: 1.18

- uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Install protoc
uses: arduino/setup-protoc@v2

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "16"
- run: if [ ! -x "$(command -v yarn)" ]; then npm install -g yarn; fi

- name: Check generated swagger docs
run: scripts/ci/check-generated.sh
67 changes: 51 additions & 16 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,88 @@
name: Build & Push
name: Push Docker Images
# Build & Push builds the finschia docker image on every tag push

on:
pull_request:
branches:
- main
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10
- "v[0-9]+.[0-9]+.[0-9]+-*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-alpha1

env:
registry: docker.io
repository: finschia/finschianode
DOCKER_REPOSITORY: finschia/finschianode
RUNNER_BASE_IMAGE_ALPINE: alpine:3.17
jobs:
build:
docker_build_and_push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check out the repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Create a context for buildx
run: docker context create buildx

- name: Set up docker buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
endpoint: buildx
config-inline: |
[registry."docker.io"]
- name: login to the registry
- name: Login to the registry
uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
registry: ${{env.registry}}
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}
- name: extract metadata for docker

- name: Find go version
id: find_go_version
run: |
GO_VERSION=$(cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2)
echo "GO_VERSION=$GO_VERSION" >> $GITHUB_ENV
- name: Find Ostracon version
id: find_ostracon_version
run: |
OST_VERSION=$(go list -m github.com/Finschia/ostracon | sed 's:.* ::')
echo "OST_VERSION=$OST_VERSION" >> $GITHUB_ENV
- name: Parse tag
id: tag
run: |
ref='refs/tags/'
if [[ ${{ github.ref }} == *${ref}* ]]; then
VERSION=$(echo ${{ github.ref_name }} | sed "s/v//")
echo "VERSION=$VERSION" >> $GITHUB_ENV
else
echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV
fi
- name: Extract metadata for docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{env.registry}}/${{env.repository}}
images: ${{env.registry}}/${{env.DOCKER_REPOSITORY}}
tags: |
type=semver,pattern={{version}}
- name: docker build
# Build Docker image
- name: Build and push
uses: docker/build-push-action@v4
with:
push: ${{github.event_name != 'pull_request'}}
build-args: ARCH=x86_64
tags: ${{steps.meta.outputs.tags}}
file: Dockerfile
context: .
push: true
platforms: linux/amd64,linux/arm64
build-args: |
GO_VERSION=${{ env.GO_VERSION }}
RUNNER_IMAGE=${{ env.RUNNER_BASE_IMAGE_ALPINE }}
GIT_VERSION=${{ env.VERSION }}
GIT_COMMIT=${{ github.sha }}
OST_VERSION=${{ env.OST_VERSION }}
tags: |
${{ env.DOCKER_REPOSITORY }}:${{ env.VERSION }}
labels: ${{steps.meta.outputs.labels}}
platforms: linux/amd64
Loading

0 comments on commit a30d888

Please sign in to comment.