diff --git a/.github/workflows/Dockerfile.linux.amd64 b/.github/workflows/Dockerfile.linux.amd64 new file mode 100644 index 00000000..bd4e2ef8 --- /dev/null +++ b/.github/workflows/Dockerfile.linux.amd64 @@ -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"] diff --git a/.github/workflows/build-and-upload.yml b/.github/workflows/build-and-upload.yml new file mode 100644 index 00000000..597e49c3 --- /dev/null +++ b/.github/workflows/build-and-upload.yml @@ -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 diff --git a/.github/workflows/build-darwin-amd64.yml b/.github/workflows/build-darwin-amd64.yml new file mode 100644 index 00000000..eb178c76 --- /dev/null +++ b/.github/workflows/build-darwin-amd64.yml @@ -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 diff --git a/.github/workflows/build-linux-amd64.yml b/.github/workflows/build-linux-amd64.yml new file mode 100644 index 00000000..2f330589 --- /dev/null +++ b/.github/workflows/build-linux-amd64.yml @@ -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 diff --git a/.github/workflows/build-linux-arm64.yml b/.github/workflows/build-linux-arm64.yml new file mode 100644 index 00000000..a96a4514 --- /dev/null +++ b/.github/workflows/build-linux-arm64.yml @@ -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 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 57734e03..0d651d30 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,104 +1,104 @@ -name: Docker - -on: - workflow_dispatch: - push: - branches: - - "main" - tags: - - "v*" - paths: - - "**.go" - - "go.mod" - - "go.sum" - pull_request: - branches: - - "main" - paths: - - "**.go" - - "go.mod" - - "go.sum" - -env: - REGISTRY: ghcr.io - -jobs: - initiad: - name: Initiad - runs-on: ubuntu-latest - - permissions: - contents: read - packages: write - - outputs: - tags: ${{ steps.meta.outputs.tags }} - - env: - IMAGE_NAME: initiad - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} - - - name: Build and push - uses: docker/build-push-action@v4 - with: - build-args: "GITHUB_ACCESS_TOKEN=${{ secrets.GH_READ_TOKEN }}" - file: images/private/Dockerfile - push: ${{ startsWith(github.ref, 'refs/tags') }} # push image only for tags - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - node: - name: Node - needs: initiad - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - env: - IMAGE_NAME: node - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} - - - name: Get base image - run: echo "BASE_IMAGE=$(echo ${{ needs.initiad.outputs.tags }} | cut -d',' -f1)" >> "$GITHUB_ENV" - - - name: Build and push - uses: docker/build-push-action@v4 - with: - build-args: "GITHUB_ACCESS_TOKEN=${{ secrets.GH_READ_TOKEN }},BASE_IMAGE=${{ env.BASE_IMAGE }}" - file: images/node/Dockerfile - push: ${{ startsWith(github.ref, 'refs/tags') }} # push image only for tags - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} +# name: Docker + +# on: +# workflow_dispatch: +# push: +# branches: +# - "main" +# tags: +# - "v*" +# paths: +# - "**.go" +# - "go.mod" +# - "go.sum" +# pull_request: +# branches: +# - "main" +# paths: +# - "**.go" +# - "go.mod" +# - "go.sum" + +# env: +# REGISTRY: ghcr.io + +# jobs: +# initiad: +# name: Initiad +# runs-on: ubuntu-latest + +# permissions: +# contents: read +# packages: write + +# outputs: +# tags: ${{ steps.meta.outputs.tags }} + +# env: +# IMAGE_NAME: initiad + +# steps: +# - name: Checkout +# uses: actions/checkout@v3 + +# - name: Log in to the Container registry +# uses: docker/login-action@v2 +# with: +# registry: ${{ env.REGISTRY }} +# username: ${{ github.actor }} +# password: ${{ secrets.GITHUB_TOKEN }} + +# - name: Extract metadata (tags, labels) for Docker +# id: meta +# uses: docker/metadata-action@v4 +# with: +# images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} + +# - name: Build and push +# uses: docker/build-push-action@v4 +# with: +# build-args: "GITHUB_ACCESS_TOKEN=${{ secrets.GH_READ_TOKEN }}" +# file: images/private/Dockerfile +# push: ${{ startsWith(github.ref, 'refs/tags') }} # push image only for tags +# tags: ${{ steps.meta.outputs.tags }} +# labels: ${{ steps.meta.outputs.labels }} + +# node: +# name: Node +# needs: initiad +# runs-on: ubuntu-latest +# permissions: +# contents: read +# packages: write + +# env: +# IMAGE_NAME: node + +# steps: +# - name: Checkout +# uses: actions/checkout@v3 + +# - name: Log in to the Container registry +# uses: docker/login-action@v2 +# with: +# registry: ${{ env.REGISTRY }} +# username: ${{ github.actor }} +# password: ${{ secrets.GITHUB_TOKEN }} + +# - name: Extract metadata (tags, labels) for Docker +# id: meta +# uses: docker/metadata-action@v4 +# with: +# images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} + +# - name: Get base image +# run: echo "BASE_IMAGE=$(echo ${{ needs.initiad.outputs.tags }} | cut -d',' -f1)" >> "$GITHUB_ENV" + +# - name: Build and push +# uses: docker/build-push-action@v4 +# with: +# build-args: "GITHUB_ACCESS_TOKEN=${{ secrets.GH_READ_TOKEN }},BASE_IMAGE=${{ env.BASE_IMAGE }}" +# file: images/node/Dockerfile +# push: ${{ startsWith(github.ref, 'refs/tags') }} # push image only for tags +# tags: ${{ steps.meta.outputs.tags }} +# labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/linux-amd64.yml b/.github/workflows/linux-amd64.yml new file mode 100644 index 00000000..f4df2c62 --- /dev/null +++ b/.github/workflows/linux-amd64.yml @@ -0,0 +1,57 @@ +name: CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + L1_NETWORK_NAME: testnet + MOVEVM_VERSION: v0.2.12 + +jobs: + build-linux-amd64: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - name: Build + uses: docker/build-push-action@v5 + with: + context: . + file: .github/workflows/Dockerfile.linux.amd64 + load: true + tags: initia:linux-amd64 + - name: Export binary + run: | + docker create --name temp initia:linux-amd64 + docker cp temp:/app ./app + tar -czvf initia_${{ github.sha }}_Linux_amd64.tar.gz -C app . + docker rm temp + + - 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/testnet/binaries/ + + - name: Verify upload and Generate public URL + env: + GCS_BUCKET: ${{ secrets.GCS_BUCKET }} + run: | + if gsutil stat gs://${GCS_BUCKET}/networks/testnet/binaries/initia_${{ github.sha }}_Linux_amd64.tar.gz; then + echo "File successfully uploaded" + echo "Public URL: https://storage.googleapis.com/${GCS_BUCKET}/networks/testnet/binaries/initia_${{ github.sha }}_Linux_amd64.tar.gz" >> $GITHUB_STEP_SUMMARY + else + echo "File upload failed" + exit 1 + fi