Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CI/CD workflows for Initia binary builds #227

Closed
wants to merge 75 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
a1c9de1
Implement CI/CD workflows for Initia binary builds
Jul 12, 2024
d185bd2
Update build-linux.yml
LizJeong Jul 12, 2024
4cb15ea
Update build-darwin.yml
LizJeong Jul 12, 2024
3abb338
Update build-linux.yml
LizJeong Jul 12, 2024
b28114b
Update build-and-upload.yml
LizJeong Jul 12, 2024
c4f6954
Update and rename build-linux.yml to build-linux-arm64.yml
LizJeong Jul 12, 2024
bcf1fe6
Create build-linux-amd64.yml
LizJeong Jul 12, 2024
8e1b339
Rename build-linux-arm64.yml to build-linux-arm-64.yml
LizJeong Jul 12, 2024
6a36128
Rename build-linux-amd64.yml to build-linux-amd-64.yml
LizJeong Jul 12, 2024
23e2a7c
Rename build-linux-amd-64.yml to build-linux-amd64.yml
LizJeong Jul 12, 2024
7931af2
Rename build-linux-arm-64.yml to build-linux-arm64.yml
LizJeong Jul 12, 2024
34f5d54
Update docker.yml
LizJeong Jul 12, 2024
c78c8e6
Update build-linux-arm64.yml
LizJeong Jul 12, 2024
31bd2fc
Update build-linux-arm64.yml
LizJeong Jul 12, 2024
3bbad33
Update build-linux-arm64.yml
LizJeong Jul 12, 2024
2a36ba6
Update build-and-upload.yml
LizJeong Jul 12, 2024
d053fb1
Update build-linux-arm64.yml
LizJeong Jul 12, 2024
0509a3a
Update build-linux-arm64.yml
LizJeong Jul 12, 2024
3315081
Update build-linux-arm64.yml
LizJeong Jul 12, 2024
b47993c
Update build-linux-arm64.yml
LizJeong Jul 12, 2024
dc9b12e
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
f7cd13f
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
2096b29
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
7eeba43
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
3dc938d
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
7b53f19
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
ac5eac9
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
46acd57
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
ff6dc71
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
6162104
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
72a123b
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
c16aec5
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
db08398
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
8e57ed8
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
02ce40a
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
bec476e
Create Dockerfile
LizJeong Jul 15, 2024
1693f7f
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
47cbcbc
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
1e44dfa
Update Dockerfile
LizJeong Jul 15, 2024
b2fa6d2
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
7167234
Update Dockerfile
LizJeong Jul 15, 2024
1882737
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
66bf2b0
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
e90d15b
Rename Dockerfile to Dockerfile.linux
LizJeong Jul 15, 2024
b5003da
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
5140778
Update build-linux-arm64.yml
LizJeong Jul 15, 2024
393cd25
Update build-and-upload.yml
LizJeong Jul 15, 2024
474c39d
Update build-darwin.yml
LizJeong Jul 15, 2024
92b1320
Update build-darwin.yml
LizJeong Jul 15, 2024
fd0c2b8
Update and rename Dockerfile.linux to Dockerfile
LizJeong Jul 15, 2024
ea329ae
Update build-darwin.yml
LizJeong Jul 15, 2024
6dbd54d
Update Dockerfile
LizJeong Jul 15, 2024
d8dadf2
Update Dockerfile
LizJeong Jul 15, 2024
5fdb302
Update build-darwin.yml
LizJeong Jul 15, 2024
164fe81
Update Dockerfile
LizJeong Jul 15, 2024
04459f3
Update build-darwin.yml
LizJeong Jul 15, 2024
e3f3edb
Update build-darwin.yml
LizJeong Jul 15, 2024
0714965
Update build-darwin.yml
LizJeong Jul 15, 2024
454fd4a
Update Dockerfile
LizJeong Jul 15, 2024
795ede9
Update build-darwin.yml
LizJeong Jul 15, 2024
c0f3b81
Update and rename Dockerfile to Dockerfile.linux.amd64
LizJeong Jul 15, 2024
b891f1e
Update build-darwin.yml
LizJeong Jul 15, 2024
5aac094
Update Dockerfile.linux.amd64
LizJeong Jul 15, 2024
fff013a
Update Dockerfile.linux.amd64
LizJeong Jul 15, 2024
fa7c2af
Update Dockerfile.linux.amd64
LizJeong Jul 15, 2024
22faf0c
Update Dockerfile.linux.amd64
LizJeong Jul 15, 2024
9ffd42d
Update and rename build-darwin.yml to linux-amd64.yml
LizJeong Jul 15, 2024
f0face0
Update Dockerfile.linux.amd64
LizJeong Jul 15, 2024
f3198c0
Update build-linux-amd64.yml
LizJeong Jul 15, 2024
75c5148
Update Dockerfile.linux.amd64
LizJeong Jul 15, 2024
22f7720
Update build-linux-amd64.yml
LizJeong Jul 15, 2024
6616743
Update Dockerfile.linux.amd64
LizJeong Jul 15, 2024
48e9cdd
Update build-linux-amd64.yml
LizJeong Jul 15, 2024
10e7d21
Create build-darwin-amd64.yml
LizJeong Jul 15, 2024
3923cd9
Update build-and-upload.yml
LizJeong Jul 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/Dockerfile.linux.amd64
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM golang:1.22

WORKDIR /src

RUN apt-get update && apt-get install -y git make

COPY . .

ENV MOVEVM_VERSION=v0.2.12

# Go 모듈 다운로드
RUN go mod download

# 직접 빌드 수행
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o /src/build/initiad ./cmd/initiad

# movevm 라이브러리 다운로드 및 복사
RUN go get github.com/initia-labs/movevm@${MOVEVM_VERSION}
RUN cp /go/pkg/mod/github.com/initia-labs/movevm@${MOVEVM_VERSION}/api/libmovevm.so /src/build/libmovevm.amd64.so
RUN cp /go/pkg/mod/github.com/initia-labs/movevm@${MOVEVM_VERSION}/api/libcompiler.so /src/build/libcompiler.amd64.so

# 결과물 준비
RUN mkdir -p /output && \
cp /src/build/initiad /output/ && \
cp /src/build/libmovevm.amd64.so /output/ && \
cp /src/build/libcompiler.amd64.so /output/

FROM ubuntu:20.04

WORKDIR /app

COPY --from=0 /output/initiad /app/
COPY --from=0 /output/libmovevm.amd64.so /app/
COPY --from=0 /output/libcompiler.amd64.so /app/

CMD ["/app/initiad", "version"]
18 changes: 18 additions & 0 deletions .github/workflows/build-and-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build and Upload to GCS

on:
# push:
# tags:
# - 'v*'
# push:
# branches:
# - "main"

jobs:
# build-linux-amd64:
# uses: ./.github/workflows/build-linux-amd64.yml
# secrets: inherit

build-linux-arm64:
uses: ./.github/workflows/build-linux-arm64.yml
secrets: inherit
62 changes: 62 additions & 0 deletions .github/workflows/build-darwin-amd64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build and Upload Darwin AMD64

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
GO_VERSION: '1.22'
MOVEVM_VERSION: 'v0.2.12'
L1_NETWORK_NAME: 'testnet'

jobs:
build-and-upload:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Build initiad
run: |
make build ARCH=amd64

- name: Prepare artifacts
run: |
mkdir -p artifacts
cp build/initiad artifacts/
cp ~/go/pkg/mod/github.com/initia-labs/movevm@${MOVEVM_VERSION}/api/libmovevm.dylib artifacts/
cp ~/go/pkg/mod/github.com/initia-labs/movevm@${MOVEVM_VERSION}/api/libcompiler.dylib artifacts/
tar -czvf initia_${{ github.sha }}_Darwin_amd64.tar.gz -C artifacts .

- name: Google Auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'

- name: Set up Cloud SDK
uses: 'google-github-actions/setup-gcloud@v2'

- name: Upload to GCS
env:
GCS_BUCKET: ${{ secrets.GCS_BUCKET }}
run: |
gsutil cp initia_${{ github.sha }}_Darwin_amd64.tar.gz gs://${GCS_BUCKET}/networks/${{ env.L1_NETWORK_NAME }}/binaries/

- name: Verify upload and Generate public URL
env:
GCS_BUCKET: ${{ secrets.GCS_BUCKET }}
run: |
if gsutil stat gs://${GCS_BUCKET}/networks/${{ env.L1_NETWORK_NAME }}/binaries/initia_${{ github.sha }}_Darwin_amd64.tar.gz; then
echo "File successfully uploaded"
echo "Public URL: https://storage.googleapis.com/${GCS_BUCKET}/networks/${{ env.L1_NETWORK_NAME }}/binaries/initia_${{ github.sha }}_Darwin_amd64.tar.gz" >> $GITHUB_STEP_SUMMARY
else
echo "File upload failed"
exit 1
fi
62 changes: 62 additions & 0 deletions .github/workflows/build-linux-amd64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build and Upload Linux AMD64

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
GO_VERSION: '1.22'
MOVEVM_VERSION: 'v0.2.12'
L1_NETWORK_NAME: 'testnet'

jobs:
build-and-upload:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Build initiad
run: |
make build-linux-with-shared-library ARCH=amd64

- name: Prepare artifacts
run: |
mkdir -p artifacts
cp build/initiad artifacts/
cp build/libmovevm.so artifacts/libmovevm.amd64.so
cp build/libcompiler.so artifacts/libcompiler.amd64.so
tar -czvf initia_${{ github.sha }}_Linux_amd64.tar.gz -C artifacts .

- name: Google Auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'

- name: Set up Cloud SDK
uses: 'google-github-actions/setup-gcloud@v2'

- name: Upload to GCS
env:
GCS_BUCKET: ${{ secrets.GCS_BUCKET }}
run: |
gsutil cp initia_${{ github.sha }}_Linux_amd64.tar.gz gs://${GCS_BUCKET}/networks/${{ env.L1_NETWORK_NAME }}/binaries/

- name: Verify upload and Generate public URL
env:
GCS_BUCKET: ${{ secrets.GCS_BUCKET }}
run: |
if gsutil stat gs://${GCS_BUCKET}/networks/${{ env.L1_NETWORK_NAME }}/binaries/initia_${{ github.sha }}_Linux_amd64.tar.gz; then
echo "File successfully uploaded"
echo "Public URL: https://storage.googleapis.com/${GCS_BUCKET}/networks/${{ env.L1_NETWORK_NAME }}/binaries/initia_${{ github.sha }}_Linux_amd64.tar.gz" >> $GITHUB_STEP_SUMMARY
else
echo "File upload failed"
exit 1
fi
109 changes: 109 additions & 0 deletions .github/workflows/build-linux-arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Build and Upload Multi-Platform Binaries

on:
workflow_call:

jobs:
build:
runs-on: ubuntu-20.04
timeout-minutes: 60

steps:
- name: Checkout code
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: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.4'

- name: Build Multi-Platform Binaries
run: |
docker buildx create --use
docker buildx build \
--platform linux/amd64,linux/arm64 \
--output "type=local,dest=./build" \
--file Dockerfile \
--progress plain \
.
echo "Multi-platform build completed"
ls -al build/

- name: Create output directories
run: |
mkdir -p ./build/initia_${GITHUB_REF#refs/tags/}_amd64
mkdir -p ./build/initia_${GITHUB_REF#refs/tags/}_arm64

- name: Move binaries to output directories
run: |
mv ./build/linux/amd64/initiad ./build/initia_${GITHUB_REF#refs/tags/}_amd64/initiad || true
mv ./build/linux/amd64/libmovevm.so ./build/initia_${GITHUB_REF#refs/tags/}_amd64/libmovevm.so || true
mv ./build/linux/amd64/libcompiler.so ./build/initia_${GITHUB_REF#refs/tags/}_amd64/libcompiler.so || true
mv ./build/linux/arm64/initiad ./build/initia_${GITHUB_REF#refs/tags/}_arm64/initiad || true
mv ./build/linux/arm64/libmovevm.so ./build/initia_${GITHUB_REF#refs/tags/}_arm64/libmovevm.so || true
mv ./build/linux/arm64/libcompiler.so ./build/initia_${GITHUB_REF#refs/tags/}_arm64/libcompiler.so || true

- name: Create tarballs
run: |
cd ./build
tar -czvf initia_${GITHUB_REF#refs/tags/}_Linux_amd64.tar.gz initia_${GITHUB_REF#refs/tags/}_amd64
tar -czvf initia_${GITHUB_REF#refs/tags/}_Linux_arm64.tar.gz initia_${GITHUB_REF#refs/tags/}_arm64

- name: Verify binary architecture
run: |
file ./build/initia_${GITHUB_REF#refs/tags/}_amd64/initiad || true
file ./build/initia_${GITHUB_REF#refs/tags/}_amd64/libmovevm.so || true
file ./build/initia_${GITHUB_REF#refs/tags/}_amd64/libcompiler.so || true
file ./build/initia_${GITHUB_REF#refs/tags/}_arm64/initiad || true
file ./build/initia_${GITHUB_REF#refs/tags/}_arm64/libmovevm.so || true
file ./build/initia_${GITHUB_REF#refs/tags/}_arm64/libcompiler.so || true

- name: Google Auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'

- name: Set up Cloud SDK
uses: 'google-github-actions/setup-gcloud@v2'

- name: Upload to GCS
env:
GCS_BUCKET: ${{ secrets.GCS_BUCKET }}
run: |
gsutil cp ./build/initia_${GITHUB_REF#refs/tags/}_Linux_amd64.tar.gz gs://${GCS_BUCKET}/initia/${GITHUB_REF#refs/tags}/
gsutil cp ./build/initia_${GITHUB_REF#refs/tags/}_Linux_arm64.tar.gz gs://${GCS_BUCKET}/initia/${GITHUB_REF#refs/tags}/

- name: Verify upload and Generate public URL
env:
GCS_BUCKET: ${{ secrets.GCS_BUCKET }}
run: |
if gsutil stat gs://${GCS_BUCKET}/initia/${GITHUB_REF#refs/tags}/initia_${GITHUB_REF#refs/tags}_Linux_amd64.tar.gz; then
echo "File successfully uploaded"
echo "Public URL: https://storage.googleapis.com/${GCS_BUCKET}/initia/${GITHUB_REF#refs/tags}/initia_${GITHUB_REF#refs/tags}_Linux_amd64.tar.gz" >> $GITHUB_STEP_SUMMARY
else
echo "File upload failed"
exit 1
fi
if gsutil stat gs://${GCS_BUCKET}/initia/${GITHUB_REF#refs/tags}/initia_${GITHUB_REF#refs/tags}_Linux_arm64.tar.gz; then
echo "File successfully uploaded"
echo "Public URL: https://storage.googleapis.com/${GCS_BUCKET}/initia/${GITHUB_REF#refs/tags}/initia_${GITHUB_REF#refs/tags}_Linux_arm64.tar.gz" >> $GITHUB_STEP_SUMMARY
else
echo "File upload failed"
exit 1
fi
Loading
Loading