Skip to content

Commit

Permalink
Update build-linux-arm64.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
LizJeong authored Jul 15, 2024
1 parent 1693f7f commit 47cbcbc
Showing 1 changed file with 41 additions and 102 deletions.
143 changes: 41 additions & 102 deletions .github/workflows/build-linux-arm64.yml
Original file line number Diff line number Diff line change
@@ -1,108 +1,47 @@
name: Build and Upload Multi-Platform Binaries
name: Multi-Architecture Build

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

jobs:
build:
runs-on: ubuntu-20.04
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
os: [linux, darwin]
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 \
--file .github/workflows/Dockerfile \
--platform linux/amd64,linux/arm64 \
--output "type=local,dest=./build" \
--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
- uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build for ${{ matrix.os }}-${{ matrix.arch }}
env:
ARCH: ${{ matrix.arch }}
OS: ${{ matrix.os }}
L1_VERSION: ${{ github.sha }}
L1_NETWORK_NAME: testnet
MOVEVM_VERSION: v0.1.0 # 적절한 버전으로 변경하세요
run: |
docker buildx build --platform ${{ matrix.os }}/${{ matrix.arch }} \
--file .github/workflows/Dockerfile \
--build-arg ARCH=${{ matrix.arch }} \
--build-arg OS=${{ matrix.os }} \
--build-arg L1_VERSION=${{ env.L1_VERSION }} \
--build-arg L1_NETWORK_NAME=${{ env.L1_NETWORK_NAME }} \
--build-arg MOVEVM_VERSION=${{ env.MOVEVM_VERSION }} \
--output type=local,dest=./output \
.
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: initia-${{ matrix.os }}-${{ matrix.arch }}
path: ./output/initia_${{ env.L1_VERSION }}_${{ matrix.os }}_${{ matrix.arch }}.tar.gz

0 comments on commit 47cbcbc

Please sign in to comment.