Skip to content

Integrate GraalVM for Native Image Compilation #13

Integrate GraalVM for Native Image Compilation

Integrate GraalVM for Native Image Compilation #13

Workflow file for this run

name: Build
on:
push:
pull_request:
branches:
- main
release:
types:
- prereleased
- released
jobs:
precheck:
runs-on: [ubuntu-24.04]
outputs:
version: ${{ steps.get_version.outputs.version }}
version_number: ${{ steps.get_version.outputs.version_number }}
full_version: ${{ steps.get_version.outputs.full_version }}
branchTag: ${{ steps.get_version.outputs.branchTag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Validate Release
if: github.event_name == 'release' || github.event_name == 'prerelease'
run: |
TAG_NAME=${GITHUB_REF/refs\/tags\//}
VERSION_FILE=$(cat VERSION)
if [ "$TAG_NAME" != "$VERSION_FILE" ]; then
echo "tag $TAG_NAME not equals to VERSION file $VERSION_FILE"
exit 1
fi
- name: Get Versions
id: get_version
run: |
VERSION_FILE=$(cat VERSION)
echo ::set-output name=branchTag::$(echo $GITHUB_REF | cut -d / -f 3)
if [[ "$VERSION_FILE" =~ ^v([0-9]+)\.([0-9]+)(\.([0-9]+))?(\.([0-9]+))?$ ]] ; then
VERSION=${VERSION_FILE}.${{ github.run_number }}
VERSION_NUMBER=$(echo "${VERSION_FILE}" | cut -d "v" -f 2).${{ github.run_number }}
SHORT_COMMIT=$(git rev-parse --short=4 HEAD)
FULL_VERSION="${VERSION}_${SHORT_COMMIT}"
echo ::set-output name=full_version::${FULL_VERSION}
echo ::set-output name=version::${VERSION}
echo ::set-output name=version_number::${VERSION_NUMBER}
else
echo "VERSION file doesn't have valid version format: ^v([0-9]+)\.([0-9]+)(\.([0-9]+))?(\.([0-9]+))?$"
exit 1
fi
build_client:
runs-on: [ubuntu-24.04]
needs: [precheck]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
graalvm-version: '22.1.0'
java-version: '17'
- name: Grant execute permission for gradlew
run: cd client && chmod +x gradlew
- name: Build
run: cd client && ./gradlew build
- name: Test
run: cd client && ./gradlew test
- name: Package
run: cd client && ./gradlew bootJar
- name: Build Native Image
run: cd client && make build_linux VERSION=${{ needs.precheck.outputs.version }} COMMIT=$(git rev-parse HEAD)
- name: List build directory
run: |
ls -la client/build/
ls -la client/build/libs/
ls -la client/build/native/nativeCompile/
- name: Archive files
uses: actions/upload-artifact@v4
with:
name: app-${{ needs.precheck.outputs.full_version }}
path: |
client/build/*.jar
client/build/libs/*.jar
client/build/native/nativeCompile/toscactl-linux-amd64
- name: Release Asset Upload
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'release' || github.event_name == 'prerelease'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: client/build/native/nativeCompile/toscactl-linux-amd64
tag: ${{ needs.precheck.outputs.branchTag }}
overwrite: true
file_glob: true