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 bec476e commit 1693f7f
Showing 1 changed file with 62 additions and 15 deletions.
77 changes: 62 additions & 15 deletions .github/workflows/build-linux-arm64.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Build Linux ARM64
name: Build and Upload Multi-Platform Binaries

on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
timeout-minutes: 60
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -15,25 +17,62 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build for Linux ARM64
- 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/arm64 --load -t initia-build:arm64 -f Dockerfile.arm64 .
docker create --name extractor initia-build:arm64
mkdir -p ./build/initia_${GITHUB_REF#refs/tags/}
docker cp extractor:/app/build/libmovevm.so ./build/initia_${GITHUB_REF#refs/tags/}/libmovevm.arm64.so
docker cp extractor:/app/build/libcompiler.so ./build/initia_${GITHUB_REF#refs/tags/}/libcompiler.arm64.so
docker cp extractor:/app/build/initiad ./build/initia_${GITHUB_REF#refs/tags/}/
docker rm extractor
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_arm64.tar.gz initia_${GITHUB_REF#refs/tags/}
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/}/initiad
file ./build/initia_${GITHUB_REF#refs/tags/}/libmovevm.arm64.so
file ./build/initia_${GITHUB_REF#refs/tags/}/libcompiler.arm64.so
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:
Expand All @@ -46,12 +85,20 @@ jobs:
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
Expand Down

0 comments on commit 1693f7f

Please sign in to comment.