Build and Push native image to Google Cloud Storage #5
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push native image to Google Cloud Storage | |
| on: | |
| # This allows manual activation of this action for testing. | |
| workflow_dispatch: | |
| env: | |
| GITHUB_SHA: ${{ github.sha }} | |
| GITHUB_REF: ${{ github.ref }} | |
| jobs: | |
| setup-build-publish-deploy: | |
| name: 'Build Native Image ${{ matrix.platform }}' | |
| strategy: | |
| matrix: | |
| os: [ macos-latest, ubuntu-latest ] | |
| include: | |
| - os: 'ubuntu-latest' | |
| platform: 'linux-amd64' | |
| - os: 'macos-latest' | |
| platform: 'darwin-arm64' | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - id: 'auth' | |
| uses: 'google-github-actions/auth@v2' | |
| with: | |
| credentials_json: '${{ secrets.CLOUD_SPANNER_PG_ADAPTER_SERVICE_ACCOUNT }}' | |
| # Setup GraalVM | |
| - uses: graalvm/setup-graalvm@v1 | |
| with: | |
| java-version: '23' | |
| distribution: 'graalvm-community' | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| native-image-job-reports: 'true' | |
| # Build the assembly and native image | |
| - name: Build assembly | |
| run: | | |
| mvn package -Passembly -DskipTests | |
| export VERSION=`echo $GITHUB_REF | awk -F/ '{print $NF}'` | |
| echo $VERSION | |
| cd "target/pgadapter" | |
| native-image \ | |
| --initialize-at-build-time=com.google.protobuf,com.google.gson,com.google.cloud.spanner.pgadapter.Server \ | |
| -J-Xmx14g \ | |
| -H:IncludeResources=".*" \ | |
| -H:ReflectionConfigurationFiles=../../build/native-image/reflect-config.json \ | |
| -jar pgadapter.jar \ | |
| --no-fallback | |
| tar -czvf "pgadapter-${{ matrix.platform }}.tar.gz" pgadapter | |
| cp "pgadapter-${{ matrix.platform }}.tar.gz" "pgadapter-${{ matrix.platform }}-$VERSION.tar.gz" | |
| echo "native_image=target/pgadapter/pgadapter-${{ matrix.platform }}-$VERSION.tar.gz" >> $GITHUB_ENV | |
| echo "native_image_current=target/pgadapter/pgadapter-${{ matrix.platform }}.tar.gz" >> $GITHUB_ENV | |
| echo ${{ env.native_image }} | |
| echo ${{ env.native_image_current }} | |
| # Upload the native image to Google Cloud Storage | |
| - id: 'upload-versioned-file' | |
| uses: 'google-github-actions/upload-cloud-storage@v2' | |
| with: | |
| path: ${{ env.native_image }} | |
| destination: 'pgadapter-jar-releases' | |
| parent: false | |
| - id: 'overwrite-current-file' | |
| uses: 'google-github-actions/upload-cloud-storage@v2' | |
| with: | |
| path: ${{ env.native_image_current }} | |
| destination: 'pgadapter-jar-releases' | |
| parent: false |