From 5a5317f4374725182ccd75725fc3514b0b25f093 Mon Sep 17 00:00:00 2001 From: Sam Cao Date: Wed, 16 Oct 2024 09:20:30 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=8E=20ci:=20Split=20console=20builds?= =?UTF-8?q?=20by=20os,=20arch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/android_build.yml | 4 + .github/workflows/console_build.yml | 160 +++++++++++++++------------- 2 files changed, 88 insertions(+), 76 deletions(-) diff --git a/.github/workflows/android_build.yml b/.github/workflows/android_build.yml index aa704cb..898e429 100644 --- a/.github/workflows/android_build.yml +++ b/.github/workflows/android_build.yml @@ -9,11 +9,15 @@ on: pull_request: types: [opened, synchronize, reopened, ready_for_review] paths-ignore: + - .github/** + - "!.github/workflows/android_build.yml" - "**.md" - "docs/**" - "console/**" push: paths-ignore: + - .github/** + - "!.github/workflows/android_build.yml" - "**.md" - "docs/**" - "console/**" diff --git a/.github/workflows/console_build.yml b/.github/workflows/console_build.yml index 5918e14..2cdaf91 100644 --- a/.github/workflows/console_build.yml +++ b/.github/workflows/console_build.yml @@ -9,11 +9,15 @@ on: pull_request: types: [opened, synchronize, reopened, ready_for_review] paths-ignore: + - .github/** + - "!.github/workflows/console_build.yml" - "**.md" - "docs/**" - "android/**" push: paths-ignore: + - .github/** + - "!.github/workflows/console_build.yml" - "**.md" - "docs/**" - "android/**" @@ -22,84 +26,88 @@ env: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} jobs: - jar_for_linux_and_windows_x86_64: - name: Jar for Linux and Windows x86_64 - runs-on: ubuntu-latest + build_jar: + strategy: + matrix: + include: + - name: Linux x86_64 + image: ubuntu-latest + jar_name: linux-x86-64 + zip_exclude_files: "*.dll *arm64*.so dylib" + - name: MacOS x86_64 + image: macos-13 + jar_name: macos-x86-64 + zip_exclude_files: "*.dll *.so *arm64*.dylib" + - name: MacOS arm64 + image: macos-14 + jar_name: macos-arm64 + zip_exclude_files: "*.dll *.so *x86_64*.dylib" + - name: Windows x86_64 + image: windows-latest + jar_name: windows-x86-64 + zip_exclude_files: "*arm64*.dll *.dylib *.so" + + name: Build Jar for ${{ matrix.name }} + runs-on: ${{ matrix.image }} steps: - - - name: Checkout the code - uses: actions/checkout@v4 - - - name: Setup JDK 17 - uses: actions/setup-java@v4 - with: - distribution: corretto - java-version: 17 - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v4 - with: - gradle-version: 8.5 - - - name: Build the Artifact - run: | - cd console - gradle build --debug - - - name: Upload the Artifact - uses: actions/upload-artifact@v4 - with: - name: javet-shell-console-linux-windows_x86-64 - path: console/build/libs/*.jar - - jar_for_macos: - name: Jar for MacOS - runs-on: macos-latest - - steps: - - - name: Checkout the code - uses: actions/checkout@v4 - - - name: Setup JDK 17 - uses: actions/setup-java@v4 - with: - distribution: corretto - java-version: 17 - - - name: Setup Gradle - uses: gradle/gradle-build-action@v3 - with: - gradle-version: 8.5 - - - name: Build the Artifact - run: | - cd console - gradle build --debug - - - name: Upload the Artifact - uses: actions/upload-artifact@v4 - with: - name: javet-shell-console-macos - path: console/build/libs/*.jar - - docker_image_for_linux_amd64: - name: Docker Image for Linux amd64 + - name: Checkout the code + uses: actions/checkout@v4 + + - name: Setup JDK 17 + uses: actions/setup-java@v4 + with: + distribution: corretto + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + with: + gradle-version: 8.5 + + - name: Build the Artifact + run: | + cd console + gradle build --debug + + - name: Remove Binary Files for Linux + uses: edgarrc/action-7z@v1 + if: matrix.name == 'Linux x86_64' + with: + args: 7z d build/libs/*.jar ${{ matrix.zip_exclude_files }} + + - name: Remove Binary Files for MacOS + if: matrix.name == 'MacOS x86_64' || matrix.name == 'MacOS arm64' + run: | + zip -d build/libs/*.jar ${{ matrix.zip_exclude_files }} + + - name: Remove Binary Files for Windows + if: matrix.name == 'Windows x86_64' + run: | + choco install 7zip.install + 7z d build/libs/*.jar ${{ matrix.zip_exclude_files }} + + - name: Upload the Artifact + uses: actions/upload-artifact@v4 + with: + name: javet-shell-console-${{ matrix.jar_name }} + path: console/build/libs/*.jar + + build_docker_image: + name: Build Docker Image for Linux x86_64 runs-on: ubuntu-latest steps: - - - name: Checkout the code - uses: actions/checkout@v4 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Docker Build and Push - run: | - docker build -t ${{ env.DOCKERHUB_USERNAME }}/javet-shell:amd64-latest -f docker/console.Dockerfile . - docker push ${{ env.DOCKERHUB_USERNAME }}/javet-shell:amd64-latest + - name: Checkout the code + uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Docker Build and Push + run: | + docker build -t ${{ env.DOCKERHUB_USERNAME }}/javet-shell:amd64-latest -f docker/console.Dockerfile . + docker push ${{ env.DOCKERHUB_USERNAME }}/javet-shell:amd64-latest