From 9851a393fede8821489317d54e5bf02e6dc0bf72 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Mon, 12 Feb 2024 16:09:19 -0800 Subject: [PATCH] Generate native-image binaries for google-java-format And include them in release artifacts. I tested this on my fork of the repo, and have a demo here: https://github.com/cushon/google-java-format/releases When downloading the artifacts from the releases page they don't have the executable bit set, and my Mac blocks them because they aren't signed. That can be worked around with the following, but isn't ideal: ``` chmod a+rx google-java-format-darwin sudo xattr -r -d com.apple.quarantine google-java-format-darwin ``` Progress towards #868 --- .github/workflows/release.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf57f3e94..3dafd8cd3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,3 +79,31 @@ jobs: files: | core/target/google-java-format* eclipse_plugin/target/google-java-format-eclipse-plugin-*.jar + + build-native-image: + name: "Build GraalVM native-image on ${{ matrix.os }}" + runs-on: ${{ matrix.os }} + needs: build-maven-jars + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + steps: + - name: "Check out repository" + uses: actions/checkout@v4 + - name: "Set up GraalVM" + uses: graalvm/setup-graalvm@v1 + with: + java-version: "21" + distribution: "graalvm-community" + github-token: ${{ secrets.GITHUB_TOKEN }} + native-image-job-reports: "true" + cache: "maven" + - name: "Native" + run: mvn -Pnative -DskipTests package -pl core -am + - name: "Move outputs" + run: cp core/target/google-java-format google-java-format-${{ matrix.os == 'ubuntu-latest' && 'linux' || 'darwin' }} + - name: "Upload native-image" + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + run: gh release upload "v${{ github.event.inputs.version }}" "google-java-format-${{ matrix.os == 'ubuntu-latest' && 'linux' || 'darwin' }}"